diff --git a/.chglog/CHANGELOG-full-history.tpl.md b/.chglog/CHANGELOG-full-history.tpl.md new file mode 100644 index 0000000..a7497c9 --- /dev/null +++ b/.chglog/CHANGELOG-full-history.tpl.md @@ -0,0 +1,111 @@ +{{- $repourl := $.Info.RepositoryURL -}} +# 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]({{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD) + +{{ if .Unreleased.NoteGroups }} +{{ range .Unreleased.NoteGroups -}} +### {{ .Title }} +{{ range .Notes -}} +{{ .Body }} +{{ end -}} +{{ end -}} +{{ end -}} +{{ range .Unreleased.CommitGroups }} +{{ range .Commits -}} + +{{- /** Remove markdown urls when there's a pull request linked and replace it with a tag **/ -}} +{{- $subject := (regexReplaceAll `URL` (regexReplaceAll `\[#(\d+)\]\(.*?\)` .Subject "#${1}") $repourl) -}} +{{- /** Filter out refs mentioned in the title **/ -}} +{{- $list := (list) -}} +{{- range $idx, $ref := .Refs -}} +{{- if not (regexMatch $ref.Ref $subject) -}} +{{ $list = append $list $ref }} +{{- end -}} +{{- end -}} +{{- /** end custom variables **/ -}} + +{{ if .TrimmedBody -}}
{{ else -}}- {{ end -}} +{{.Hash.Short}} {{ $subject }} +{{- if $list -}} +{{ printf " %s " "(closes"}} +{{- range $idx, $ref := $list -}}{{ if $idx }}, {{ end -}} + #{{ $ref.Ref}}{{ end }}) +{{- end -}} +{{ if .TrimmedBody -}}{{ printf "\n\n%s\n\n" .TrimmedBody }}
{{ end }} + +{{ end }} +{{ end -}} + +{{- if .Versions }} +{{ range .Versions -}} + +## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}[{{ .Tag.Name }}](https://github.com/niko0xdev/gqlgen/releases/tag/{{ .Tag.Name }}){{ end }} - {{ datetime "2006-01-02" .Tag.Date }} +{{- if .CommitGroups -}} +{{ range .CommitGroups -}} + +### {{ .Title }} +{{ range .Commits -}} +{{- /** Remove markdown urls when there's a pull request linked and replace it with a tag **/ -}} +{{- $subject := (regexReplaceAll `URL` (regexReplaceAll `\[#(\d+)\]\(.*?\)` .Subject "#${1}") $repourl) -}} +{{- /** Filter out refs mentioned in the title **/ -}} +{{- $list := (list) -}} +{{- range $idx, $ref := .Refs -}} +{{- if not (regexMatch $ref.Ref $subject) -}} +{{ $list = append $list $ref }} +{{- end -}} +{{- end -}} +{{- /** end custom varaibles **/ -}} + +{{ if .TrimmedBody -}}
{{ else -}}- {{ end -}} +{{.Hash.Short}} {{ $subject }} +{{- if $list -}} +{{ printf " %s " "(closes"}} +{{- range $idx, $ref := $list -}}{{ if $idx }}, {{ end -}} + #{{ $ref.Ref}}{{ end }}) +{{- end -}} + +- {{ if .Type }}**{{ .Type }}:** {{ end }}{{ if .Subject }}{{ .Subject }}{{ else }}{{ .Header }}{{ end }} +{{ end }} +{{ end -}} +{{ else }} +{{ range .Commits -}} + +{{- /** Remove markdown urls when there's a pull request linked and replace it with a tag **/ -}} +{{- $subject := (regexReplaceAll `URL` (regexReplaceAll `\[#(\d+)\]\(.*?\)` .Subject "#${1}") $repourl) -}} +{{- /** Filter out refs mentioned in the title **/ -}} +{{- $list := (list) -}} +{{- range $idx, $ref := .Refs -}} +{{- if not (regexMatch $ref.Ref $subject) -}} +{{ $list = append $list $ref }} +{{- end -}} +{{- end -}} +{{- /** end custom variables **/ -}} + +{{ if .TrimmedBody -}}
{{ else -}}- {{ end -}} +{{.Hash.Short}} {{ $subject }} +{{- if $list -}} +{{ printf " %s " "(closes"}} +{{- range $idx, $ref := $list -}}{{ if $idx }}, {{ end -}} + #{{ $ref.Ref}}{{ end }}) +{{- end -}} +{{ if .TrimmedBody -}}{{ printf "\n\n%s\n\n" .TrimmedBody }}
{{ end }} + +{{ end }} +{{ end -}} + +{{ if .NoteGroups }} +{{ range .NoteGroups -}} +### {{ .Title }} +{{ range .Notes -}} +{{ .Body }} +{{ end -}} +{{ end -}} +{{ end -}} +{{ end -}} +{{ end -}} diff --git a/.chglog/config.yml b/.chglog/config.yml new file mode 100755 index 0000000..3486f1b --- /dev/null +++ b/.chglog/config.yml @@ -0,0 +1,18 @@ +style: github +template: CHANGELOG-full-history.tpl.md +info: + title: CHANGELOG + repository_url: https://github.com/niko0xdev/gqlgen +options: + commits: + # filters: + # Type: [] + commit_groups: + # title_maps: [] + header: + pattern: "^(.*)$" + pattern_maps: + - Subject + notes: + keywords: + - BREAKING CHANGE \ No newline at end of file diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c8aadf3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +/**/node_modules +/codegen/tests/gen +/vendor diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..feba8bb --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +root = true + +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = space +indent_size = 4 + +[*.{go,gotpl}] +indent_style = tab + +[*.yml] +indent_size = 2 + +# These often end up with go code inside, so lets keep tabs +[*.{html,md}] +indent_size = 2 +indent_style = tab diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..0555011 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +/codegen/templates/data.go linguist-generated +/_examples/dataloader/*_gen.go linguist-generated +generated.go linguist-generated diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..12c453c --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,9 @@ +### What happened? + +### What did you expect? + +### Minimal graphql.schema and models to reproduce + +### versions + - `go run github.com/niko0xdev/gqlgen version`? + - `go version`? diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..fd9346b --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,5 @@ +Describe your PR and link to any relevant issues. + +I have: + - [ ] Added tests covering the bug / feature (see [testing](https://github.com/niko0xdev/gqlgen/blob/master/TESTING.md)) + - [ ] Updated any relevant documentation (see [docs](https://github.com/niko0xdev/gqlgen/tree/master/docs/content)) diff --git a/.github/workflows/check-coverage b/.github/workflows/check-coverage new file mode 100755 index 0000000..5854f7f --- /dev/null +++ b/.github/workflows/check-coverage @@ -0,0 +1,10 @@ +#!/bin/bash + +set -euo pipefail +GO111MODULE=off go get github.com/mattn/goveralls + +go test -covermode atomic -coverprofile=/tmp/coverage.out.tmp -coverpkg=./... $(go list github.com/niko0xdev/gqlgen/... | grep -v _examples) +# ignore protobuf files +cat /tmp/coverage.out.tmp | grep -v ".pb.go" > /tmp/coverage.out + +goveralls -coverprofile=/tmp/coverage.out -service=github -ignore='_examples/*/*,_examples/*/*/*,integration/*,integration/*/*,codegen/testserver/*/*,plugin/federation/testdata/*/*/*,*/generated.go,*/*/generated.go,*/*/*/generated.go,graphql/executable_schema_mock.go' diff --git a/.github/workflows/check-federation b/.github/workflows/check-federation new file mode 100755 index 0000000..8025e8e --- /dev/null +++ b/.github/workflows/check-federation @@ -0,0 +1,22 @@ +#!/bin/bash + +set -euo pipefail + +cd _examples/federation + +./start.sh & + +sleep 5 +curl -s --connect-timeout 5 \ + --max-time 10 \ + --retry 5 \ + --retry-delay 5 \ + --retry-max-time 40 \ + --retry-connrefused \ + localhost:4003 > /dev/null + +sleep 1 + +echo "### running jest integration spec" +./node_modules/.bin/jest --color + diff --git a/.github/workflows/check-fmt b/.github/workflows/check-fmt new file mode 100755 index 0000000..1e3b3b4 --- /dev/null +++ b/.github/workflows/check-fmt @@ -0,0 +1,11 @@ +#!/bin/bash + +set -euo pipefail + +go fmt ./... +cd _examples && go fmt ./... +if [[ $(git --no-pager diff) ]] ; then + echo "you need to run "go fmt" and commit the changes" + git --no-pager diff + exit 1 +fi diff --git a/.github/workflows/check-generate b/.github/workflows/check-generate new file mode 100755 index 0000000..815c78e --- /dev/null +++ b/.github/workflows/check-generate @@ -0,0 +1,11 @@ +#!/bin/bash + +set -euo pipefail + +go generate ./... +cd _examples && go generate ./... +if [[ $(git --no-pager diff) ]] ; then + echo "you need to run "go generate ./..." and commit the changes" + git --no-pager diff + exit 1 +fi diff --git a/.github/workflows/check-init b/.github/workflows/check-init new file mode 100755 index 0000000..3f602a0 --- /dev/null +++ b/.github/workflows/check-init @@ -0,0 +1,21 @@ +#!/bin/bash + +set -euo pipefail + +gqlgen_dir=$(pwd) +cd $(mktemp -d) +go mod init inittest +printf '// +build tools\npackage tools\nimport _ "github.com/niko0xdev/gqlgen"' | gofmt > tools.go +go mod tidy +go mod edit -replace=github.com/niko0xdev/gqlgen="$gqlgen_dir" +go mod tidy + +if ! go run github.com/niko0xdev/gqlgen init ; then + echo "gqlgen init failed" + exit 125 +fi + +if ! go run github.com/niko0xdev/gqlgen generate ; then + echo "gqlgen generate failed" + exit 125 +fi diff --git a/.github/workflows/check-integration b/.github/workflows/check-integration new file mode 100755 index 0000000..c079cd6 --- /dev/null +++ b/.github/workflows/check-integration @@ -0,0 +1,29 @@ +#!/bin/bash + +set -euo pipefail + +cd integration + +date +go run ./server/cmd/integration/server.go & + +sleep 5 +curl -s --connect-timeout 5 \ + --max-time 10 \ + --retry 5 \ + --retry-delay 5 \ + --retry-max-time 40 \ + --retry-connrefused \ + localhost:8080 > /dev/null + + +echo "### validating introspected schema" +npm run gen + +if ! diff <(tail -n +3 src/generated/schema-expected.graphql) <(tail -n +3 src/generated/schema-fetched.graphql) ; then + echo "The expected schema has changed, you need to update schema-expected.graphql with any expected changes" + exit 1 +fi + +echo "### running integration spec" +npm run test diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml new file mode 100644 index 0000000..806a44b --- /dev/null +++ b/.github/workflows/integration.yml @@ -0,0 +1,56 @@ +name: Integration +on: [push, pull_request] +# When a new revision is pushed to a PR, cancel all in-progress CI runs for that +# PR. See https://docs.github.com/en/actions/using-jobs/using-concurrency +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true +jobs: + integration: + strategy: + matrix: + go: ["1.18", "1.20"] + node: [18] + runs-on: ubuntu-latest + timeout-minutes: 3 + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go }} + - uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node }} + - run: go mod download + - run: cd integration ; npm ci + - run: .github/workflows/check-integration + + federation: + strategy: + matrix: + go: ["1.18", "1.20"] + node: [14] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go }} + - uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node }} + - run: go mod download + - run: cd _examples/federation ; npm install + - run: .github/workflows/check-federation + + init: + strategy: + matrix: + go: ["1.18", "1.20"] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go }} + - run: .github/workflows/check-init diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..a53bb83 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,55 @@ +name: Lint +on: [push, pull_request] +# When a new revision is pushed to a PR, cancel all in-progress CI runs for that +# PR. See https://docs.github.com/en/actions/using-jobs/using-concurrency +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true +jobs: + lint: + strategy: + matrix: + go: ["1.19", "1.20"] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go }} + - run: go mod download + - run: .github/workflows/check-fmt + - run: .github/workflows/check-generate + + coverage: + strategy: + matrix: + go: ["1.19", "1.20"] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go }} + - run: go mod download + - run: .github/workflows/check-coverage + env: + COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + golangci-lint: + strategy: + matrix: + go: ["1.19", "1.20"] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go }} + - name: golangci-lint + uses: golangci/golangci-lint-action@v3.5.0 + with: + version: latest + # skip cache because of flaky behaviors + skip-build-cache: true + skip-pkg-cache: true + args: '--timeout 5m' diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml new file mode 100644 index 0000000..635e643 --- /dev/null +++ b/.github/workflows/security.yml @@ -0,0 +1,20 @@ +name: Security +on: [push, pull_request] +# When a new revision is pushed to a PR, cancel all in-progress CI runs for that +# PR. See https://docs.github.com/en/actions/using-jobs/using-concurrency +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true +jobs: + nancy: + strategy: + matrix: + go: ["1.20"] # nancy is a little flaky + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go }} + - run: go mod download && go list -json -deps all > go.list + - uses: sonatype-nexus-community/nancy-github-action@main diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..6d211ec --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,37 @@ +name: Test +on: [push, pull_request] +# When a new revision is pushed to a PR, cancel all in-progress CI runs for that +# PR. See https://docs.github.com/en/actions/using-jobs/using-concurrency +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true +jobs: + test: + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + go: ["1.18", "1.20"] + runs-on: ${{ matrix.os }} + continue-on-error: true + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go }} + - name: Core tests + uses: nick-fields/retry@v2 + with: + max_attempts: 3 + timeout_minutes: 20 + command: | + go mod download + go test -race ./... + - name: Example tests + uses: nick-fields/retry@v2 + with: + max_attempts: 3 + timeout_minutes: 20 + command: | + cd _examples + go mod download + go test -race ./... diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cbc986f --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +/vendor +/docs/public +/docs/.hugo_build.lock +/_examples/chat/node_modules +/integration/node_modules +/integration/schema-fetched.graphql +/_examples/chat/package-lock.json +/_examples/federation/package-lock.json +/_examples/federation/node_modules +/codegen/gen +/gen + +/.vscode +.idea/ +*.test +*.out +gqlgen +*.exe diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..5966bf2 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,35 @@ +run: + tests: true + skip-dirs: + - bin + +linters-settings: + errcheck: + ignore: fmt:.*,[rR]ead|[wW]rite|[cC]lose,io:Copy + +linters: + disable-all: true + enable: + - bodyclose + - dupl + - errcheck + - gocritic + - gofmt + - goimports + - gosimple + - govet + - ineffassign + - misspell + - nakedret + - prealloc + - staticcheck + - typecheck + - unconvert + - unused + +issues: + exclude-rules: + # Exclude some linters from running on tests files. + - path: _test\.go + linters: + - dupl diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..792f80f --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11183 @@ +# 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](https://github.com/niko0xdev/gqlgen/compare/v0.17.42...HEAD) + + + + +## [v0.17.42](https://github.com/niko0xdev/gqlgen/compare/v0.17.41...v0.17.42) - 2023-12-29 +- 7bf0c223 release v0.17.42 + +
c811d47e fix: avoid panic from tracing on bad request (#2871) + +This fixes a panic which arises from the tracing components when a request has some defect which results in an error when creating the operation context. The transports consistently handle this by calling `DispatchError(graphql.WithOperationContext(ctx, rc), err)` where `rc` is the OperationContext which was not correctly constructed. This seems dangerous, because middleware may assume that if there in an `OperationContext` in the `context.Context` than they are being invoked on a normal codepath and can assume their other interceptors have been invoked in the normal order. Also, using a value returned by a function which also returned a non-nil error is very unusual. However, I have no idea what the impact of changing that dangerous behavior in the transports would be, so I opted to make the tracing component more resilient instead. + +
+ +- 13bb4152 fix for entity interfce code gen with related test (#2868) + +- 0354649c Remove archived dependency appdash (#2866) + +- 0d43599c Update examples go.mod with appdash replacements (#2863) + +- 7dd971c8 Use defer wg.Done() in FieldSet Dispatch (#2861) + +
24ea195c vikstrous/dataloadgen replaces recommended dataloader package in example docs (#2770) + +* update example for dataloadgen + +* improved example with link to example repo + +* undo unnecessary changes + +* fix wrong signature + +* fix creation of loader + +* Update docs/content/reference/dataloaders.md + +
+ +
42f6e39d Allow fields that return root level definitions (#2858) + +* generate structs for root level definitions to support fields that return Query, Mutation or Subscription + +* removed unnecessary comment + +* re-ran go generate + +--------- + +
+ +- 682a58dd Add go generate for examples so contributors never forget (#2859) + +
e080a96d Modify to prevent unreachable code from occurring (#2846) + +* fix: 型の数でソートする処理を追加 + +* 戻し + +* fix: case文の最初にスーパークラスが来ないようにする + +* testdata追加 + +* fix: Added sorting by number of types. +* fix: Prevent superclass from appearing at the beginning of case statement + +
+ +- 68744ad2 Bump changelog + +- e4cf21d2 v0.17.41 postrelease bump + + + + + + +## [v0.17.41](https://github.com/niko0xdev/gqlgen/compare/v0.17.40...v0.17.41) - 2023-12-03 +- fe60938c release v0.17.41 + +
5e98a16a fix fieldset.New bug when prefix slice has len < cap (#2851) + +* fix fieldset.New bug when prefix slice has len < cap + +* ignore gocritic warning + +
+ +
bd9657f3 Improve ResolverImplementer.Implment (#2850) + +* improve resolver implement render + +* add error when multiple implementors + +* add initial test + +
+ +
cb3c1c89 Updated apollo sandbox (#2849) + +Added all supported options to new window.EmbeddedSandbox object + +
+ +
eb5cea72 Small template fix to save space in the generated file (#2841) + +* Small template fix to save space in the generated file + +* Re-generate + + +--------- + +
+ +- c0ca5091 Omittable can now be serialized as json (#2839) + +- dcb76191 fix: sample program indentation (#2840) + +
132ec1ce Updated GraphiQL 3.0.1 => 3.0.6 (#2837) + +* Updated GraphiQL 3.0.1 => 3.0.6 + +* Added unit tests to cover integrity of playgrounds + +* Updated vulnerable dependency + +* Close response body + +
+ +- 91740700 v0.17.40 postrelease bump + + + + + + +## [v0.17.40](https://github.com/niko0xdev/gqlgen/compare/v0.17.39...v0.17.40) - 2023-10-24 +- c5ad14bf release v0.17.40 + +
74e918f9 Map based input types fields are now coerced to the right type (#2830) + +* Input maps now unmarshals and checks nested fields + +* Added unit tests + +* Tested required fields in input maps + +* Docs updated with disclaimer + +* Added test for nested inputs + +
+ +
1e5fa72a Bump [@babel](https://github.com/babel)/traverse from 7.22.5 to 7.23.2 in /integration (#2831) + +- [Release notes](https://github.com/babel/babel/releases) +- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) +- [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse) + +--- +updated-dependencies: + dependency-type: indirect +... + +
+ +
e5c17d63 resolver: fix case-insensitive file name collision (#2829) + +for compatibility with Windows/Mac OS X, Go does not allow files with +identical case-insensitive names. +this commit changes the key of the 'files' map to use the lower case +file name, keeping the original file name as a property on the File +object. + +
+ +- 9c5fc302 v0.17.39 postrelease bump + + + + + + +## [v0.17.39](https://github.com/niko0xdev/gqlgen/compare/v0.17.38...v0.17.39) - 2023-10-05 +- eed94e8c release v0.17.39 + +
a863d645 Add [@interfaceObject](https://github.com/interfaceObject) and [@composeDirective](https://github.com/composeDirective) at Federation 2 directive lists. (#2821) + +This commit just adding those directives into the list. + +
+ +
3ff523ba Bump postcss from 8.4.24 to 8.4.31 in /integration (#2819) + +Bumps [postcss](https://github.com/postcss/postcss) from 8.4.24 to 8.4.31. +- [Release notes](https://github.com/postcss/postcss/releases) +- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md) +- [Commits](https://github.com/postcss/postcss/compare/8.4.24...8.4.31) + +--- +updated-dependencies: +- dependency-name: postcss + dependency-type: indirect +... + +
+ +
59258642 Adding duration scalar conforming to ISO8601 standard (#2800) + +* Adding duration scalar + +* simple Duration scalar docs + +* using MarshalString, to add proper double quotes + +* adding deps and running go mod tidy on _examples + +* Re-organize imports + + +* Fix test now that imports are sorted + + +--------- + +
+ +
37f8e4eb Add ability to not fail when pong is not received. (#2815) + +I also changed how the read deadline set works a little, the reason for +this is that the protocol allows for pong to be sent without a ping. + +So setting a read deadline on receiving pong isn't great. Instead we +should always set the read deadline on sending ping. Though to do this +we need to know whether we have received a pong or not. Because if we +set the read deadline when the previous ping still hasn't received the +pong. Then it will never hit the deadline. + +
+ +
89ac736f Store parsed Schema on ExecutableSchema rather than use global variable (#2811) + +* codegen: executableSchema schema configurable + +* feat + +* feat + +* codegen: add schema property on Config and executableSchema + +* fix: fmt + +* regenerate + + +--------- + +
+ +
919aded6 Add a pong only keep alive for the new protcol (#2814) + +The protocol allows for this and this eliminates the potential for +over-agressive triggers of the read deadline set for using the ping/pong +flow. + +https://github.com/enisdenjo/graphql-ws/blob/50d5a512d0d7252d41c079e6716b884a191b1ddc/PROTOCOL.md#pong + +
+ +- 001c296a Update auto-generated files with latest results. (#2813) + +
f6fa3aae Consider go type name when autobinding (#2812) + +Currently, generated schema type names are normalized, for instance - SomeTYPE in the schema will be generated as SomeType in the model. + +When autobinding, however, we only consider the schema type name when searching for it in the relevant package(s), +thus type names that differ post normalizations aren't auto-bound properly and are instead re-generated. + +This commit suggests a fix where we'd try to autobind for both the schema type name (first, to maintain back compat), or the go type name if the former isn't found. + +
+ +
4e8d8c70 Feature: Support Apollo Federation Auth Directives (#2809) + +* local version working + +* gofmt + +* tabs + +
+ +- 66709d89 feat: update getting-started CreateTodo mutationResolver (#2810) + +
2c9f9c5f fix: CodeGen for omit_slice_element_pointers and GetMany Entity Resolvers (#2802) + +* remove ! from reps definition + +* adding tests + +* fixing tests + +* adding documentation + +* addressing lint + +* commit after go gonerate + +* gofmt + + +--------- + +
+ +
3e2393f3 add close flag into wsConnection to avoid duplicate calls of CloseFunc (#2803) + +* add close flag into wsConnection to avoid duplicate calls of CloseFunc + +* add test + +* Fix linter error + +
+ +
af4d3943 Allow WebsocketInitFunc to add payload to Ack (#4) (#2791) + +* Allow WebsocketInitFunc to add payload to Ack + +The connection ACK message in the protocol for both +graphql-ws and graphql-transport-ws allows for a payload in the +connection ack message. + +We really wanted to use this to establish better telemetry in our use of +websockets in graphql. + +* Fix lint error in test + +* Switch argument ordering. + +--------- + +
+ +- f3b86033 v0.17.38 postrelease bump + + + + + + +## [v0.17.38](https://github.com/niko0xdev/gqlgen/compare/v0.17.37...v0.17.38) - 2023-09-19 +- d9077fac release v0.17.38 + +- 5f452ce2 Update gqlparser to 2.5.10 (#2798) + +- c89860bd refactor: return `null` instead of zero value uuid (#2794) + +- 625ca2e5 Make it possible to pass UI headers (#2793) + +- fceb3311 Fix rand int docs link in Getting Started (#2789) + +- f01d5805 Add new changelog (#2787) + +
9930e574 Ability to use forceGenerate and extraFields together (#2788) + +* Ability to user forceGenerate and extraFields together + +* Some docs for forceGenerate added + +--------- + +
+ +- f90ac05e v0.17.37 postrelease bump + + + + + + +## [v0.17.37](https://github.com/niko0xdev/gqlgen/compare/v0.17.36...v0.17.37) - 2023-09-08 +- ccae370e release v0.17.37 + +- 6505f8be Update gqlparser (#2785) + +
153ec470 add uuid type (#2751) (closes #2749) + +* add uuid type + +* add uuid example + +* add uuid scalar doc + +* strconv.Quote + +* Apply suggestions from code review + +* fix + + + +--------- + +
+ +
fa471180 ForceGenerate parameter to [@goModel](https://github.com/goModel) added. (#2780) + +* forceGenerate to docs added + +--------- + +
+ +
11bb9b18 codegen: add support for `go_build_tags` option in gqlgen.yaml (#2784) + +* codegen: support go_build_tags option in gqlgen.yaml + +* chore: added test + +* docs/content: update config example + +* chore: more comment + +
+ +
bee47dcf fix flaky test TestSubscriptions (#2779) + +* fix flaky test TestSubscriptions + +* update other copy of the test + +
+ +- a41f4daa docs: short-lived loader (#2778) + +- cc4e0ba2 ensure HasOperationContext checks for nil (#2776) + +
a1ca2204 fix typo in TESTING.md server path (#2774) + +following TESTING.md instructions, I got an error: +"stat ./server/server.go: no such file or directory" + +server.go path is: integration/server/cmd/integration/server.go + +
+ +
1cde8c3f return internal types in schema introspection (#2773) + +according to graphql spec: +``` +types: return the set of all named types contained within this schema. +Any named type which can be found through a field of any introspection type must be included in this set. +``` +source: https://github.com/graphql/graphql-spec/blob/main/spec/Section%204%20--%20Introspection.md#the-__schema-type + +some clients libs (like HotChocolate for C#) depends on this behavior. + +
+ +- 065aea3e Fix gqlgen truncates tag value with colon (#2759) + +- d6270e4f Update subsciptions documentation to correctly close channel (#2753) + +- 2d8673a6 Add Model references to Interface (#2738) + +- 790d7a75 Allow GraphiQL headers to be set when creating the playground handler (#2740) (closes #2739) + +- 0eb95dc4 v0.17.36 postrelease bump + + + + + + +## [v0.17.36](https://github.com/niko0xdev/gqlgen/compare/v0.17.35...v0.17.36) - 2023-07-27 +- bd6cfd31 release v0.17.36 + +
60ec0d86 Fix plugin template resolution (#2733) (closes #2262) + +- According to the documentation comment for [templates.Options], if the + `Template` and `TemplateFS` fields are empty, it `Render` should find + the `.gotpl` files from the calling plugin. However, it looks like + helper function. This results in broken behavior in consumers such as + [infiotinc/gqlgenc](https://github.com/infiotinc/gqlgenc) when they + use the latest version of `gqlgen` as instead of finding the template + from the plugin, the test template from this package is used which + outputs only: `this is my test package`. +- The cause for this is that `runtime.Caller` was still only skipping + one stack level which means that it was finding the `Render` function + instead of its caller. + +
+ +- 76d444c1 Make models configurable via template (#2730) + +- abe3ffde Don't set the package variable for the new Resolver Template (#2725) + +
febf9566 Make the resolver implementation configurable via a new template resolver.gotpl (#2720) + +* Make an optional resolver.gotpl ResolverTemplate to implement a custom resolver + +* Add test + +* Add documetation for the new resolver option + +* Change the tab to spaces + +* remove unecessary test assertion :/ + +
+ +
bda30260 Fixed Data Loader docs (#2723) + +Also updated to v7 + +
+ +
16c9eb64 Fix docs (#2722) + +* docs: fix variable names in dataloader sample + +* fix: request-scoped middleware + +
+ +
b233a01b docs: update dataloader docs (#2719) + +* docs: update example + +* docs: update example + +* fix: import + +
+ +- cccc7389 Added go mod tidy to quick start guide (#2718) (closes #2717, #2651, #2641, #2614, #2576) + +- 9adc7b81 Update gqlparser to v2.5.8 (#2716) + +- b442fbf4 Post v0.17.35 changelog update + +- 57c12199 v0.17.35 postrelease bump + + + + + + +## [v0.17.35](https://github.com/niko0xdev/gqlgen/compare/v0.17.34...v0.17.35) - 2023-07-15 +- 05006bf1 release v0.17.35 + +- d95d614f Update gqlparser to v2.5.7 (#2714) + +- 8c378e6b Updated GraphiQL playground 2.0.7 -> 3.0.1 and react 17 -> 18 (#2713) + +
7880739d Add op ctx safety for apollo tracing (#2709) + +* Add automated tests for both tracing and tracer to simulate a client disconnect +* Check for existence of operation context before proceeding to avoid panic + +
+ +- 6ed9337b fix function name in comment (#2707) + +- 2cfb9f98 Fix apollo integrity hash (#2706) + +- 470fca87 Update gqlparser again (#2697) + +- 280441b1 Update changelog + +- 5bc36e14 v0.17.34 postrelease bump + + + + + + +## [v0.17.34](https://github.com/niko0xdev/gqlgen/compare/v0.17.33...v0.17.34) - 2023-06-23 +- 5a705857 release v0.17.34 + +
1a9dbadd Use "No longer supported" as the default deprecationReason for deprecations without a reason specified (#2692) + +* fix: use "No longer supported" as the default deprecationReason for deprecated fields with no reason specified + +* test: add integration tests to ensure deprecated fields with no reason set get the default reason defined in the spec `No longer supported` + +
+ +- 640f3836 Update gqlparser dependency (#2694) + +- 5ac9fe59 Added flag to omit interface checks (#2689) + +
abc3c627 feat: always use latest apollo sandbox (#2686) + +* feat: removeDuplicateTags() validates tags and panic with meaningful error message + +* Instead of pinning on _latest without subresource integrity check, update both url and integrity to latest + +* Update graphql/playground/apollo_sandbox_playground.go + +--------- + +
+ +
3b295bb4 added GoInitialismsConfig which overrides the initialisms to be regarded (#2683) + +* added GoInitialismsConfig which overrides the initialisms to be regarded + +* typo + +* adjusted examples and documentation + +* removed test with side-effects, adjustend yaml indentations, changed example entry "ID" to "CC" (again? I though I already did that) + +* comply with linter + +
+ +- ee6add4b Refactor TypeIdentifier to avoid circular imports (#2682) + +- 44376e52 fix subscription example in documentation (#2677) + +
d5080828 Reworked integration testing using vitest (#2675) + +* Reworked integration using vitest +Added SSE client testing +Fixed SSE Transport parse errors not being sent as event-stream + +* Added defer testing using urql + +* Cleanup unnecessary dependencies + +
+ +
d16f498f fix: issue with extraFields being thrown away (#2674) + +* fix: issue with extraFields being thrown away + +* Go fumpt on file + + +--------- + +
+ +- 71d16aa0 v0.17.33 postrelease bump + + + + + + +## [v0.17.33](https://github.com/niko0xdev/gqlgen/compare/v0.17.32...v0.17.33) - 2023-06-13 +- a1e34ca0 release v0.17.33 + +
790a72c1 issue-1372: add custom decode func (#2666) + +* issue-1372: add custom decode func + +* issue-1372: add custom decode method + +* issue-1372: fix lint + +* issue-1372: add custom decode func + +* issue-1372: add custom decode method + +* issue-1372: fix lint + +* issue-1372: extend functionality by setting up the whole decode config instead of one nested field + +* issue-1372: rollback generated.go file + +* issue-1372: fix lint + +
+ +
c63c60eb Update all modules (#2667) + +* Update all modules + + +* Add gqlparser v2.5.3 + + +--------- + +
+ +
4a78eb0c minor cleaning: fix some stricter lint rule warnings (#2665) + +* Add Changelog notes + + +* Some spring cleaning + + +* Update golangci-lint to latest + + +--------- + +
+ +- 1e925f7e v0.17.32 postrelease bump + + + + + + +## [v0.17.32](https://github.com/niko0xdev/gqlgen/compare/v0.17.31...v0.17.32) - 2023-06-06 +- 3a81a78b release v0.17.32 + +- dbb61174 Added unit tests for defer (#2657) + +
5c19c841 Addressing few issues in defer feature (#2656) + +And fixed hasNext to only appear in the payload when there is deferred usage + +* Regenerate + +* Use go 1.18 compatible atomic operations + +* Regenerate + +
+ +
8e295024 Update extra fields type definition and plus docs about the feature (#2655) + +* Update extra fields type definition and plus docs about the feature + +* Update docs + +
+ +
adf5da27 Make usage of omitempty tag optional (#2649) + +* Make usage of omitempty tag optional + +* adding probably good enough test + +* some kinda docs + +* lintersssssssssssssssssssssssssssss + +* removing unnecessary fields from config + +
+ +- 7ab33176 Extra fields (#2638) + +
22deb8bd allow binding a GraphQL `Any` field to a struct method returning `*any` (#2644) + +* allow binding GQL `Any` field to struct method returning `*any` + +* add singlefile tests for binding to `*any` case + +* add followschema tests for binding to `*any` case + +* make ptr_to_any binding tests follow binding conventions better + +
+ +
c313bf3d `[@defer](https://github.com/defer)` initial support (#2642) + +* support returning errors with deferred fragments. + + +* update integration tests. + +* fix gotpl indent and pass the correct context to deferred .Dispatch(). + +* Added hasNext in the tests + +* Added back root_.gotpl + +* Regenerate + +* Regenerate recursively + +* Updated schema-expected.graphql + + +* Fixed starwars_test.go + +* Cleanup + +* Add graphql response hasnext omitempty and update tests to match + + +--------- + +
+ +
4d945da2 feat(federation): update Apollo Federation v2 definitions (#2635) + +* feat(federation): update Apollo Federation v2 definitions + +Fix Apollo Federation v2 directive definitions: +* `_FieldSet` was renamed `FieldSet` + + +* regenerate examples + +
+ +- 9796f91d Generate entity resolvers for interfaces with [@key](https://github.com/key) defined (#2634) + +
33fdd1b5 fix enum capitalization (#2630) + +* fix enum capitalization + +* apply suggestion: adding comment + +
+ +
82a110ce Fix uint32 unmarshal (#2631) + +The string unmarshal for uint32 used ParseInt instead of ParseUint, +which would parse the wrong range of valid numbers. + +
+ +- e62a0277 Add Changelog entries for v0.17.31 + +- f707aa8d v0.17.31 postrelease bump + + + + + + +## [v0.17.31](https://github.com/niko0xdev/gqlgen/compare/v0.17.30...v0.17.31) - 2023-05-05 +- 37b26207 release v0.17.31 + +- 4016b2bd fix (#2628) + +- 5a81c3e3 Remove other && + +- fde269c0 Remove extraneous run + +- 47a5b333 Avoid && in command for retry + +- 4d8f850b Add timeout minutes + +- c839b6c1 Bandaid for flaky websocket tests + +
395c362b New option to make comments on resolver optional (#2627) + +* remove 'foo' above resolver + +* regenerate after 6a3869707da1ffff7c196fcbcac44c92 + +* omit resolver template comment + +* re-generate + +
+ +- 239b97ee Omittable input fields (#2585) + +
2ad08fff Bugfix: add missing return statements in GRAPHQL and UrlEncodedForm transports. (#2625) + +Two transports (GRAPHQL and UrlEncodedForm) did not have return +statement at the end of `if err` block. Instead of returning +a 'could not cleanup body' error, we continued processing. + +User still got an error. But instead of early 'could not cleanup' +error, user gor 'Internal system error' which happened a few +lines after the if block. + +Tests are added. + +
+ +- a13eca12 update autogenerated gqlgen.yml with new options. (#2622) + +- f1f63b52 Post Release Changelog entry + +- 81f3469f v0.17.30 postrelease bump + + + + + + +## [v0.17.30](https://github.com/niko0xdev/gqlgen/compare/v0.17.29...v0.17.30) - 2023-04-20 +- 4754e2b3 release v0.17.30 + +
acd4b07f feat: gqlgen ver in generated file notice and entire file notice optional (#2617) + +* feat: gqlgen ver in filenotice optional + +This commit allows the user of gqlgen to configure whether or not the +version of gqlgen used to generate the files is included in the +filenotice/comment header for generated files. + +* feat: filenotice in generated files optional + +* chore: rename config var for omit gqlgen ver in file notice + +
+ +- 498ce3f3 Add Changelog entry + +- 024430a1 v0.17.29 postrelease bump + + + + + + +## [v0.17.29](https://github.com/niko0xdev/gqlgen/compare/v0.17.28...v0.17.29) - 2023-04-11 +- 325405ba release v0.17.29 + +
7bc1f626 Read gqlgen.yml from io.Reader. (#2607) + +* Update config.go + +Add ReadConfig + +* Add tests + +* Update config_test.go + +remove extra space to fix lint checks + +* Update config.go + +Need to return the config + +
+ +
50c2829c Transport for application/x-www-form-urlencoded content type (#2611) + +* Renamed 'form' transport to 'form_multipart'. + +There are multiple ways form data can be encoded. 'multipart' is +just one of them - there are also 'application/x-www-form-urlencoded' +(which will be added in next commit) and 'text/plain' encodings. + +Let each encoding have it's own form_xxxx file and tests. + +* Adds transport for application/x-www-form-urlencoded content type. + +This commit adds transport that handles form POST with content +type set to 'application/x-www-form-urlencoded'. + +Form body can be json, urlencoded parameters or plain text. + +Example: + +``` + curl -X POST 'http://server/query' -d '{name}' -H "Content-Type: application/x-www-form-urlencoded" +``` + +Enable it in your GQL server with: + +``` +srv.AddTransport(transport.UrlEncodedForm{}) +``` + +* golangci-lint: change ifElseChain to switch. + +No other changes but this rewrite to switch. + +
+ +
8b38c0e9 Add on-close handler for websockets. (#2612) + +* working without test + +* test + +
+ +
45488157 Transport for application/graphql contentType (#2592) + +* Adds application/graphql transport layer + +This commit adds 'application/graphql' transport. It is based +on POST metod and has only the 'query' part in it's body. + +See: https://graphql.org/learn/serving-over-http/#post-request and +it's comment about this content-type. + +An example of correct application/graphql query is: + +``` +curl 'http://host/graphql' -d '{time{now}}' -H "Content-Type: application/graphql" +``` + +Some clients prefix body with 'query=': + +``` +-d 'query={time{now}}' +``` + +Some clients html encode body payload: + +``` +-d 'query=%7Btime%7Bnow%7D%7D' +``` + +We cleanup both in cleanupBody() method. + +Tests are in http_graphql_test.go file. + +* Adds tests for GRAPHQL transport response headers. + +GRAPHQL transport (like GET, POST and MULTIPART transports) can +have specific response headers added. + +This commit adds tests for it and changes doRequest() method +so that we can set inbound Content-Type. Graphql transport +uses 'application/graphql' content-type and not 'application/json'. + +* Adds GRAPHQL transfer to the documentation. + +
+ +- 21054eba Cleanup only non-gqlgen packages when reloading all packages (#2598) + +- 1c6bf9bd v0.17.28 postrelease bump + + + + + + +## [v0.17.28](https://github.com/niko0xdev/gqlgen/compare/v0.17.27...v0.17.28) - 2023-04-03 +- f2b34655 release v0.17.28 + +- a1a6f231 Re-generate after #2599 (#2601) + +- 9a644c54 Fix 2546: Relax external for object (#2599) + +
db534792 EntityResolver input type fix (#2594) (closes #2326) + +* EntityResolver input type fix + +the entity resolver may be in a different package (usually `model`). +The fix is to pull the types.Type of the resolver input, and use +templates.CurrentImports.LookupType in order to render it correctly +(possibly adding another import) + +* entityResolver input type fix: update tests + +change testdata/entityresolver/gqlgen.yml to use a dedicated package for +the model (as in the default sample yml), and run go generate. + +before the input type fix, generation fails with errors like - +plugin/federation/testdata/entityresolver/generated/federation.go:338:17: + undeclared name: MultiHelloByNamesInput +plugin/federation/testdata/entityresolver/generated/federation.go:354:21: + undeclared name: MultiHelloMultipleRequiresByNamesInput +plugin/federation/testdata/entityresolver/generated/federation.go:362:17: + undeclared name: MultiHelloMultipleRequiresByNamesInput + +
+ +- 6da735ce feat: removeDuplicateTags() validates tags and panic with meaningful error message (#2597) + +
677d854a Allow setting headers in HTTP transports (#2590) + +Currently gqlgen sets Content-Type header to 'application/json'. There's +no easy way to change it or add additional headers. + +This commit adds struct variable ResponseHeaders that can hold any +headers you want to be returned with response. It is standard +`map[string][]string` variable. + +If user does not set this map, we default to the Content-Type +header with 'application/json' value - nothing will be changed +for existing users. + +Usage: + +as simple as: + +``` +headers := map[string][]string{ + "Content-Type": {"application/json; charset: utf8"}, + "Other-Header": {"dummy-post-header","another-value"}, +} + +h.AddTransport(transport.POST{ResponseHeaders: headers}) +``` + +Added tests in transport/headers_test.go. + +
+ +- 65ec8b5a Add Changelog entry for v0.17.27 + +- a3400ff4 v0.17.27 postrelease bump + + + + + + +## [v0.17.27](https://github.com/niko0xdev/gqlgen/compare/v0.17.26...v0.17.27) - 2023-03-20 +- 5bfcdd63 release v0.17.27 + +- aab9b968 Revert mstephano #2486 #2508 #2528 (#2587) + +
05500c9d POST transport: missing return and unnecessary logs (#2584) + +* Add missing return in HTTP POST transport + +* Remove HTTP POST transport logs + +
+ +
622039cb feat: support ApolloSandbox playground (#2581) + +* feat: support ApolloSandbox playground + +* add initialState to be same behavior as others + +* add docs link of configuration values + +
+ +- 0bbc7f8c Add omitempty to struct tags for nullable types (#2436) + +- acbae6f0 Update Changelog for v0.17.26 + +- fbfa16ea v0.17.26 postrelease bump + + + + + + +## [v0.17.26](https://github.com/niko0xdev/gqlgen/compare/v0.17.25...v0.17.26) - 2023-03-07 +- 8ad59302 release v0.17.26 + +
dcd75559 Revert issue 2470 (#2577) (closes #2471, #2523, #2541) + +This reverts commit 5cb6e3ecb07a292daa37f5ce8e5bcf364e1190af. + + +* misspell lint fix + +--------- + +
+ +- cac5f0f4 Post release version bump for examples + +- 9e9af41a Update Changelog + +- a8f647cb v0.17.25 postrelease bump + + + + + + +## [v0.17.25](https://github.com/niko0xdev/gqlgen/compare/v0.17.24...v0.17.25) - 2023-02-28 +- ea6a4e65 release v0.17.25 + +- 7e013e1d Freshen dependencies (#2571) + +
c5dfc26b Update lru package (#2570) + +* update + +* Adjust example go mod and go sum + + +--------- + +
+ +- ff19a5a5 fix typo in dataloaders docs example (#2562) + +
a9e42e16 Move minimum supported version to Go 1.18 (#2556) + +* Move minimum supported version to Go 1.18 + + +* Update matrix to use strings instead of floats + + +* Change test to match Go order + + +* lint on Go 1.19 and Go 1.20 + + +* Attempt to limit github action concurrency + + +--------- + +
+ +
01d46b85 Bump undici from 5.14.0 to 5.19.1 in /integration (#2557) + +Bumps [undici](https://github.com/nodejs/undici) from 5.14.0 to 5.19.1. +- [Release notes](https://github.com/nodejs/undici/releases) +- [Commits](https://github.com/nodejs/undici/compare/v5.14.0...v5.19.1) + +--- +updated-dependencies: +- dependency-name: undici + dependency-type: indirect +... + +
+ +- e36095f5 Updated the documentation on using the plugins (#2553) + +
cf1607ad Add ability to customize resolvergen behavior using additional plugins (#2516) + +* Add ability to customize resolvergen behavior using additional plugins + +* Add field.GoResultName() + +--------- + +
+ +
356f4f90 prepend goTag directive on struct tags and omit overridden duplicate struct tags per #2514 (#2533) + +* Change to prepend goTag directive + + +* Fix test for field_hooks_are_applied to prepend + + +--------- + +
+ +
5b85e93e fix #2524 basic alias Byte was not binded properly (#2528) + +* add tests for defined types as []byte and []rune + +
+ +- 49ac94fa fix introspection doc typo (#2529) + +- e6114a2c remove extra call to packages.Load fix #2505 (#2519) + +- 9d22d98c Changelog for v0.17.24 + +- 2d048b38 v0.17.24 postrelease bump + + + + + + +## [v0.17.24](https://github.com/niko0xdev/gqlgen/compare/v0.17.23...v0.17.24) - 2023-01-23 +- 77c63865 release v0.17.24 + + + + + + +## [v0.17.23](https://github.com/niko0xdev/gqlgen/compare/v0.17.22...v0.17.23) - 2023-01-23 +- 9573b595 release v0.17.23 + +- 866187fd missed a closing parenthesis (#2513) + +- ec3b4711 fix #2485 for some types requiring a scalar (#2508) + +
11c3a4da Enable Subscription Resolver to return websocket error message (#2506) + +* Enanble Subscription Resolver to return websocket error message + +* add PR link + +* lint + +* fmt and regenerate + +
+ +
2bd7cfef Add omit_complexity config option for issue #2502 (#2504) + +* Add omit_complexity config option to skip generation of ComplexityRoot struct content and Complexity function + +* fix lint error + +
+ +
867b61a5 fix #2485 Defined type from a basic type should not need scalar (#2486) + +* following review + +* better way to compare basic type + +
+ +- 43c9a1d2 fix: gin sample code error in v0.17.22 (#2503) + +
f5764a83 Bump json5 from 2.2.1 to 2.2.3 in /integration (#2500) + +Bumps [json5](https://github.com/json5/json5) from 2.2.1 to 2.2.3. +- [Release notes](https://github.com/json5/json5/releases) +- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md) +- [Commits](https://github.com/json5/json5/compare/v2.2.1...v2.2.3) + +--- +updated-dependencies: +- dependency-name: json5 + dependency-type: indirect +... + +
+ +
32bfdfb7 Bump jsonwebtoken and [@graphql](https://github.com/graphql)-tools/prisma-loader in /integration (#2501) + +Updates `jsonwebtoken` from 8.5.1 to 9.0.0 +- [Release notes](https://github.com/auth0/node-jsonwebtoken/releases) +- [Changelog](https://github.com/auth0/node-jsonwebtoken/blob/master/CHANGELOG.md) +- [Commits](https://github.com/auth0/node-jsonwebtoken/compare/v8.5.1...v9.0.0) + +- [Release notes](https://github.com/ardatan/graphql-tools/releases) +- [Changelog](https://github.com/ardatan/graphql-tools/blob/master/packages/loaders/prisma/CHANGELOG.md) + +--- +updated-dependencies: +- dependency-name: jsonwebtoken + dependency-type: indirect + dependency-type: indirect +... + +
+ +
f0a090d0 Add Server-Sent Events transport (#2498) + +* Add new transport via server-sent events + +* Add graphql-sse option to chat example + +* Add SSE transport to documentation + +* Reorder imports and handle test err to fix golangci-lint remarks + +
+ +
b09608d2 fix misspelling and format code (#2497) + +* fix: misspelling dont + +* fix: sort import order + +* fix example indent + +
+ +- e8d61150 plugin/resolvergen: respect named return values (#2488) + +
c2b8eabb feat: support Altair playground (#2437) + +* feat: support Altair playground + +* fix method params + +
+ +
5cb6e3ec Fix issue #2470: Incorrect response when errors occurred (#2471) + +* go generate ./... + +* regenerate examples + +
+ +- 3008f4e2 fix #2465 remote model with omitempty (#2468) + +- da43147f Export default modelgen hooks (#2467) + +- 6b8c6ee7 Fix #2457 update websocket example (#2461) + +- aaf1638b Update Release script to generate after version bumps + +- 95437035 Increment version, regenerate, and make changelog + +- 99e036be v0.17.22 postrelease bump + + + + + + +## [v0.17.22](https://github.com/niko0xdev/gqlgen/compare/v0.17.21...v0.17.22) - 2022-12-08 +- d6579466 release v0.17.22 + +- 9a292299 graphql.Error is not deprecated anymore (#2455) + +
a44685b2 Ability to return multiple errors from resolvers raise than add it to stack. (#2454) + +* Remove DO NOT EDIT + +Sometimes vscode warn about this while editing resolvers code. +Finally the resolver's code is editable and generated at the same time. + +* Ability to return multiple errors from resolver. + +* Multiple errors return example + +* Fix missing import + +* reformat + +* gofmt + +* go generate ./... + +* go generate ./... + +* Regenerate + + +* remove trailing period + +
+ +
db1e3b81 Implicit external check (#2449) + +* Prevent entity resolver generation for stub types. +In Federation 2 key fields are implicitly external + +* Add more comments to "isResolvable" + +* Check that no resolvers are set for stub "Hello" + +* Run generate with go 1.16 + +* Simplify implicit external check + +* Add stricter federation version check. +Update comment on expected behavior of the resolvable argument. +Add comment to documentation about external directive. + +* Preallocate keyFields slice + +* Add non stub type to federation v2 test + +* Do not append to preallocated slice + +* Add test coverage for multiple fields in key + +* Fix typo in comment + +
+ +- 5065163c Re-generate and update release checklist to regenerate for new version + +- 5cfc22de Add v0.17.21 Release notes + +- 5d39046d v0.17.21 postrelease bump + + + + + + +## [v0.17.21](https://github.com/niko0xdev/gqlgen/compare/v0.17.20...v0.17.21) - 2022-12-03 +- 9deb8381 release v0.17.21 + +
5c083c79 use goField directive for getters generation (#2447) + +* consider goField directive for getters generation + +* Re-generate to pass linting + +
+ +
463d2134 fix: safe http error response (#2438) + +* safe http error when parsing body + +* fix tests + +* fix linting + +* fix linting + +* Dispatch decoding errors so hook can present them + + +* Revert test expectation to original + +
+ +
86c144fc Bump decode-uri-component from 0.2.0 to 0.2.2 in /integration (#2445) + +Bumps [decode-uri-component](https://github.com/SamVerschueren/decode-uri-component) from 0.2.0 to 0.2.2. +- [Release notes](https://github.com/SamVerschueren/decode-uri-component/releases) +- [Commits](https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.2) + +--- +updated-dependencies: +- dependency-name: decode-uri-component + dependency-type: indirect +... + +
+ +
f28ffccd Bump minimatch from 3.0.4 to 3.1.2 in /integration (#2435) + +Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.1.2. +- [Release notes](https://github.com/isaacs/minimatch/releases) +- [Commits](https://github.com/isaacs/minimatch/compare/v3.0.4...v3.1.2) + +--- +updated-dependencies: +- dependency-name: minimatch + dependency-type: indirect +... + +
+ +- e3af4459 docs : embedding schema in generated code (#2351) + +
efb31b54 Check if go.mod exists while init (#2432) + +* Add check go.mod first to prevent cascade errors in "init" directive + +* Fix formatting + +* Fix formatting with gofmt + + + +This reverts commit c23d183d9da4e33993e600beefcccd1fc4ec6264. + + +* Adjust go.mod file to look in parent directories as well + +
+ +
89e91da1 Add resolver commit (#2434) + +* Add resolver commit + +* Add version to comment and re-generate + +
+ +- 3087cf3a Fix for #1274. (#2411) + +
906c0dee optional return pointers in unmarshalInput (#2397) + +* optional return pointers in unmarshalInput + +* add docs for return_pointers_in_unmarshalinput + +
+ +
a9d06036 Add json.Number support to UnmarshalString (#2396) + +* Add json.Number support to UnmarshalString + +* Add UnmarshalString tests + +* Remove trailing zeros when calling UnmarshalString with float64 + +
+ +
daa44079 Update README.md (#2391) + +fix: execute gqlgen generate command error. eg: systems failed: unable to build object definition: unable to find type: github.com/niko0xdev/gqlgen/graphql/introspection.InputValue. need import github.com/niko0xdev/gqlgen/graphql/introspection . + +
+ +
419dd96c Bump got and [@graphql](https://github.com/graphql)-codegen/cli in /integration (#2389) + +Removes `got` + +- [Release notes](https://github.com/dotansimha/graphql-code-generator/releases) +- [Changelog](https://github.com/dotansimha/graphql-code-generator/blob/master/packages/graphql-codegen-cli/CHANGELOG.md) + +--- +updated-dependencies: +- dependency-name: got + dependency-type: indirect + dependency-type: direct:development +... + +
+ +- b1ca215a Add global typescript (#2390) + +
265888c6 Bump jsdom and jest in /integration (#2388) + +Bumps [jsdom](https://github.com/jsdom/jsdom) and [jest](https://github.com/facebook/jest/tree/HEAD/packages/jest). These dependencies needed to be updated together. + +Removes `jsdom` + +Updates `jest` from 24.9.0 to 29.0.3 +- [Release notes](https://github.com/facebook/jest/releases) +- [Changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md) +- [Commits](https://github.com/facebook/jest/commits/v29.0.3/packages/jest) + +--- +updated-dependencies: +- dependency-name: jsdom + dependency-type: indirect +- dependency-name: jest + dependency-type: direct:development +... + +
+ +
56f6db04 Update module mitchellh/mapstructure to 1.5.0 (#2111) + +* Update mitchellh/mapstructure + + +* Avoid double pointer + +
+ +- ea9590a4 update changelog for v0.17.20 + +- 4c06e6c6 v0.17.20 postrelease bump + + + + + + +## [v0.17.20](https://github.com/niko0xdev/gqlgen/compare/v0.17.19...v0.17.20) - 2022-09-19 +- 0e4cbd10 release v0.17.20 + +
12ae8ffa Update go-colorable and x/tools. (#2382) + +This picks up a new 2022 version of golang.org/x/sys which is caused by +https://github.com/golang/go/issues/49219 and is needed to fix building +using Go 1.18 on aarch64-darwin. + +
+ +
68136ffb Update diagram in documentation (#2381) + +The diagram wasn't rendering properly in Go docs, which was a shame because it's a great diagram. This PR fixes that by indenting it another space. + +
+ +- d29d098f fix field merging behavior for fragments on interfaces (#2380) + +- 6bb31862 Update changelog for v0.17.19 + +- bb7fbc0f v0.17.19 postrelease bump + + + + + + +## [v0.17.19](https://github.com/niko0xdev/gqlgen/compare/v0.17.18...v0.17.19) - 2022-09-15 +- 588c6ac1 release v0.17.19 + +- c6713170 v0.17.18 postrelease bump + + + + + + +## [v0.17.18](https://github.com/niko0xdev/gqlgen/compare/v0.17.17...v0.17.18) - 2022-09-15 +- 1d41c808 release v0.17.18 + +- 4dbe2e47 update graphiql to 2.0.7 (#2375) + +
b7cc094a testfix: make apollo federated tracer test more consistent (#2374) + +* Update tracing_test.go + +* add missing imports + +
+ +- d096fb9b Update directives (#2371) + +- 1acfea2f Add v0.17.17 changelog + +- c273adc8 v0.17.17 postrelease bump + + + + + + +## [v0.17.17](https://github.com/niko0xdev/gqlgen/compare/v0.17.16...v0.17.17) - 2022-09-13 +- d50bc5ac release v0.17.17 + +
462025b4 nil check error before type assertion follow-up from #2341 (#2368) + +* Improve errcode.Set safety + +
+ +
59493aff fix: apollo federation tracer was race prone (#2366) + +The tracer was using a global state across different goroutines +Added req headers to operation context to allow it to be fetched in InterceptOperation + +
+ +- fc018556 Update gqlparser to v2.5.1 (#2363) + +- 56574a14 feat: make Playground HTML content compatible with UTF-8 charset (#2355) + +
182b039d Add `subscriptions.md` recipe to docs (#2346) + +* Add `subscriptions.md` recipe to docs + +* Fix wrong request type + +
+ +- b66fff16 Add omit_getters config option (#2348) + +- 2ba8040f Update changelog for v0.17.16 + +- 8bef8c80 v0.17.16 postrelease bump + + + + + + +## [v0.17.16](https://github.com/niko0xdev/gqlgen/compare/v0.17.15...v0.17.16) - 2022-08-26 +- 9593cead release v0.17.16 + +- 2390af2d Update gqlparser to v2.5.0 (#2341) + +- 2a87fe06 feat: update Graphiql to version 2 (#2340) + +
32e2ccd3 Update yaml to v3 (#2339) + +* update yaml to v3 + +* add missing go entry for yaml on _example + +* add missing sum file + +
+ +- 7949117a v0.17.15 postrelease bump + + + + + + +## [v0.17.15](https://github.com/niko0xdev/gqlgen/compare/v0.17.14...v0.17.15) - 2022-08-23 +- 23cc7492 release v0.17.15 + +- 577a570c Markdown formatting fixes (#2335) + +
2b584011 Fix Interface Slice Getter Generation (#2332) + +* Make modelgen test fail if generated doesn't build +Added returning list of interface to modelgen test schema + +* Implement slice copying when returning interface slices + +* Re-generate to satisfy the linter + +
+ +
aee57b4c Correct boolean logic (#2330) + +Correcting boolean logic issue + +
+ +- da0610e1 Update changelog for v0.17.14 + +- ddcb524e v0.17.14 postrelease bump + + + + + + +## [v0.17.14](https://github.com/niko0xdev/gqlgen/compare/v0.17.13...v0.17.14) - 2022-08-18 +- 581bf6eb release v0.17.14 + +- d3384377 Update gqlparser + +- c2d02d35 More descriptive `not implemented` stubs (#2328) (closes #2327) + +
9f919d2c Avoid GraphQL to Go Naming Collision with "ToGoModelName" func (#2322) (closes #2321) + +* using ReplaceAllStringLiteral + +* fixing wordInfo template test + +* bumping linter timeout to 5m + +* comment cleanup + +* some cleanup, adding "ToGoPrivateModelName" func + +* adding "ToGoPrivateModelName" func + +* refactoring word walker impl and tests + +* hopefully making linter happy + +
+ +- 2304c104 Include docstrings on interface getters (#2317) + +- f5d60326 Leverage (*Imports).LookupType when generating interface field getters (#2315) + +
242c3ba2 Generate getters for interface fields (#2314) + +* Generate getters for interface fields + +* Changes to make models_test.go pass + +* Use text/template, not html/template + +* Re-run go generate ./... + +* gofmt a few files that were failing lint checks + +* Another gofmt straggler + +* Try making the "generated" match the exact whitespace github is disliking + +
+ +- 0d91c893 Add hackernews graphql api tutorial to other resources (#2305) + +- c2526ba5 Update gqlparser to v2.4.7 (#2300) + +- f283124d #2298: fix gqlgen extracting module name from comment line (#2299) + +
779d7cdd Add support for KeepAlive message in websocket client (#2293) + +* Add support for KeepAlive message in websocket client + +* rewrite if-else to switch statement + +
+ +- 5a37d1dc v0.17.13 postrelease bump + + + + + + +## [v0.17.13](https://github.com/niko0xdev/gqlgen/compare/v0.17.12...v0.17.13) - 2022-07-15 +- e82b6bf1 release v0.17.13 + +
f0e9047d Hide dependencies in `tools.go` from importers (#2287) + +Projects that use `go mod vendor` will vendor `github.com/matryer/moq` +despite it not being required at runtime. + +Moving `tools.go` to `internal` hides this import from downstream +users and avoids `github.com/matryer/moq` being vendored. + +`go generate` of the mocks still works as expected. + +The assumption behind the import test broke, so I've pointed it at a +different path that has no Go code. This seems to match the intent +behind the original test for the `internal/code/..` path. + +
+ +- 6310e6a7 support named interface to Field.CallArgs (#2289) + +
30493696 fix: return the original error (#2288) + +* fix: return the original error + +close https://github.com/niko0xdev/gqlgen/issues/2286 + +* Update error.go + +
+ +- fb13091d updated WebSocker InitFunc recipe (#2275) + +- 770c09fb Update changelog for v0.17.12 + +- b4c186a7 v0.17.12 postrelease bump + + + + + + +## [v0.17.12](https://github.com/niko0xdev/gqlgen/compare/v0.17.11...v0.17.12) - 2022-07-04 +- 94c02b0d release v0.17.12 + +- 7eb8ba93 Fix CreateTodo (#2256) + +
0b0e5ce4 Replace use of strings.Title with cases.Title (#2268) + +* github: Test more go versions + +* github: Fix ci tests + +* github: Increase verbosity, sleep + +* github: Drop bash + +* github: Test go 1.18 and newer node verisons + +* github: Pull out node 16 for now + +* github: Only lint 1.16 for now + +* cases: Use cases.Title over strings.Title which is deprecated + +* gqlgen: Remove use of deprecated strings.Title + +
+ +- 0c11e5fd parse at beginning of do function (#2269) + +- edb1c585 Update Changelog for v0.17.11 + +- 5e6b52fd v0.17.11 postrelease bump + + + + + + +## [v0.17.11](https://github.com/niko0xdev/gqlgen/compare/v0.17.10...v0.17.11) - 2022-07-03 +- ea294c4e release v0.17.11 + +- 8ebf75c1 Update gqlparser (#2270) + +
b8497f52 github: Fix CI pipelines (#2266) + +* github: Test more go versions + +* github: Fix ci tests + +* github: Increase verbosity, sleep + +* github: Drop bash + +* github: Test go 1.18 and newer node verisons + +* github: Pull out node 16 for now + +* github: Only lint 1.16 for now + +
+ +
c287a7b0 codegen: fix resolvers execution order (#2267) + +* codegen: fix run order of resolver + + +* fix: update code generate + +* fix: update stub, root to generate resolver for input + +* fix: added unit-test for input field order + +* fix: added test for singlefile + +
+ +
8481457f gqlgen: Add resolver comment generation and preservation (#2263) + +* gqlgen: Add resolver comment generation and preservation + +* gqlgen: Regenerate + +
+ +- 532d46af Make uploads content seekable (#2247) + +
34bbc450 Use the go:embed API to lookup templates (#2262) + +* Switch the templates package internally to read from TemplateFS + +Users are expected to pass in the FS by using the embed API. + +* Update all usages of templates.Render to use the TemplateFS option + +* Fix unit tests + +* Fix linter error + +* Commit generated changes + +Doesn't look like anything has changed though. Maybe just a different +whitespace character. + +* Fix test + +
+ +
53ca207a Fix PR links in CHANGELOG.md (#2257) + +* fix "PR" regex in CHANGELOG-full-history.tpl.md + +* regenerate CHANGELOG.md + +
+ +
53ada82e Replace deprecated ioutil pkg with os & io (#2254) + +As of Go 1.16, the same functionality is now provided by package io or +package os, and those implementations should be preferred in new code. + +So replacing all usage of ioutil pkg with io & os. + +
+ +- a8f112e0 update changelog + +- 82fbbe41 v0.17.10 postrelease bump + + + + + + +## [v0.17.10](https://github.com/niko0xdev/gqlgen/compare/v0.17.9...v0.17.10) - 2022-06-13 +- 4ff9ea92 release v0.17.10 + +- cac4f404 update gqlparser (#2239) + +- d07ec12d Use exact capitalization from field names overridden in config (#2237) + +- 3a640782 fix: #2234 (#2235) Response.Errors in DispatchError function is not PresentedError + +
c355df9e fix #1876: Optional Any type should allow nil values (#2231) + +* Anonymous func that checks value of arg type interface for nil + +* Added unit test for `CallArgs()` + +* Fixed type of argument in unit test + +
+ +- 65e68108 Add config boolean for whether resolvers return pointers (#2175) + +- ddd825ef Only make cyclical struct fields pointers (#2174) + +- 5a87fe29 Update websocket.go (#2223) + +- e2edda5d Update dataloaders.MD (#2221) + +- 3de7d2cf fix: chat example frontend race condition (#2219) + +- 11f40572 Update Changelog + +- caca01fb v0.17.9 postrelease bump + + + + + + +## [v0.17.9](https://github.com/niko0xdev/gqlgen/compare/v0.17.8...v0.17.9) - 2022-05-26 +- 7f0611b2 release v0.17.9 + +- 738209b2 Update gqlparser (#2216) + +
6855b729 fix: prevent goroutine leak and CPU spinning at websocket transport (#2209) (closes #2168) + +* Added goroutine leak test for chat example + +* Improved chat example with proper concurrency + + +This reverts commit eef7bfaad1b524f9e2fc0c1150fdb321c276069e. + +* Improved subscription channel usage + +* Regenerated examples and codegen + +* Add support for subscription keepalives in websocket client + +* Update chat example test + +* if else chain to switch + + +* Revert "Add support for subscription keepalives in websocket client" + +This reverts commits 64b882c3c9901f25edc0684ce2a1f9b63443416b and 670cf22272b490005d46dc2bee1634de1cd06d68. + +* Fixed chat example race condition + +* Fixed chatroom#Messages type + +
+ +
5f5bfcb9 fix #2204 - don't try to embed builtin sources (#2214) + +* dont't try to embed builtins + +* add test + +* generated code + +* fix error message string + +
+ +- 8d9d3f12 Check only direct dependencies (#2205) + +- b262e40a v0.17.8 postrelease bump + + + + + + +## [v0.17.8](https://github.com/niko0xdev/gqlgen/compare/v0.17.7...v0.17.8) - 2022-05-25 +- 25367e0a release v0.17.8 + +- 5a56b69d Add security workflow with nancy (#2202) + +- 482f4ce0 Run CI tests on windows (#2199) + +- 656045d3 This works on Windows too! (#2197) + +- f6aeed60 Merge branch 'master' of github.com:niko0xdev/gqlgen + +- d91080be Update changelog + +- 752d2d7e v0.17.7 postrelease bump + + + + + + +## [v0.17.7](https://github.com/niko0xdev/gqlgen/compare/v0.17.6...v0.17.7) - 2022-05-24 +- 2b1dff1b release v0.17.7 + +- b2087f94 Update module dependencies (#2192) + +
8825ac46 Fix misprint (#2187) + +* Fix misprint + +* Fix misprint + +* Re-generate + +
+ +- 41daa5d8 fix #2190 - don't use backslash for "embed" paths on windows (#2191) + +- 0cce5544 Update Changelog + +- 26644541 v0.17.6 postrelease bump + + + + + + +## [v0.17.6](https://github.com/niko0xdev/gqlgen/compare/v0.17.5...v0.17.6) - 2022-05-23 +- 358d45dc release v0.17.6 + +- 7c95938c Improve operation error handling (#2184) + +- 2526f687 Correct identation (#2182) + +
f7bf453c Bump dset from 3.1.1 to 3.1.2 in /integration (#2176) + +Bumps [dset](https://github.com/lukeed/dset) from 3.1.1 to 3.1.2. +- [Release notes](https://github.com/lukeed/dset/releases) +- [Commits](https://github.com/lukeed/dset/compare/v3.1.1...v3.1.2) + +--- +updated-dependencies: +- dependency-name: dset + dependency-type: indirect +... + +
+ +
4cdf7026 Update getting-started.md (#2157) + +Fix getting-started missing fields resolver config + +
+ +- eef7bfaa fix: prevents goroutine leak at websocket transport (#2168) + +- b8ec51d8 go: update gqlparser to latest (#2149) + +- ec3e597e Fix docs bug in field collection (#2141) + +
f6b35231 Add argument to WebsocketErrorFunc (#2124) + +* Add argument to WebsocketErrorFunc + +to determine whether the error ocured on read or write to the websocket. + +* Wrap websocket error + +
+ +- 0f016df3 Fix invalid query parameter for playground subscription endpoint (#2148) + +
fb5751ab use "embed" in generated code (#2119) + +* use "embed" in generated code + +* don't use embed for builtins + +* working poc + +* handle no embeddable sources + +* fix dir + +* comment + +* add test for embedding + +* improve error handling + +
+ +
d38911f1 Allow absolute https://github.com/niko0xdev/gqlgens to the GraphQL playground (#2142) + +* Allow absolute URLs to the GraphQL playground + +* Add test for playground URLs + +* Close res.Body in playground test + +
+ +
3228f36f Update getting-started.md (#2140) + +* Update getting-started.md + +function rand.Int requires two parameters and returns two value in golang version 1.18.1. + +* Highlight the package used so people don't pick crypto/rand + +* Revert to original + +* Remove extra space + +
+ +
33fe0b9b Update package.json (#2138) + +I added `graphql-ws` because there is no graphql-ws in package.json + +
+ +
f8e837b8 Use MultipartReader to parse file uploads (#2135) + +Use a streaming MultipartReader to parse requests with file +uploads. The GraphQL multipart request specification guarantees +that the operations and map form fields will come first. + +There are two reasons motivating this change: + +- This allows for file uploads without specifying a specific + filename. +- This avoids unnecessary copies for requests with more than one + file. Go's ParseForm already copies the request's body into + memory or on disk. We were also doing this manually as a second + step. + +
+ +- 05bfc1fb Upddate Changelog + +- 62f694f0 v0.17.5 postrelease bump + + + + + + +## [v0.17.5](https://github.com/niko0xdev/gqlgen/compare/v0.17.4...v0.17.5) - 2022-04-29 +- fd97e74e release v0.17.5 + +
9250f9ac Feature: Add FTV1 Support via Handler (#2132) + +* initial support for ftv1 traces via handler + +* remove testing json extension + +* remove binary from commit and add to .gitignore + +* updating go.mod + +* updating examples go.sum + +* rerunning generate within the examples folder + +
+ +
fce3a11a feat: added graphql.UnmarshalInputFromContext (#2131) + +* feat: added graphql.UnmarshalInputFromContext + +* chore: run go generate for _examples + +* fix: apply suggestions from code review + + +* fix: update error cases + +* fix: fixed unit-test by update root_.gotpl + +* fix: apply suggestions from code review + +* fix: update graphql/input.go + +
+ +
6a24e881 update instructions to specify package of Role (#2130) + +Can't compile with the example unless I also include `model.` for Role. + +
+ +- ccfa245b Ignore protobuf files in coverage (#2133) + +- 0465dcb1 Update federation.md (#2129) + +- 8f0631dc Update Changelog + +- 41611560 v0.17.4 postrelease bump + + + + + + +## [v0.17.4](https://github.com/niko0xdev/gqlgen/compare/v0.17.3...v0.17.4) - 2022-04-25 +- d6de831a release v0.17.4 + +
2a2a3dcb Feature: Adds Federation 2 Support (#2115) + +* fed2 rough support + +* autodetection of fed2 + +* adding basic tests for changes + +* fixing docs + +* Update plugin/federation/federation.go + +* removing custom scalar since it was causing issues + +* fixing lint test + +* should fix for real this time + +* fixing test failures + +
+ +
77260e88 shorten some generated code (#2120) + +* shorten some generated code + +* generate examples + +
+ +
4da17e1c update modules except mapstructure (#2118) + +* Update modules + + +* Update modules except for mapstructure + + +* Try to update to v1.3.1 + +
+ +- cddbf02d Update Changelog file + +- 8f80f4ef v0.17.3 postrelease bump + + + + + + +## [v0.17.3](https://github.com/niko0xdev/gqlgen/compare/v0.17.2...v0.17.3) - 2022-04-20 +- 0bb262d1 release v0.17.3 + +
8d0bd22a Update gqlparser (#2109) + +* Update gqlparser + + +* Update tests to be NoError + +
+ +
ec0dea88 Fix the ability of websockets to get errors (#2097) + +Because DispatchOperation creates tempResponseContext, +which is passed into Exec, which is then used in _Subscription to +generate the next function. Inside the various subscription functions +when generating next the context was captured there. + +Which means later when the returned function from DispatchOperation is +called. The responseContext which accumulates the errors is the +tempResponseContext which we no longer have access to to read the errors +out of it. + +Instead add a context to next() so that it can be passed through and +accumulated the errors as expected. + +Added a unit test for this as well. + +
+ +
e3f04b42 Change the error message to be consumer targeted (#2096) + +* Change the error message to be slightly more clear + +* Rebase on updated origin/master. + +Fix the test to not be sensitive to array ordering. +Re-generate on master as there was a schema change. + +
+ +
5a497649 Fix websocket subscriptions to not double close. (#2095) + +We were closing at the end of the loop and also in the defer. + +
+ +- a15a9bfd Update test.yml to be valid + +
a1538928 Use Github API to update the docs (#2101) + +* Use Github API to update the docs + +Instead of a hard-coded version of the docs we want to realease, this +uses the Github API to get the last 20 versions and publish those. This +will allow any script invoking this to make sure to always have the +latest version of the docs + +* Reinstate set -e + +
+ +- 3bf437c2 Update golangci-lint (#2103) + +
12c6d0bf Fix misprint (#2102) + +* Fix misprint + +* Update websocket_graphql_transport_ws.go + +
+ +
9f5fad13 Bump minimist from 1.2.5 to 1.2.6 in /integration (#2085) + +Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6. +- [Release notes](https://github.com/substack/minimist/releases) +- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6) + +--- +updated-dependencies: +- dependency-name: minimist + dependency-type: indirect +... + +
+ +
035e1d6e Add AllowedMethods field to transport.Options (#2080) + +* Add AllowedMethods field to transport.Options + +to enable users to specify allowed HTTP methods. + +* Update graphql/handler/transport/options.go + +
+ +- f0fdb116 Add instructions for enabling autobinding (#2079) + +
12b0b385 Bump Playground version (#2078) + +* update playground + +* enables tabs + +* update shas + +
+ +
1324c3ff Merge pull request #2062 from a8m/childfield + +graphql: add FieldContext.Child field function and enable it in codegen + +
+ +- bf9caeae graphql: add FieldContext.ChildArgs field and enable it in codegen + +- 36fb3dc6 codegen: allow binding methods with optional variadic arguments (#2066) + +- fba5edd4 Update Changelog + +- 48b2b7e1 v0.17.2 postrelease bump + + + + + + +## [v0.17.2](https://github.com/niko0xdev/gqlgen/compare/v0.17.1...v0.17.2) - 2022-03-21 +- 1f04d38a release v0.17.2 + +- 87fc5f22 Fix #1961 for Go 1.18 (#2052) + +- f85d59d3 fixed modelgen test schema (#2032) + +- d873ff8b v0.17.1 postrelease bump + + + + + + +## [v0.17.1](https://github.com/niko0xdev/gqlgen/compare/v0.17.0...v0.17.1) - 2022-03-02 +- 5ea50aee release v0.17.1 + +- a493a423 Prepare for new release + +
9f520a28 Update golangci-lint and fix resource leak (#2024) + +* Fix golangci-lint in CI + +* Fix resource leak + +
+ +- 74baaa14 fixed model gen for multiple implemented type (#2021) + +- d31cf6be v0.17.0 postrelease bump + + + + + + +## [v0.17.0](https://github.com/niko0xdev/gqlgen/compare/v0.16.0...v0.17.0) - 2022-03-01 +- e4be5651 release v0.17.0 + +
082bbff6 Revert "Update quickstart (#1850)" (#2014) + +This reverts commit 0ab636144bfc875f86e4d9fd7a2686bc57d5050c. + +
+ +- a58411b8 Embed templates instead of inlining them (#2019) + +- 839b50df Test gqlgen generate in CI (#2017) + +- 00dc14ad Remove ambient imports (#2016) + +
45e192ea Clean up docs to clarify how to use a particular version (#2015) (closes #1851) + +This reverts commit 57a148f6d12572fe585ecfcafafbb7441dbf9cab. + +* Update getting-started.md + +* Update getting-started.md + +
+ +- 3a9413f7 Fix issue template + +
5236fb09 fix introspection for description to be nullable (#2008) + +* fixed introspection for description to be nullable + +* regenerated for integration + +* regenerated + +* fixed introspection package + +* regenerated + +
+ +
82fefdb5 support to generate model for intermediate interface (#1982) + +* support to generate model for intermediate interface + +* go generate ./... in example + +* fixed filepath generation + +
+ +
3ec83635 Bump ajv from 6.10.2 to 6.12.6 in /integration (#2007) + +Bumps [ajv](https://github.com/ajv-validator/ajv) from 6.10.2 to 6.12.6. +- [Release notes](https://github.com/ajv-validator/ajv/releases) +- [Commits](https://github.com/ajv-validator/ajv/compare/v6.10.2...v6.12.6) + +--- +updated-dependencies: +- dependency-name: ajv + dependency-type: indirect +... + +
+ +
9546de2c Web Socket initialization message timeout (#2006) + +* Added an optional timeout to the web socket initialization message read operation. + +* Added a fail message to a web socket init read timeout test. + +
+ +
f6ea6230 fixed introspection for schema description and specifiedByhttps://github.com/niko0xdev/gqlgen (#1986) + +* fixed introspection for schema description and specifiedByURL + +* updated to the master latest + +* fixed Description resolver + +* updated integration go file + +* fixed codegen tests for the latest gqlparser + +* updated go mod in example + +* go generate + +* skip specifiedBy + +* regenerate + +* fixed schema-expected.graphql for the latest + +* fixed integration test to use latest tools + +* fixed integration workflow + +* use v2.4.0 + +* fixed sum + +
+ +- f17ca15e Fix broken links in docs (#1983) (closes #1734) + +- a0c856b7 Added a callback error handling function to the websocket and added tests for it. (#1975) + +- cfea9f07 generate resolvers for input types (#1950) + +
ffa857ef Websocket i/o timeout fix (#1973) + +* Renamed "pingMesageType" to "pingMessageType" and refactored websocket_graphqlws.go to look more like websocket_graphql_transport_ws.go for the sake of consistency. + +* Made the keep-alive messages graphql-ws only, and the ping-pong messages graphql-transport-ws only (and added tests for it). + +* gofmt + +
+ +
d7da5b0d Merge pull request #1958 from niko0xdev/cleanup-main + +Cleanup main + +
+ +
42f32432 Merge pull request #1957 from niko0xdev/move-init-ci + +Upate init CI step + +
+ +- be164748 Cleanup main + +- 8ea290c0 Upate init CI step + +- 56bfb188 Fix 1955: only print message on [@key](https://github.com/key) found on interfaces (#1956) + +
213a085b rename "example" dir to "_examples" (#1734) + +* rename "example" dir to "_examples" + +* fix lint + +* Adjust permissions + +
+ +
9262b358 fix: typo in dataloader code sample (#1954) + +* fix: typo in dataloader code sample + +* rename k to key for sample to compile + +
+ +- a0543733 remove autobind example (#1949) + +
06bbca37 docs: migrate dataloaders sample to graph-gophers/dataloader (#1871) + +* docs: add dataloader sample + +* finish example + +* add example + +* simplify method + +* replace old example + +* styling + +* Update docs/content/reference/dataloaders.md + +* Update docs/content/reference/dataloaders.md + +* Update docs/content/reference/dataloaders.md + +* Update docs/content/reference/dataloaders.md + +
+ +
f9fcfa16 Comment out autobind in the sample config file (#1872) + +The reason is that many people using it for the first time copy exactly that configuration example and then open the issues to say it doesn't work. + +
+ +- a30b68de fix: whitelist VERSION and CURRENT_VERSION env vars (#1870) + +
76a533b8 Bump gopkg.in/yaml.v2 from 2.2.4 to 2.2.8 (#1858) + +* Bump gopkg.in/yaml.v2 from 2.2.4 to 2.2.8 + +Bumps [gopkg.in/yaml.v2](https://github.com/go-yaml/yaml) from 2.2.4 to 2.2.8. +- [Release notes](https://github.com/go-yaml/yaml/releases) +- [Commits](https://github.com/go-yaml/yaml/compare/v2.2.4...v2.2.8) + +--- +updated-dependencies: +- dependency-name: gopkg.in/yaml.v2 + dependency-type: direct:production +... + + +* Update go sum for example + +
+ +
eed4301c Bump node-fetch from 2.6.1 to 2.6.7 in /integration (#1859) + +Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.1 to 2.6.7. +- [Release notes](https://github.com/node-fetch/node-fetch/releases) +- [Commits](https://github.com/node-fetch/node-fetch/compare/v2.6.1...v2.6.7) + +--- +updated-dependencies: +- dependency-name: node-fetch + dependency-type: direct:development +... + +
+ +- 7f5dce6d Fix #1776 : Edit and persist headers in GraphiQL (#1856) + +- e0b42f99 fix requires directive with nested field when entityResolver directive is used (#1863) + +- 25c2cdcb Fix #1636 by updating gqlparser (#1857) + +- c161ab38 fix #1770 minor error in getting-started.md (#1771) + +
57a148f6 Remove outdated version reference so example is always for latest (#1851) + +* Also update version reference to next + +* Update getting-started.md + +
+ +- 0ab63614 Update quickstart (#1850) + +
a8eba26d Fix #1777 by updating version constant and adding release checklist (#1848) + +* Revise to use script 🤦 + +
+ + + + + + +## [v0.16.0](https://github.com/niko0xdev/gqlgen/compare/v0.15.1...v0.16.0) - 2022-01-24 +- b90f9750 Merge branch 'master' of github.com:niko0xdev/gqlgen + +- 99523e44 Prepare for v0.16.0 release (#1842) + +- 0563146c Prepare for v0.16.0 release + +
7cefef26 add PrependPlugin (#1839) + +* add PrependPlugin + +related: https://github.com/niko0xdev/gqlgen/pull/1838 + +* added test for PrependPlugin + +
+ +
972878a0 Revert "Fix plugin addition (#1717)" (#1838) + +This reverts commit f591c8f797e35635fb5eb0e4465c77b6a073896b. + +
+ +
1ed7e050 Fix #1832 [@requires](https://github.com/requires) directive when [@entityResolver](https://github.com/entityResolver) is used (#1833) + +* fix requires directive for multipleEntity directive + + +* fix lint + +
+ +
fcee4c40 Update README.md (#1836) + +Corrected a simple grammar typo. + +
+ +
3fb5fd99 Fix #1834: Implement federation correctly (#1835) + +* Fix federation implementation which does not conform to Apollo Federation subgraph specification + +* Optimize generated line breaks + +* Run go generate + +
+ +
98665071 Imporve gqlgen test cases (#1773) (closes #1765) + +* Imporve test cases for init and generate + +
+ +
5d904d87 Merge pull request #1778 from ipfans/gh-pages-patch + +Bump gqlgen.com version list + +
+ +- 196ee13b Bump gqlgen.com version + + + + + + +## [v0.15.1](https://github.com/niko0xdev/gqlgen/compare/v0.15.0...v0.15.1) - 2022-01-16 +- 7102a36b Prepare for 0.15.1 release + +
2b8f50b3 Fix #1765: Sometimes module info not exists or not loaded. (#1767) + +* Remove failing test + +
+ +- 46502e5e fixed broken link (#1768) + + + + + + +## [v0.15.0](https://github.com/niko0xdev/gqlgen/compare/v0.14.0...v0.15.0) - 2022-01-14 +- 99be1951 Prepare for release + +
931271a2 Fix #1762: Reload packages before merging type systems (#1763) + +* run gofmt on file + +
+ +- e5b5e832 Improve performance of MarshalBoolean (#1757) + +
57664bf0 Migrate playgrounds to GraphiQL (#1751) + +* migrate to GraphiQL playground + +* fix lint + +
+ +
b2a832d5 Avoid problems with `val` being undefined in the federation template. (#1760) + +* Avoid problems with `val` being undefined in the federation template. + +When running gqlgen over our schema, we were seeing errors like: +``` +assignments/generated/graphql/service.go:300:4: val declared but not used +``` + +The generated code looks like this: +``` +func entityResolverNameForMobileNavigation(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + m = rep + if _, ok = m["kaid"]; !ok { + break + } + m = rep + if _, ok = m["language"]; !ok { + break + } + return "findMobileNavigationByKaidAndLanguage", nil + } + return "", fmt.Errorf("%w for MobileNavigation", ErrTypeNotFound) +} +``` + +Looking at the code, it's pretty clear that this happens when there +are multiple key-fields, but each of them has only one keyField.Field +entry. This is because the old code looked at `len(keyFields)` to +decide whether to declare the `val` variable, but looks at +`len(keyField.Field)` for each keyField to decide whether to use the +`val` variable. + +The easiest solution, and the one I do in this PR, is to just declare +`val` all the time, and use a null-assignment to quiet the compiler +when it's not used. + +* run go generate to update generated files + +* run go generate to update moar generated files + +* Adding a test for verify that this fixes the issue. + +From `plugins/federation`, run the following command and verify that no errors are produced + +``` +go run github.com/niko0xdev/gqlgen --config testdata/entityresolver/gqlgen.yml +``` + +
+ +
47015f12 Added pointer to a solution for `no Go files` err (#1747) + +While following the instructions in this getting started guide I run into this error `package github.com/niko0xdev/gqlgen: no Go files` which was pretty annoying to fix. Its a golang issue but for people who are unfamiliar with how the `go generate` command works in vendored projects its a blocker trying to follow the rest of this guide. It will be really nice to at least have a pointer in the guide for people to find a possible solution to the issue while going through the guide. I'm sure many folks have run into this issue given vendoring is now very popular with the latest go releases. + +
+ +- 27a2b210 Downgrade to Go 1.16 (#1743) + +
14cfee70 Support for multiple [@key](https://github.com/key) directives in federation (reworked) (#1723) + +* address review comments + +- reworked code generation for federation.go +- better checking for missing/incorrect parameters to entity resolver functions +- better tests for generated entity resolvers + +Still missing: +- suggested test for autobind vs non-autobind generation +- could probably clean up generated code spacing, etc + +
+ +- 2747bd5f Add CSV and PDF to common initialisms (#1741) + +
44beadc1 Fix list coercion when using graphql variables (#1740) + +* fix(codegen): support coercion of lists in graphql variables + +This was broken by an upstream dependency `gqlparser` coercing variables during validation. this has broken the existing coercion process withing `gqlgen` + +* test: add list coercion integration tests + +* chore: regenerate generated code + +* test: update expected schema for integration tests + +* chore: run goimports + +* chore: regenerate examples + +
+ +
bd8938d8 fix: automatically register built-in directive goTag (#1737) + +* fix: automatically register built-in tag goTag + +* doc: add directive config documentation + +
+ +
497227fa Close Websocket Connection on Context close/cancel (#1728) + +* Added code to the web socket so it closes when the context is cancelled (with an optional close reason). + +* Added a test. + +* go fmt + + +* Fix linter issues about the cancel function being thrown away. + +
+ +- 4581fccd Don't loose field arguments when none match (#1725) + +
213ecd93 Add support for graphql-transport-ws with duplex ping-pong (#1578) + +* Add support for graphql-transport-ws with duplex ping-pong + +* Add tests for the duplex ping-pong + +
+ +- ae92c83d add federation tests (#1719) + +- f591c8f7 Fix plugin addition (#1717) + +- 8fa6470f Fix #1704: handle [@required](https://github.com/required) nested fields as in [@key](https://github.com/key) (#1706) + +
af33b7cd Cleaning up extra return in federation generated code (#1713) + +In PR 1709, I introduced GetMany semantics for resolving federated entities. But I left a couple of extra return statements in the generated code that are not necessary. So Im just cleaning those up here. + +Also added `go:generate` in federation entity resolver tests to make it simpler to test. + +To test: +``` +go generate ./... && cd example/ && go generate ./... && cd .. +go test -race ./... && cd example && go test -race ./... && cd .. +``` + +
+ +
402a2259 Optimize performance for binder, imports and packages (Rebased from sbalabanov/master) (#1711) + +* Cache go.mod resolution for module name search + +* Optimize binder.FindObject() for performance by eliminating repeatitive constructs + +* Optimize allocations in packages.Load() function + +* Optimize binder.FindObject() by indexing object definitions for each loaded package + +* goimports to fix linting + +
+ +- 237a7e6a Separate golangci-lint from other jobs (#1712) + +
50292e99 Resolve multiple federated entities in a single entityResolve call (#1709) + +* Resolve multiple federated entities in a single entityResolve call + +Entity resolver functions can only process one entity at a time. But often we want to resolve all the entities at once so that we can optimize things like database calls. And to do that you need to add you'd need to add batching with abstractions like dataloadgen or batchloader. The drawback here is that the resolver code (the domain logic) gets more complex to implement, test, and debug. + +An alternative is to have entity resolvers that can process all the representations in a single call so that domain logic can have access to all the representations up front, which is what Im adding in this PR. + +There are a few moving pieces here: +3. When that's configured, the federation plugin will create an entity resolver that will take a list of representations. + +Please note that this is very specific to federation and entity resolvers. This does not add support for resolving fields in an entity. + +Some of the implementation details worth noting. In order to efficiently process batches of entities, I group them by type so that we can process groups of entities at the same time. The resolution of groups of entities run concurrently in Go routines. If there is _only_ one type, then that's just processed without concurrency. Entities that don't have multiget enabled will still continue to resolve concurrently with Go routines, and entities that have multiget enabled just get the entire list of representations. + +The list of representations that are passed to entity resolvers are strongly types, and the type is generated for you. + +There are lots of new tests to ensure that there are no regressions and that the new functionality still functions as expected. To test: +1. Go to `plugin/federation` +2. Generate files with `go run github.com/niko0xdev/gqlgen --config testdata/entityresolver/gqlgen.yml` +3. And run `go test ./...`. Verify they all pass. + +You can look at the federated code in `plugin/federation/testdata/entityresolver/gederated/federation.go` + +* Added `InputType` in entity to centralize logic for generating types for multiget resolvers. + +* reformat and regenerate + +
+ +
80713b84 Adding entity resolver tests for errors, entities with different type… (#1708) + +* Adding entity resolver tests for errors, entities with different types, and requires + +The tests in this PR are for ensuring we get the expected errors from entity resolvers, that we also handle resolving entities where the representations are for different types, and that requires directive works correctly. + +To run tests: +1. Go to `plugin/federation` +2. Generate files with `go run github.com/niko0xdev/gqlgen --config testdata/entityresolver/gqlgen.yml` +3. And run `go test ./...`. Verify they all pass. + +* Fixed test for errors + +
+ +- ed2d6998 Replace ! with _ in root.generated file to avoid build conflicts (#1701) + +
828820af transport: implement `graphql-transport-ws` ws sub-protocol (#1507) + +* websocket: create `messageExchanger` to handle subprotocol messages + +* remove unused type + +* typo in comments + +* change `graphqlwsMessageType` type to string + +* add support for `graphql-transport-ws` subprotocol + +* fix chat app example + +* update example chat app dependencies + +* improve chat app exmaple to use the recommended ws library + +* add tests + +* removed unused const in tests + +* Update example/chat/readme.md + +
+ +- 28caa6ce Ignore generated files from test coverage (#1699) + +- 7ac988de Fix linting issue + +
01d3c4f8 Entity resolver tests (#1697) + +* Moving federation tests to their own folders + +Reorganizing the tests in the federation plugin a little bit so make it simpler to add more safely without testdata colliding. This is in anticipation for a follow up PR for adding entity resolver tests. + +Run the tests with `go test ./plugin/federation/...` and verify they all pass. Also verify that the testdata/allthething directory has a `generated` directory specific to that test. + +NOTE: There is a catch all type of test that I moved to the directory `allthething`. Open to suggestions for a better name! One potential thing to considere here is to split up the tests that use that testdata and break them down into more specific tests. E.g. Add a multikey test in the testdata/entity. For now, Im leaving that as a TODO. + +* Adding entity resolver tests in the federation plugin + +The tests work by sending `_entities` queries with `representation` variables directly to the mocked server, which will allow us to test generated federation code end to end. For context, the format of the entity query is something like: + +``` +query($representations:[_Any!]!){_entities(representations:$representations){ ...on Hello{secondary} }} +``` + +And `representations` are the list of federated keys for the entities being resovled, and they look like + +``` +representations: [{ + "__typename": "Hello", + "name": "federated key value 1", +}, { + "__typename": "Hello", + "name": "federated key value 2", +}] +``` + +The entity resolver tests are in `plugin/federation/federation_entityresolver_test.go` and they rely on `plugin/federation/testdata/entityresolver`. + +To run the tests: +1. Build the entityresolver testdata + - From plugin/federation, run `go run github.com/niko0xdev/gqlgen --config testdata/entityresolver/gqlgen.yml` +2. Run the tests with `go test ./...` or similar + +
+ +
b7db36d3 Revert "Support for multiple [@key](https://github.com/key) directives in federation (#1684)" (#1698) + +This reverts commit 47de912f56cd4bd6da9b74929cd67b8881617026. + +
+ +- 4a4b5601 DOC: Fixed indention in example code. (#1693) + +
47de912f Support for multiple [@key](https://github.com/key) directives in federation (#1684) + +* add more unit test coverage to plugin/federation + +
+ +
59a30919 Reimplement goTag using FieldMutateHook (#1682) + +* Reimplement goTag using a FieldMutateHook + +This change does not change the logic of goTag, merely reimplements it using a FieldMutateHook and sets it as the default FieldMutateHook for the modelgen plugin. + +* Add repeated tag test + +
+ +
37a4e7ee Rename `[@extraTag](https://github.com/extraTag)` directive to `[@goTag](https://github.com/goTag)` and make repeatable (#1680) + +* Allow Repeatable `goTag` Directive + +* Default to field name if none provided + +* Update Docs + +
+ +
87f9e436 Fix nil pointer dereference when an invalid import is bound to a model (#1676) + +* Fixes remaining Name field in singlefile test + +* Fixes nill pointer dereference when an invalid import is bound to a model + +* Only return error if we failed to find type + +* Revert "Fixes remaining Name field in singlefile test" + +This reverts commit e43ebf7aa80f884afdb3feca90867b1eff593f01. + +* Undo change of log.Println -> fmt.Println + +Totally accidental, sorry! + +
+ +
6c65e8f1 Update getting-started.md (#1674) + +missing an 's' on quoted filename default + +
+ +- 3bbc2a34 feat: generate resolvers for inputs if fields are missing (#1404) + +
7db941a5 Fix 1138: nested fieldset support (#1669) + +* formatting + +* update federation schema to latest Apollo spec + + +also: +handle extra spaces in FieldSet +upgrade deps in federation integration tests + +
+ +
488a31fc ContextMarshaler (#1652) + +* Add interface and detection for ContextMarshaler + +* Test error on float marshalling + +* Revert prettier changes + +* Rename context test + +* Only use the erroring float printer + +* Test that context is passed to marshal functions + +* Update scalar docs to include the context + +* Generate the examples + +* Move ContextMarshaller test code to new followschema + +* Resolve conflict a little more + + +* Replicate sclar test for singlefile + +
+ +- a626d9b4 Add ICMP to common initialisms (#1666) + +- db4b5eb7 Merge Inline Fragment Nested Interface Fields (#1663) + +
8b973717 Update directives doc page (#1660) + +* Update directives doc page + +* Add back one beloved piece of jargon + +
+ +
1f500016 Add follow-schema layout for exec (#1309) (closes #1265) + +* Define ExecConfig separate from PackageConfig + +When support for writing generated code to a directory instead of +a single file is added, ExecConfig will need additional fields +that will not be relevant to other users of PackageConfig. + +* Add single-file, follow-schema layouts + +When `ExecLayout` is set to `follow-schema`, output generated code to a +directory instead of a single file. Each file in the output directory +will correspond to a single *.graphql schema file (plus a +root!.generated.go file containing top-level definitions that are not +specific to a single schema file). + +`ExecLayout` defaults to `single-file`, which is the current behavior, so +this new functionality is opt-in. + +These layouts expose similar functionality to the `ResolverLayout`s with +the same name, just applied to `exec` instead of `resolver`. + + +* Rebase, regenerate + +
+ +
12978359 Update GQLgen test client to work with multipart form data (take 2) (#1661) + +* Update GQLgen test client to work with multipart form data + +Update the GQLgen to support multipart form data, like those present +within the fileupload examples. + +- Add missing space between "unsupported encoding " and failing + content-type header error + +(cherry picked from commit 101842f73fb79b10c1299bb40506080e08543ec6) + +* Add WithFiles client option for fileupload GQLgen client tests + +Add a `WithFiles` GQLgen client option to support the fileupload input +within tests, using the core Golang `os` package and File type, which +converts `os.File`s to their appropriate multipart form data within a +request. + +- If there are no files this should just simply convert a + `application/json` Content-Type to supported `multipart/form-data` + +(cherry picked from commit 08ef942416c98a2cadf61223308a3ff3c879d1c9) + +* Update fileupload test to use GQLgen test client + +Update the fileupload test to use the GQLgen test client and `WithFiles` +option to remove the need for `createUploadRequest` helper with raw http +posts + +- Fix setting the Content Type by using the appropriate `http` package + function to dectect it + + + https://godoc.org/net/http#DetectContentType + +(cherry picked from commit 5e573d51440eba9d457adb4186772577b28ef085) + +* Update WithFiles option test with multipart Reader + +(cherry picked from commit 6dfa3cbe0647138e80a59a0c1d55dd9c900f96f2) + +* Update file upload tests `WithFiles` option + +Update the file upload tests to use the GQL test client and its +`WithFiles` option to remove the need for a custom raw HTTP post request +builder `createUploadRequest`. + +- Also update `WithFiles` option to group & map identical files; e.g. + + ``` + { "0": ["variables.req.0.file", "variables.req.1.file"] } + ``` + +(cherry picked from commit 486d9f1b2b200701f9ce6b386736a633547c1441) + +* Make sure `WithFiles` does not add duplicates to multipart form data + +(cherry picked from commit 0c2364d8495553051d97ab805618b006fcd9eddb) + +* Fix use of byte vs string in `WithFiles` tests + +(cherry picked from commit ba10b5b1c52a74e63e825ee57c235254e8821e0d) + +* Fix strict withFiles option test for race conditions + +Fix a problem with how strict the test's expected response was for tests +with files in their request, since it always expected a strict order of +files input that is somewhat random or dependent on what OS it is +running the test on and/or race condition + +
+ +
7435403c Adds RootFieldInterceptor to extension interfaces (#1647) + +* Adds RootFieldInterceptor to extension interfaces + + +* Regenerates example folder + + +* Re-generate after changes + +
+ +- 8b25c9e0 Add a config option to skip running "go mod tidy" on code generation (#1644) + +
658195b7 Revert "Update GQLgen test client to work with multipart form data (#1418)" (#1659) + +This reverts commit 1318f12792e86c76a2cdff9132ebac5b3e30e148. + +
+ +- 41c86765 Revert 1595 (#1658) + +- 8359f974 Allow custom websocket upgrader (#1595) + +
1318f127 Update GQLgen test client to work with multipart form data (#1418) + +* Update GQLgen test client to work with multipart form data + +Update the GQLgen to support multipart form data, like those present +within the fileupload examples. + +- Add missing space between "unsupported encoding " and failing + content-type header error + +* Add WithFiles client option for fileupload GQLgen client tests + +Add a `WithFiles` GQLgen client option to support the fileupload input +within tests, using the core Golang `os` package and File type, which +converts `os.File`s to their appropriate multipart form data within a +request. + +- If there are no files this should just simply convert a + `application/json` Content-Type to supported `multipart/form-data` + +* Update fileupload test to use GQLgen test client + +Update the fileupload test to use the GQLgen test client and `WithFiles` +option to remove the need for `createUploadRequest` helper with raw http +posts + +- Fix setting the Content Type by using the appropriate `http` package + function to dectect it + + + https://godoc.org/net/http#DetectContentType + +* Update WithFiles option test with multipart Reader + +* Update file upload tests `WithFiles` option + +Update the file upload tests to use the GQL test client and its +`WithFiles` option to remove the need for a custom raw HTTP post request +builder `createUploadRequest`. + +- Also update `WithFiles` option to group & map identical files; e.g. + + ``` + { "0": ["variables.req.0.file", "variables.req.1.file"] } + ``` + +* Make sure `WithFiles` does not add duplicates to multipart form data + +* Fix use of byte vs string in `WithFiles` tests + +
+ +- 6758654c raise panic when nested [@requires](https://github.com/requires) are used on federation (#1655) + +
f6c35be2 Add ReplacePlugin option to replace a specific plugin (#1657) + +* Add Helper Option for replacing plugins + +* Update recipe to use ReplacePlugin instead of NoPlugin and AddPlugin + +* fix linting issue on comment + +
+ +
f8c46600 fix double indirect bug (#1604) (closes #1587) + +* invalid code generated + +* update code generation for pointer-to-pointer updating + +
+ +- 629c91a2 remove extra WithOperationContext call (#1641) + +- 35199c49 codegen: ensure Elem present before using (#1317) + +
bfea93cd Reload config packages after generating models (#1491) + +If models are generated in a package that has already been loaded, and +that package refers to another package that has already been loaded, we +can find ourselves in a position where it appears that a GQL `union` is +not satisfied. + +For example, if we have: + +``` +union Subject = User +``` + +with this gqlgen.yml in github.com/wendorf/gqlgen-error/gql: + +``` +schema: +- schema.graphql +exec: + filename: generated.go +model: + + filename: models_gen.go +models: + User: + model: github.com/wendorf/gqlgen-error/gql.User + Subject: + model: github.com/wendorf/gqlgen-error/models.Subject +``` + +Note that our User model is in the github.com/wendorf/gqlgen-error.gql +package, and our models_gen.go will be generated in that same package. + +When we try to run gqlgen, we get this error: + +``` +merging type systems failed: unable to bind to interface: github.com/wendorf/gqlgen-error/gql.User does not satisfy the interface github.com/wendorf/gqlgen-error/models.Subject +``` + +Digging deeper, it's because we use types.Implements in +codegen/interface.go, which does a shallow object comparison. Because +the type has been reloaded, it refers to a _different_ interface type +object than the one we're comparing against, and get a false negative. + +By clearing the package cache and repopulating it, the whole package +cache is generated at the same time, and comparisons across packages +work. + +To see a demo of this, check out +https://github.com/wendorf/gqlgen-error and try the following: + +1. Checkout the works-with-v0.10.2 branch and `go generate ./...` to see + that it works +2. Checkout the breaks-with-v0.13.0 branch (or run go get + to see errors +3. Checkout the works-with-pull-request branch and `go generate ./...` + to see that it works again. This branch adds a go.mod replace + directive to use the gqlgen code in this PR. + +The demo starts at v0.10.2 since it is the last release without this +problem. https://github.com/niko0xdev/gqlgen/pull/1020 introduces the +code that fails in this scenario. + +
+ +
9e0817cd Add graphql schema aware field level hook to modelgen (#1650) + +* Add ast aware field level hook to modelgen + +Currently, the only mechanism for extending the model generation is to use a BuildMutateHook at the end of the model generation process. This can be quite limiting as the hook only has scope of the model build and not the graphql schema which has been parsed. + +This change adds a hook at the end of the field creation process which provides access to the parsed graphql type definition and field definition. This allows for more flexibility for example adding additional tags to the model based off custom directives + +* Add recipe for using the modelgen FieldMutateHook + +* fix goimport linting issue in models_test + +
+ +
af2ac061 handling unconventional naming used in type names (#1549) + +* handling unconventional naming used in type names + +* Fix merge resolution mistake + +* Fix merge resolution mistake + +
+ +- 393f7554 add extraTag directive (#1173) + +- fd1bd7c9 adding support for sending extension with gqlgen client (#1633) + +
589a7742 Enable lowercase type names in GraphQL schema to properly render (#1359) + +The difficulty with lowercased type names is that in go code any lowercased name is not exported. +This change makes the names title case for go code while preserving the proper case when interacting with the GraphQL schema. + +
+ +- 50f6a2aa Fixes #1653: update docs and wrap error if not *gqlerror.Error (#1654) + +
7081dedb Bump tmpl from 1.0.4 to 1.0.5 in /integration (#1627) + +Bumps [tmpl](https://github.com/daaku/nodejs-tmpl) from 1.0.4 to 1.0.5. +- [Release notes](https://github.com/daaku/nodejs-tmpl/releases) +- [Commits](https://github.com/daaku/nodejs-tmpl/commits/v1.0.5) + +--- +updated-dependencies: +- dependency-name: tmpl + dependency-type: indirect +... + +
+ +
5287e4e5 Add QR and KVK to common initialisms (#1419) + +* Add QR and KVK to common initialisms + +* Update templates.go + +* Sort commonInitialisms + +
+ +
f9df1a46 Update time format for `Time` scalar (#1648) + +* Use more precise time format + +* update test + +* update docs + +* Apply suggestions from code review + +* Update scalars.md + +
+ +
77c757f0 Merge pull request #1640 from minus7/master + +Fix example run instructions + +
+ +
e60dc7af Merge pull request #1619 from Khan/benkraft.mod-tidy-stdout + +Forward `go mod tidy` stdout/stderr + +
+ +
0c63f1d1 Merge pull request #1515 from OpenSourceProjects/time + +Marshaling & Unmarshaling time return initial value + +
+ +- a3d9e8ce Remove redundant favicon (#1638) + +- 210c1aa6 Appropriately Handle Falsy Default Field Values (#1623) + +
47ce074a Fix example run instructions (closes #1607) + +Making ./example a separate Go module [1] broke the `go run` invocations +listed in a few example readmes [2]. Using relative paths from the +respective example directory should be clear enough. + +[2]: +example/todo/server/server.go:10:2: no required module provides package github.com/niko0xdev/gqlgen/example/todo; to add it: + go get github.com/niko0xdev/gqlgen/example/todo + +
+ +- 1a0b19fe Update README.md + +
d9998283 Merge pull request #1628 from robertmarsal/patch-1 + +Fix typo in the getting-started docs + +
+ +- f93f73ac Fix typo in the getting-started docs + +
2f6919ff Merge pull request #1624 from FlymeDllVa/master + +Update disabling Introspection + +
+ +- c53bc0e5 Update disabling Introspection + +- 880cd73d Update README.md + +- eec81df0 Update README.md + +
43b56cba Forward `go mod tidy` stdout/stderr + +This is a command that can fail (in my case I think for stupid reasons +in a hell of my own construction, but nonetheless). Right now we just +get +``` +$ go run github.com/Khan/webapp/dev/cmd/gqlgen +tidy failed: go mod tidy failed: exit status 1 +exit status 3 +``` +which is not the most informative. Now, instead, we'll forward its +output to our own stdout/stderr rather than devnull. + +
+ +- ce7a8ee4 Fix link in docs + +- 488cf7e8 Update docs/content/getting-started.md + +- 73809f69 Update getting started + +- b938e558 Update README.md + +- cacd49a6 Update README.md + +
7d549d64 Merge pull request #1617 from niko0xdev/update-docs-for-go1.17 + +Update docs for getting started + +
+ +- 5c52f27c Update docs for getting started + +- 41d6926f Replace gitter with discord in contributing.md + +- 24d4edcf Update README.md + +- 2272e05b Update README.md + +
ef4d4a38 Merge pull request #1614 from niko0xdev/go-1.16 + +Also test against 1.16 + +
+ +- 00ed6fb1 Also test against 1.16 + +
473f0671 Merge pull request #1613 from niko0xdev/bump-non-module-deps + +Clean up non-module deps + +
+ +- 6960c0c2 Bump non-module deps + +
bf9b34aa Merge pull request #1612 from niko0xdev/update-linter + +Update golangci linter + +
+ +- 85e7a4a0 Linting fixes + +- 777dabde Update the linter + +
85dd47bb Merge pull request #1607 from niko0xdev/example-module + +[POC/RFC] Split examples into separate go module + +
+ +- f93fb248 Split examples into separate go module + +
890f5f66 Merge pull request #1610 from niko0xdev/go-1.17 + +Update to go 1.17 + +
+ +- 9162c53f Fix newlines in error messages + +- f67a5b26 Update github.com/urfave/cli/v2 + +
1116ea6c Merge pull request #1608 from jjmengze/patch-1 + +fix Options response header + +
+ +- 71e57843 Simplify init + +- a8903ca2 Wrap errors + +- a644175b Update error checks for go 1.17 + +- c6b9f292 go mod tidy + +- 1c63cfff Add missing model package file + +- 59da23fe Create a temporary file on init so go recognises the directory as a package + +
682a7d66 fix Options response header + +operatee the header of ResponseWriter should before WriteHeader called + +
+ +- ed8054b0 Update to a post-release version + +- 5216db58 Fix TestAutobinding test failure by checking the module + +- 90c5eb59 go generate + +- 402f4495 go fmt + +- 10bb1ef2 Go mod tidy + +- ed210385 Update to go 1.17 + +- 5c7acc1b Fix imports + +- d7473870 Update plugin/servergen/server.go + +- a6c6de6b Update plugin/resolvergen/resolver.go + +- de7d19c8 Update codegen/config/config_test.go + +- 60d80d4a Update cmd/gen.go + +- a991e3e7 Update errors to use go1.13 semantics + +
8f179be9 Merge pull request #1581 from tsh96/master + +Bypass complexity limit on __Schema queries. + +
+ +
5048f992 Merge pull request #1525 from Code-Hex/fix/support-input-object + +support input object directive + +
+ +
1e2b303a Merge pull request #1526 from epulze/fix/allow-more-types + +allow more than 10 different import sources with types + +
+ +
e7df3e5c Merge pull request #1405 from alexsn/subsciption-complete-on-panic + +subscriptions: send complete message on resolver panic + +
+ +
06e4fe88 Merge pull request #1529 from mathieupost/master + +Return type loading errors in config.Binder.FindObject + +
+ +
a557c90c Merge pull request #1340 from bickyeric/master + +serialize ID just like String + +
+ +
522cab59 Merge pull request #1285 from Khan/benkraft.federation + +Resolve requests for federation entities in parallel + +
+ +- 5adb73bb add bypass __schema field test case + +- 54cef3dd Bypass complexity limit on __Schema queries. + +- f0ccab79 Return type loading errors in config.Binder.FindObject + +- 91b54787 generated go code + +- 1efc152e supported INPUT_OBJECT directive + +- e82b401d allow more than 10 different import sources with types + +
481a4e44 Marshaling & Unmarshaling time return initial value + +There was a lack of symmetry that would prevent times for being +symmetrical. That is because time.Parse actually parses an RFC3339Nano +implicitly, thereby allowing nanosecond resolution on unmarshaling a +time. Therefore we now marshal into nanoseconds, getting more +information into GraphQL times when querying for a time, and restoring +the symmetry + +
+ +
95653193 Resolve requests for federation entities in parallel (closes #1278) + +In apollo federation, we may be asked for data about a list of entities. +These can typically be resolved in parallel, just as with sibling fields +in ordinary GraphQL queries. Now we do! + +I also changed the behavior such that if one lookup fails, we don't +cancel the others. This is more consistent with the behavior of other +resolvers, and is more natural now that they execute in parallel. This, +plus panic handling, required a little refactoring. + +The examples probably give the clearest picture of the changes. (And the +clearest test; the changed functionality is already exercised by +`integration-test.js` as watching the test server logs will attest.) + +
+ +- f00e2c3f subscriptions: send complete message on resolver panic + +- fa371b9b serialize ID just like String + + + + + + +## [v0.14.0](https://github.com/niko0xdev/gqlgen/compare/v0.13.0...v0.14.0) - 2021-09-08 +- 56451d92 release v0.14.0 + +
8e97969b Merge pull request #1358 from mtsmfm/patch-1 + +Create package declaration to run dataloaden + +
+ +
b978593c Merge pull request #1387 from Khan/benkraft.config + +codegen/config: Add a new API to finish an already-validated config + +
+ +
71507dfc Merge pull request #1408 from max107/patch-1 + +int64 support graphql/string.go + +
+ +
23577b69 Merge pull request #1460 from snxk/edit-docs-recipe-gin + +Edited the Gin-Gonic Recipe Docs + +
+ +- db6154b9 Update README.md + +
cecda160 Merge pull request #1464 from frederikhors/patch-1 + +Add goreportcard badge + +
+ +- cc957171 Merge branch 'master' into patch-1 + +
023f66df Merge pull request #1465 from frederikhors/patch-2 + +Add coveralls badge + +
+ +
50c2028a Merge pull request #1497 from polytomic/stable-introspection + +Return introspection document in stable order + +
+ +
a0232dd2 Merge pull request #1603 from niko0xdev/dependabot/npm_and_yarn/integration/normalize-url-4.5.1 + +Bump normalize-url from 4.5.0 to 4.5.1 in /integration + +
+ +
4e059eba Merge pull request #1602 from niko0xdev/dependabot/npm_and_yarn/integration/ini-1.3.8 + +Bump ini from 1.3.5 to 1.3.8 in /integration + +
+ +
43705d45 Merge pull request #1601 from niko0xdev/dependabot/npm_and_yarn/integration/y18n-3.2.2 + +Bump y18n from 3.2.1 to 3.2.2 in /integration + +
+ +
1f2465c6 Merge pull request #1600 from niko0xdev/dependabot/npm_and_yarn/integration/browserslist-4.17.0 + +Bump browserslist from 4.14.0 to 4.17.0 in /integration + +
+ +
bbdebd4c Merge pull request #1599 from niko0xdev/dependabot/npm_and_yarn/integration/hosted-git-info-2.8.9 + +Bump hosted-git-info from 2.8.5 to 2.8.9 in /integration + +
+ +
900a37af Merge pull request #1598 from niko0xdev/dependabot/npm_and_yarn/integration/node-fetch-2.6.1 + +Bump node-fetch from 2.6.0 to 2.6.1 in /integration + +
+ +
9d334cdd Merge pull request #1597 from niko0xdev/dependabot/npm_and_yarn/integration/ws-7.4.6 + +Bump ws from 7.3.1 to 7.4.6 in /integration + +
+ +
56181e8a Merge pull request #1365 from frederikhors/add-uint,-uint64,-uint32-types-in-graphql + +add uint, uint64, uint32 types in graphql pkg + +
+ +
fd133c0b Bump normalize-url from 4.5.0 to 4.5.1 in /integration + +Bumps [normalize-url](https://github.com/sindresorhus/normalize-url) from 4.5.0 to 4.5.1. +- [Release notes](https://github.com/sindresorhus/normalize-url/releases) +- [Commits](https://github.com/sindresorhus/normalize-url/commits) + +--- +updated-dependencies: +- dependency-name: normalize-url + dependency-type: indirect +... + +
+ +
24d8c703 Bump ini from 1.3.5 to 1.3.8 in /integration + +Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.8. +- [Release notes](https://github.com/isaacs/ini/releases) +- [Commits](https://github.com/isaacs/ini/compare/v1.3.5...v1.3.8) + +--- +updated-dependencies: +- dependency-name: ini + dependency-type: indirect +... + +
+ +
de89d3a6 Bump y18n from 3.2.1 to 3.2.2 in /integration + +Bumps [y18n](https://github.com/yargs/y18n) from 3.2.1 to 3.2.2. +- [Release notes](https://github.com/yargs/y18n/releases) +- [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md) +- [Commits](https://github.com/yargs/y18n/commits) + +--- +updated-dependencies: +- dependency-name: y18n + dependency-type: indirect +... + +
+ +
13db6111 Bump browserslist from 4.14.0 to 4.17.0 in /integration + +Bumps [browserslist](https://github.com/browserslist/browserslist) from 4.14.0 to 4.17.0. +- [Release notes](https://github.com/browserslist/browserslist/releases) +- [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md) +- [Commits](https://github.com/browserslist/browserslist/compare/4.14.0...4.17.0) + +--- +updated-dependencies: +- dependency-name: browserslist + dependency-type: indirect +... + +
+ +
94e9406e Bump hosted-git-info from 2.8.5 to 2.8.9 in /integration + +Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.5 to 2.8.9. +- [Release notes](https://github.com/npm/hosted-git-info/releases) +- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md) +- [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.5...v2.8.9) + +--- +updated-dependencies: +- dependency-name: hosted-git-info + dependency-type: indirect +... + +
+ +
36be94ff Bump node-fetch from 2.6.0 to 2.6.1 in /integration + +Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.0 to 2.6.1. +- [Release notes](https://github.com/node-fetch/node-fetch/releases) +- [Changelog](https://github.com/node-fetch/node-fetch/blob/main/docs/CHANGELOG.md) +- [Commits](https://github.com/node-fetch/node-fetch/compare/v2.6.0...v2.6.1) + +--- +updated-dependencies: +- dependency-name: node-fetch + dependency-type: direct:development +... + +
+ +
721158f3 Bump ws from 7.3.1 to 7.4.6 in /integration + +Bumps [ws](https://github.com/websockets/ws) from 7.3.1 to 7.4.6. +- [Release notes](https://github.com/websockets/ws/releases) +- [Commits](https://github.com/websockets/ws/compare/7.3.1...7.4.6) + +--- +updated-dependencies: +- dependency-name: ws + dependency-type: direct:development +... + +
+ +
2b3b7212 Merge pull request #1594 from niko0xdev/dependabot/npm_and_yarn/integration/tar-6.1.11 + +Bump tar from 6.0.5 to 6.1.11 in /integration + +
+ +
5b43833d Merge pull request #1582 from niko0xdev/dependabot/npm_and_yarn/integration/path-parse-1.0.7 + +Bump path-parse from 1.0.6 to 1.0.7 in /integration + +
+ +
55b028ca Merge pull request #1584 from nullism/patch-1 + +Fix spaces -> tabs typo in authentication.md + +
+ +
edf630a3 Bump tar from 6.0.5 to 6.1.11 in /integration + +Bumps [tar](https://github.com/npm/node-tar) from 6.0.5 to 6.1.11. +- [Release notes](https://github.com/npm/node-tar/releases) +- [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md) +- [Commits](https://github.com/npm/node-tar/compare/v6.0.5...v6.1.11) + +--- +updated-dependencies: +- dependency-name: tar + dependency-type: indirect +... + +
+ +
29133c11 Fix spaces -> tabs typo in authentication.md + +The indentation here was supposed to be a tab rather than spaces so the readme was off. + +
+ +
01b25c55 Bump path-parse from 1.0.6 to 1.0.7 in /integration + +Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7. +- [Release notes](https://github.com/jbgutierrez/path-parse/releases) +- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) + +--- +updated-dependencies: +- dependency-name: path-parse + dependency-type: indirect +... + +
+ +
9a214e80 Merge pull request #1451 from sanjeevchopra/patch-1 + +doc only change: updated sample code for disabling introspection + +
+ +
01197437 Merge pull request #1417 from RicCu/patch-1 + +Use mutation instead of query in 'Changesets' doc example + +
+ +
e3293b53 Merge pull request #1444 from lisowskibraeden/patch-1 + +Update cors.md + +
+ +
a4d67855 Merge pull request #1517 from ShivangGoswami/patch-1 + +Update apq.md function definition mismatch + +
+ +
eb36f04f Return introspection document in stable order + +This avoids spurious changes when generating client code using +something like graphql-codegen. + +
+ +
7e38dd46 Merge pull request #1568 from DanyHenriquez/patch-1 + +Update apq.md + +
+ +
88f2b8a7 Merge pull request #1572 from talhaguy/dataloaders-doc-casing + +Correct minor casing issue + +
+ +- be9a0791 Update apq.md + +- 3e45ddc1 Correct minor casing issue + +- 145101e4 Update apq.md + +
843edd9e Update apq.md function definition mismatch + +line 67: cache, err := NewCache(cfg.RedisAddress, 24*time.Hour) +line 41: func NewCache(redisAddress string, password string,ttl time.Duration) (*Cache, error) + +either password should be removed from 41 or added in line 67 +Proposed the first one for now. + +
+ +
5ad012e3 Revert "Merge pull request #1511 from a8m/a8m/restore-cwd" + +This reverts commit f4bf1f591b6a3884041876deb64ce0dd70c3c883, reversing +changes made to 3f68ea27a1a9fea2064caf877f7e24d00aa439e6. + +Reverting this because it will break existing setups, moving where +generated files get put. + +
+ +- bb59cc43 Add a CHANGELOG.md (#1512) + +- 058a365a Merge pull request #1456 from skaji/issue-1455 + +
bf2fdf44 Merge pull request #1514 from niko0xdev/bump-gqlparser + +Bump gqlparser to v2.2.0 + +
+ +- 4e881981 Bump to gqlparser v2.2.0 + +- 1d768a29 Add test covering single element -> slice coercion + +- f57d1a02 Bump gqlparser to master & support repeated directives + +
f4bf1f59 Merge pull request #1511 from a8m/a8m/restore-cwd + +codegen/config: restore current working directory after changing it + +
+ +- 3f68ea27 Special handling for pointers to slices (#1363) + +
c920bdeb Merge pull request #1449 from steebchen/feat-prisma-compat + +feat(codegen): handle (v, ok) methods + +
+ +
3cfc5b14 codegen/config: restore current working directory after changing it + +Before this commit, a call to config.LoadConfigFromDefaultLocations changed +the working directory to the directory that contains the gqlgen config +file. + +This commit changes the implementation to restore the working directory +after loading the config. + +
+ +
35b80a72 Merge pull request #1495 from Niennienzz/improve-apq-doc + +Update apq.md + +
+ +
463debae Merge pull request #1503 from nana4gonta/resolve-vulnerability + +Resolve indirect dependency vulnerability in example + +
+ +
29e7bccb Merge pull request #1501 from niko0xdev/fix-init-1.16 + +Run go mod tidy after code generation + +
+ +
9a4c80ab Merge pull request #1502 from niko0xdev/rm-chi + +Remove chi from dataloader example + +
+ +- 5f21f9d9 Remove chi from dataloader example + +- e02db808 Run go mod tidy after code generation + +- 8c3e64e1 Improve APQ documentation + +- 03b57f3e Run go mod tidy + +- 54e387c4 Resolve indirect dependency vulnerability in example + +- 7985db44 Mention math.rand for the todo ID (#1489) + +- b995f7f1 Make spacing consistent (#1488) + +
52ded951 Merge pull request #1459 from aaronArinder/getting-started-server-section + +getting started: make running server own section + +
+ +- 82a8e1bf Make it clearer what happened on init. (#1487) + +
7258af5f Merge pull request #1458 from aaronArinder/getting-started-wording + +getting started: making the resolver fn section clearer + +
+ +
4fead489 Merge pull request #1452 from fmyd/fix/formatted-query-indent + +prettified some indentation + +
+ +
58e3225e Merge pull request #1480 from wilhelmeek/double-bubble + +Bubble Null from List Element to Nearest Nullable Ancestor + +
+ +- 1fac78e9 Add test case for nullable field + +- 469e31bd Fix bad test case + +- 635b1aef Add Test Case + +- 0b5da15c Check in generated code + +- 55b774ba Fix type ref + +- 45903a65 Handle nillable list elements + +- c4bf36c5 Add coveralls badge + +- 269a58ad Add goreportcard badge + +- 971da82c Updated gin.md + +- 41ad51ce Edited the Gin-Gonic Recipe Docs + +- 67e652ad getting started: separate example mutation/query + +- 31d339ab getting started: make running server own section + +- aa531ed8 getting started: more wording updates + +- 5b2531ae getting started: wording update + +- ada1b928 getting started: updating wording around implementing unimpl fns + +- 23eec791 go generate ./... + +
18678b15 Fix data race + +The argument of unmarshalInput may be the same for concurrent use if it pass as graphql "variables". +So we have to copy it before setting default values + +
+ +- 02b14003 fomatted query indent + +- 0e9d9c3a updated sample code for disabling introspection + +- 478c3f08 feat(codegen): handle (v, ok) methods + +
5ef5d14f Update cors.md + +I had problems reading this page and applying it to my project. With these changes it worked on my end + +
+ +
997da421 Merge pull request #1436 from ddouglas/patch-1 + +Upgrade graphql-playground to 1.7.26 + +
+ +- be4514c6 Upgrade graphql-playground to 1.7.26 + +- 918801ea Change 'Changeset' doc example to mutation + +
862762c7 Merge pull request #1409 from zikaeroh/chi-mod + +Upgrade go-chi to v1.5.1 with module support + +
+ +- c30ff3dd Upgrade go-chi to v1.5.1 with module support + +- a9c8fabf int64 support + +
b484fc27 Merge pull request #1401 from oseifrimpong/patch-1 + +fix typo + +
+ +
4cc031af Merge pull request #1394 from j2gg0s/fix-default-recover-func + +bugfix: Default Recover func should return gqlerror.Error + +
+ +
2af51336 Merge pull request #1400 from niko0xdev/sanstale + +Remove stale bot + +
+ +
34a442c7 Merge pull request #1399 from niko0xdev/prevent-possible-error-deadlock + +Dont hold error lock when calling into error presenters + +
+ +
1123ba0d Update gin.md + +Changed this: +`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: +` +to: +`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: +` + +
+ +
89a9f743 Remove stale bot + +We tried it, but it's just causing more work both for maintainers and reporters of errors. + +
+ +
4628ef84 Dont hold error lock when calling into error presenters + +This can result in a deadlock if error handling code calls GetErrors. + +
+ +- d0d5f7db bugfix: Default Recover func should return gqlerror.Error + +
18b5df19 codegen/config: Add a new API to finish an already-validated config + +LoadConfig parses the config from yaml, but it does a bunch of other +things too. We want to parse the config ourselves, so that we can have +extra fields which will be passed to our plugins. Right now, that means +we either have to duplicate all of LoadConfig, or write the config back +to disk only to ask gqlgen re-parse it. + +In this commit, I expose a new function that does all the parts of +LoadConfig other than the actual YAML-reading: that way, a caller who +wants to parse the YAML themselves (or otherwise programmatically +compute the config) can do so without having to write it back to disk. + +An alternative would be to move all this logic to Config.Init(), but +that could break existing clients. Either way would work for us. + +
+ +
0e12bfbf Merge pull request #1269 from dqn/new-line-at-the-end-of-file + +Add a new line to end of the file schema.graphqls + +
+ +
22c5d1f5 Merge pull request #1303 from kunalpowar/inline-directives-doc + +Update README.md + +
+ +
88cffee4 Merge pull request #1356 from maapteh/chore/chat-example-update + +Chore: update Chat example + +
+ +- 1e8c34e5 Dont export Input + +
de8af66c Merge pull request #1360 from Captain-K-101/master + +Update introspection.md + +
+ +- 09756915 Update introspection docs + +
651eda40 Merge pull request #1374 from rudylee/docs-file-upload-small-typo + +Fix small typo in file upload docs + +
+ +- 94252e04 singleUpload consistency + +- c9d346f5 Fix small typo in file upload docs + +- 9f851619 add uint, uint64, uint32 types in graphql + +
0625525f Update introspection.md + +updated disabling interospect + +
+ +- c6a93aa7 split layout components to their own part, makes sample more readable + +- 7904ef6f channel is switchable too + +- 13752055 add some layout for demo :) + +
82ca6e24 Create package declaration to run dataloaden + +ref: https://github.com/vektah/dataloaden/issues/35 + +
+ +- bf549136 use Apollo docs styling for the gql var uppercase + +- 36045a37 do not autofocus + +- 0502228a chore: update example to React hooks and latest Apollo client + +- e6e64224 update deps + +
3a31a752 Merge pull request #1345 from abeltay/fix-alignment + +Fix tab spacing in cors.md + +
+ +
0c68337c Merge pull request #1346 from abeltay/fix-typo + +Fix typo in migration guide + +
+ +- 436a88ad Fix typo in migration guide + +- 3791f71d Fix tab spacing in cors.md + +
819e751c Merge pull request #1341 from dgraph-io/rajas/fix-gqlgen-1299 + +Rajas/fix gqlgen 1299 + +
+ +- 789d02f5 Requested changes + +- 130ed3f7 Fix different alias with same name in inline fragment + +- f4669ba9 v0.13.0 postrelease bump + +- 07c06594 Update README.md + +- 1c9f24b2 remove triming space for schemaDefault + + + + + + +## [v0.13.0](https://github.com/niko0xdev/gqlgen/compare/v0.12.2...v0.13.0) - 2020-09-21 +- 07c1f93b release v0.13.0 + +- 259f2711 Bump to gqlparser to v2.1.0 Error unwrapping release + +
669a1668 Merge pull request #1312 from niko0xdev/error-wrapping + +Always wrap user errors + +
+ +
9b948a5f Merge pull request #1316 from skaji/is-resolver + +Add IsResolver to FieldContext + +
+ +- 77aeb477 Point latest docs to v0.12.2 + +
e821b97b Always wrap user errors (closes #1305) + +Requires use of go 1.13 error unwrapping. + +On measure I think I prefer this approach, even though it's a bigger BC break: +- There's less mutex juggling +- It has never felt right to me that we make the user deal with path when overriding the error presenter +- The default error presenter is now incredibly simple + +Questions: +- Are we comfortable with supporting 1.13 and up? +- Should we change the signature of `ErrorPresenterFunc` to `func(ctx context.Context, err *gqlerror.Error) *gqlerror.Error`? + - It always is now, and breaking BC will force users to address the requirement for `errors.As` + +
+ +
51b580de Merge pull request #1324 from bemasher/patch-1 + +Fix typos in README.md + +
+ +- 8b2a023c Fix typos in README.md + +- 3e5dd956 add test for FieldContext.IsResolver + +- 1524989b go generate + +- 55951163 add IsResolver to FieldContext + +
622316e7 Merge pull request #1295 from a-oz/a-oz-patch-1 + +Update getting-started.md + +
+ +
4c11d9fa Update getting-started.md + +fix typo + +
+ +- b4375b04 v0.12.2 postrelease bump + + + + + + +## [v0.12.2](https://github.com/niko0xdev/gqlgen/compare/v0.12.1...v0.12.2) - 2020-08-18 +- 03cebf20 release v0.12.2 + +
e3ce560d Merge pull request #1288 from alexsn/nopath-field-noerror + +avoid computing field path when getting field errors + +
+ +
108975c3 Merge pull request #1284 from dgraph-io/jatin/sameFieldSameTypeGettingIgnored + +fix same field name in two different fragments + +
+ +
eb424a22 Merge pull request #1294 from niko0xdev/fix-init + +Allow rewriter to work on empty but potentially importable packages + +
+ +- a87c54ad Allow rewriter to work on empty but potentially importable ckages + +- 8a7f3e64 clean code + +- fd0f97ce avoid computing field path when getting field errors + +- 2d59b684 ran fmt on test + +- 3a153075 ran fmt + +- defd7119 added test + +- 9fcdbcd1 fix panic test + +- 473d63c0 change name to alias + +- 849e3eac added check for object defination name + +- 08eee0fc v0.12.1 postrelease bump + + + + + + +## [v0.12.1](https://github.com/niko0xdev/gqlgen/compare/v0.12.0...v0.12.1) - 2020-08-14 +- 0d5f462b release v0.12.1 + +- e076b1b0 Regenerate test server + +- c952e0de v0.12.0 postrelease bump + + + + + + +## [v0.12.0](https://github.com/niko0xdev/gqlgen/compare/v0.11.3...v0.12.0) - 2020-08-14 +- 70302123 Version 0.12.0 + +
3b633dfa Merge pull request #1267 from ImKcat/master + +Fixed transport not support issue + +
+ +
c9a27ae3 Merge pull request #1255 from s-ichikawa/fix-object-directive-bug + +Fix bug about OBJECT directive + +
+ +
e9863af1 Merge pull request #1276 from Ghvstcode/master + +Documentation Fixes + +
+ +
04f6a691 Merge pull request #1277 from niko0xdev/direct-pointer-binding + +Support pointers in un/marshal functions + +
+ +- bef9c8bf Add comments and docs for pointer scalars + +
997efd03 Reintroduce special cast case for string enums + +This reverts commit 89960664d05f0e93ed629a22753b9e30ced2698f. + +
+ +- 8561c056 Replace awkward loop in buildTypes with recursion + +- d65b04f9 Clean up generated code + +- e1c463a4 Linting + +- 89960664 Remove unused special cast case for string enums + +- 196954bc Bind directly to pointer types when possible, instead of always binding to value types + +- 5b3d08db Update README.md + +- efd33dab Update README.md + +- f35b162f Fixed transport not support issue + +
39a12e0f Merge pull request #1134 from seriousben/fix-default-config-no-ast-sources + +Add LoadDefaultConfig to load the schema by default + +
+ +
1b23cf15 Merge pull request #1264 from niko0xdev/go-1.14 + +Target multiple go versions for CI + +
+ +- dbbda22e go 1.14 + +
ce964c1f Merge pull request #1115 from bowd/add-input-path-for-unmarshaling + +Add input path in unmarshaling errors + +
+ +- bde4291c shadow context to ensure scoped context use + +- c43990a0 Merge remote-tracking branch 'origin/master' into HEAD + +- 6be2e9df fix fileupload example + +
ad675f00 Allow custom resolver filenames using `filename_template` option (closes #1085) + +resolve merge conflicts. + +
+ +- fbfdd41c Merge pull request #1262 from sateeshpnv/gqlparser-alias (closes #1258) + +- 99fafc9f [issue #1258] explicitly add gqlparser alias to vektah/gqlparser/v2 import + +- 49291f23 fix bug in OBJECT directive + +
0fbf293f Merge pull request #1248 from sotoslammer/master + +close the connection when run returns + +
+ +
d7eabafb Merge pull request #1246 from arkhvoid/master + +Fix typo cause memory problem on upload + +
+ +- 21b223b8 Fix typo cause memory problem on upload + +- cc9c520f close the connection when run returns + +
8494028e Merge pull request #1243 from niko0xdev/nilable-nullable-unnmarshal + +Remove a bunch of unneeded nil checks from non-nullable graphql type unmarshalling + +
+ +- b81138da Add test for nillable input slice + +- 14d1a4dc Only return nil for nilable types when the graphql spec would allow it + +
3e59a10d Merge pull request #1215 from ddouglas/master + +Adding Missing Header to response + +
+ +
1650c499 Merge pull request #1242 from niko0xdev/named_map_references + +Do not use pointers on named map types + +
+ +- d11f6021 Do not use pointers on named map types + +
acaee361 Merge pull request #1121 from Khan/extern-only + +Do not require a resolver for "empty" extended types. + +
+ +
555db6d2 Merge pull request #1224 from frederikhors/patch-1 + +Indentation misprint + +
+ +- 77b37bb2 Indentation misprint + +
a3c38c65 Merge pull request #1221 from longngn/patch-1 + +Update dataloaders.md + +
+ +- 71182de8 Update dataloaders.md + +
d81baeed Merge pull request #1218 from StevenACoffman/patch-1 + +Update feature comparison for federation + +
+ +- 2c1f2345 Update feature comparison for federation (closes #5) + +- e19d43bc Adding test + +- 4a62f012 Adding ContentType header to GET request responses + +- f5de4731 Add timeout to integration test + +
a21a6633 Merge pull request #1189 from RichardLindhout/patch-1 + +Upgrade to OperationContext and remove duplicate fields to fix https:… + +
+ +
543317a2 Merge pull request #1170 from alexsn/apollotracing/nopanic + +apollotracing: skip field interceptor when on no tracing extension + +
+ +- d347d972 Update stale.yml + +
032854bb Merge pull request #1154 from gsgalloway/master + +Add operation context when dispatching + +
+ +
ccc4eb1d Merge pull request #1188 from k-yomo/update-errors-doc + +Update outdated examples in errors doc + +
+ +
628b83c1 Merge pull request #1198 from ddevault/pgp + +codegen: add PGP to common initialisms + +
+ +
d881559b Merge pull request #1202 from whereswaldon/patch-1 + +doc: fix typo in embedded struct example + +
+ +
b6ce42a7 Merge pull request #1207 from k-yomo/update-gorilla-websocket + +Update gorilla/websocket to v1.4.2 to resolve vulnerability + +
+ +- c5bfe9d3 Update gorilla/websocket to v1.4.2 to resolve vulnerability + +- 55c16e93 doc: fix typo in embedded struct example + +- 89eb1993 codegen: add PGP to common initialisms + +- 9ab7294d apollotracing: skip field interceptor when on no tracing extension + +
40570d1b Merge pull request #1163 from fwojciec/master + +fix redundant type warning + +
+ +
3f7f60bf Merge pull request #1181 from tmc/patch-1 + +Update getting-started.md + +
+ +- 6518d839 Upgrade to OperationContext and remove duplicate fields to fix https://github.com/niko0xdev/gqlgen/pull/1161 + +- 632904ad Update outdated examples in errors doc + +- 0921915d Update getting-started.md + +
0a404813 Merge pull request #1117 from s-ichikawa/object-directive + +Add support for OBJECT directive + +
+ +
90ee8ded Merge pull request #1137 from ddevault/master + +Replace ~ with א in package names + +
+ +
e4c699dc Merge pull request #1147 from ddevault/docs + +Add links to godoc to the README and docsite + +
+ +
73746621 Merge pull request #1131 from muraoka/fix-typo + +Fix typo in authentication docs + +
+ +
ace558b4 Merge pull request #1124 from OpenSourceProjects/update-apq-documentation + +Update APQ example to reflect newer API + +
+ +
3c126f9e Merge pull request #1119 from skaji/patch-1 + +type Person -> type Person struct + +
+ +- 1610039e updated generated code + +- 905e1aad fix redundant type warning + +- 39ded924 fix ctx + +- e7798ff2 insert operation context + +- 6f78c6ac Add links to godoc to the README and docsite + +- 9b823a34 Replace ~ with א in package names (closes #1136) + +- 35a90482 Add LoadDefaultConfig to load the schema by default + +- 07a5494b Fix typo in docs + +
04b120c9 Update APQ example to reflect newer API + +The example in APQ relates to the old handlers. This brings it up to +show how extensions can be used - and uses the new API for registering +plugins that come in the graph. + +The cache example now implements the graphql.Cache interface + +
+ +- 55e0f0db Check in a place where `Entity` might be nil now. + +
1ecd0749 Handle the case that all entities are "empty extend". + +In that case, there are no resolvers to write, so we shouldn't emit +any. + +
+ +- 0e2666fb Run `go fmt` + +
36b5ed83 Actually, we need to check all-external, not all-key. + +We might well be defining our own type that has only key-fields, but +if they're not external then we're the primary provider of the type + +Test plan: +go test ./plugin/federation/ + +
+ +
7e3f5844 Do not require a resolver for "empty" extended types. + +Summary: +If our schema has a field with a type defined in another service, then +we need to define an "empty extend" of that type in this service, so +this service knows what the type is like. But the graphql-server will +never ask us to actually resolve this "empty extend", so we don't +require a resolver function for it. Example: +``` + type MyType { + myvar: TypeDefinedInOtherService + } + + // Federation needs this type, but it doesn't need a resolver for + // it! graphql-server will never ask *us* to resolve a + // TypeDefinedInOtherService; it will ask the other service. + extend TypeDefinedInOtherService @key(fields: "id") { + id: ID @extends + } +``` + +Test Plan: +I manually tested this on a service (`assignments`) that we have that +fell afoul of this problem. But I had a hard time adding tests inside +gqlgen because the error happens at validation-time, and the +federation tests are not set up to go that far down the processing +path. + +Reviewers: benkraft, lizfaubell, dhruv + +Subscribers: #graphql + +Differential Revision: https://phabricator.khanacademy.org/D61883 + +
+ +- 9c80bb5b type Person -> type Person struct + +- ea210929 add test for object directive + +- 5c3812cb merge object directives to field directives + +- 8ea5ba2b Fix additional missed tests + +- 65be2a6e Run generate + +- fd615cf6 Fix linting + +- 61fa9903 Add documentation for scalad error handling + +- 1aa20f25 Add test to highlight usecase + +- d98ff1b0 Modify templates to include deeper context nesting + +
a1a02615 Merge pull request #1104 from oshalygin/docs/update-query-complexity-initialization + +Update Query Complexity Documentation + +
+ +
c68df3c6 Merge pull request #1112 from s-ichikawa/delete-unused-code + +delete unused code + +
+ +
dfb6558a run CI on PRs + +PRs from outside the org arent running CI, hopefully this fixes it. + +
+ +- 5149231c delete unused code + +
6f81ff92 Update Query Complexity Documentation + +- This pass at the documentation updates the + appropriate section regarding query complexity, + specifically in the way that the http.Handler + is created. +- The deprecated handler.GraphQL calls were replaced + with NewDefaultServer. +- Instead of passing along the fixed query complexity + as a second argument to the now deprecated handler.GraphQL + func, extension.FixedComplexityLimit is used instead. + +
+ +- f0cd7a70 update doc site to point to latest version + +- 224ff345 v0.11.3 postrelease bump + + + + + + +## [v0.11.3](https://github.com/niko0xdev/gqlgen/compare/v0.11.2...v0.11.3) - 2020-03-13 +- 4d735356 release v0.11.3 + +- 4b949f2e remove copyright notice at bottom of doc pages + +
c5039196 Merge pull request #1094 from niko0xdev/update-upload-docs + +Update file upload docs with Apollo client usage + +
+ +- 5e3cef24 revert #1079 + +
793b0672 Merge pull request #1100 from sonatard/fast + +Gnerate to fast by exec codegen.GenerateCode before plugin GenerateCode + +
+ +
6ac2d1cd Merge pull request #1097 from 86/86/update-federation-doc + +Add Enable federation section in federation doc + +
+ +- 97896eeb exec codegen.GenerateCode before plugin GenerateCode to fast + +- 44f8ba9f Update licence + +- 94701fb7 add Enable federation section in federation doc + +- 64190309 Update upload docs with Apollo usage + +- a5381191 v0.11.2 postrelease bump + + + + + + +## [v0.11.2](https://github.com/niko0xdev/gqlgen/compare/v0.11.1...v0.11.2) - 2020-03-05 +- 2ccc0aa6 release v0.11.2 + +
78f3da22 Merge pull request #1050 from technoweenie/executor + +Executor + +
+ +- b82ee517 Fix CI badge + +
42eff5a9 Merge pull request #1057 from RichardLindhout/master + +Upgrade to github.com/urfave/cli/v2 + +
+ +
bb5cb8a3 Merge pull request #1086 from niko0xdev/github-actions + +Use GitHub Actions + +
+ +- cd2b53f2 remove os.Exits + +
587bc81c Merge pull request #1074 from yudppp/feature/add_contenttype_for_upload + +Add ContentType to graphql.Upload + +
+ +- a84d6577 graphql/handler: revive the existing around func types + +- f9bb017b graphql/executor_test: ensure operation trace is started before every query + +- 57dd8d9c graphql/gqlgen: remove unnecessary convenience method + +- fb86f7b9 graphql/executor: remove the naked return + +- 9ae6bc0b graphql/executor: reinit all extension values on every Use() call + +- f3909a8a graphql/executor: make ext funcs private + +- df9e7ce3 Run CI on push only + +- ed76bc92 Update badge + +- 5a1a5446 Coveralls fixes + +- 41acc753 Fix windows line endings + +- 390cea4f Replace Appveyor with Github Actions + +- 85be072f Replace CircleCI with Github Actions + +- 8d540db3 fix: Add Upload.ContentType test + +- f21832af fix: Fixed Upload type document + +
b165568c Merge pull request #1071 from kandros/fix-server-path + +fix server path + +
+ +
9d7648aa Merge pull request #1072 from wtask/patch-1 + +Fix a typo in sql example + +
+ +
24400c9b Merge pull request #1079 from sonatard/remove-unused + +Remove unused code + +
+ +
a7c79891 Merge pull request #1081 from sonatard/fix-plugin-test + +Fix unlink file path in resolvergen test + +
+ +
e7bf7548 Merge pull request #1080 from sonatard/fix-testdata + +Fix test data + +
+ +- 3a61dc00 Fix unlink file path in resolvergen test + +- df5ac929 Fix test data + +- b2843f67 Remove unused code + +- cff73f71 Add ContentType to Upload + +
f0ebc0df Fix a typo in sql example + +I think todo is referenced to user by user_id field, not by todo.id + +
+ +- 22a43d77 fix server path + +
b788cce5 Merge pull request #1054 from niko0xdev/golint-free-resolvers + +suppress golint messages + +
+ +
c515d403 Merge pull request #1053 from RichardLindhout/patch-3 + +Add practical example of getting all the requested fields + +
+ +
e57cd445 Merge pull request #1061 from halvdan/patch-1 + +Fix mismatching documentation of Todo struct + +
+ +
1388fa94 Fix mismatching documentation of Todo struct + +Mismatch between the code and the getting started documentation. + +
+ +- 294884ad Rollback go.sum and go.mod as per feedback of [@vektah](https://github.com/vektah) + +- d8acf165 Upgrade to github.com/urfave/cli/v2 + +- 81bcbe75 suppress golint messages + +
24813079 Add practical example of getting all the requested fields + +Based on this https://github.com/niko0xdev/gqlgen/issues/954 was tagged as 'need documentation' + +
+ +
a53ce377 Merge pull request #1051 from niko0xdev/has-operation-context + +Add function to check presense of operation context + +
+ +- 95e453bf Add function to check presense of operation context + +- 36365c41 graphql/executor: move setExtensions() + +- 3acc9421 graphql/executor: ensure Executor implements graphql.GraphExecutor. + +- f89b973b graphql/executor: merge ExtensionList into Executor + +- c16a77c3 graphql/handler: replace internal executor type + +- 8fa26cec graphql/executor: extract an Executor type from graphql/handler + +- d5d780c5 Point latest docs to 0.11.1 + +- abaa0a04 v0.11.1 postrelease bump + + + + + + +## [v0.11.1](https://github.com/niko0xdev/gqlgen/compare/v0.11.0...v0.11.1) - 2020-02-19 +- 11af15a1 release v0.11.1 + +
bc07188c Merge pull request #1038 from niko0xdev/feat-check-len + +check slice length + +
+ +- 2c3853c8 fix whitespace in comparison + +
07a13861 Merge pull request #1043 from niko0xdev/ensure-panic-handlers-get-applied + +Ensure panic handlers get applied + +
+ +
156d306d Merge pull request #1046 from appleboy/patch + +docs(gin): missing import playground + +
+ +- 26ee1aa1 docs(gin): missing import playground + +- 3abe5b32 add test + +- 6ecdb88d Merge branch 'master' into feat-check-len + +- 2340f7a7 Ensure panic handlers get applied + +
25d16761 Merge pull request #1039 from VitaliiLakusta/patch-1 + +Fix link to examples directory in Federation docs + +
+ +- 4c47ad16 Fix link to examples directory in Federation docs + +- 2506dce0 check slice len + +- 1a68df34 fix origin/master reference in switcher + +- 199cfedf remove old docs that no longer run with new layout + +- 556c8484 fix paths + +- 282100c8 use current layout to build old doc content + +- 4c38b8b4 v0.11.0 postrelease bump + + + + + + +## [v0.11.0](https://github.com/niko0xdev/gqlgen/compare/v0.10.2...v0.11.0) - 2020-02-17 +- 368597aa release v0.11.0 + +
e65d6228 Merge pull request #1036 from niko0xdev/update-v011-docs + +Update 0.11 migration docs + +
+ +- 11f97936 Update 0.11 migration docs + +
2b3eed30 Merge pull request #1034 from niko0xdev/strip-underscores-from-entity-interfaces + +Trim underscores from around go identifiers + +
+ +- b2d9bfcb Update stale.yml + +- 1ac8b5ae Update stale.yml + +- 4b9dfa61 trim underscores from around go identifiers + +
7cac3610 Merge pull request #1027 from sonatard/response-errors + +propagate resolver errors to response error in ResponseMiddleware + +
+ +
14dccc57 Merge pull request #1022 from niko0xdev/feat-gqlparser-117 + +example about apply https://github.com/vektah/gqlparser/pull/117 + +
+ +- cf6f7683 bump to gqlparser v2 + +
4ece3857 Merge pull request #1028 from abhimanyusinghgaur/master + +Respect includeDeprecated for EnumValues + +
+ +- 9638ce0f Fix format + +- 51b921fa Fix format + +- 07ffcc82 Respect includeDeprecated for EnuValues + +- d58434c9 propagate resolver errors to response error in ResponseMiddleware + +- 59855925 go mod tidy + +- e4530da6 apply https://github.com/vektah/gqlparser/pull/117 + +
30e23757 Merge pull request #1020 from niko0xdev/handle-interfaces-implementing-interfaces + +Handle interfaces that implement interfaces + +
+ +- b7a58a1c Handle interfaces that implement interfaces + +
ab8d62b6 Merge pull request #1019 from niko0xdev/remove-source-reprinting + +Remove source reprinting + +
+ +- 2f0fa0ef handle schema loading error better + +- aacc9b1f Remove source reprinting + +
e289aaa0 Merge pull request #1018 from niko0xdev/federation-docs + +Federation docs and examples + +
+ +- 3045b2cf Federation docs and examples + +
656a07d1 Merge pull request #1016 from niko0xdev/federation-entity-type + +Create a non generated federation _Entity type + +
+ +- 8850a527 Create a non generated federation _Entity type + +
1d41c2eb Merge pull request #1012 from niko0xdev/federation-config + +Allow configuring the federation output file location + +
+ +
afa9a150 Merge pull request #1013 from niko0xdev/feat-error-dispatch + +propagate errors to response context in DispatchError + +
+ +- 652aa2fb propagate errors to response context in DispatchError + +
0fe1af8c Merge pull request #1011 from Khan/compound-keys + +Compound key support in federation + +
+ +- ad3c1c81 Allow configuring the federation output file location + +
b4a00e6c Merge pull request #1010 from Khan/query-exists + +Make sure there's a Query node before trying to add a field to it. + +
+ +
65401637 Adding type with multiple keys to federation test + +Summary: The current federation test schema only has types with single keys (or no keys). Adding a type with multiple keys, including one non-String key, to test compound key federation code gen. + +Test Plan: - go test + +Reviewers: csilvers, miguel + +Differential Revision: https://phabricator.khanacademy.org/D60715 + +
+ +
3f714a46 Extending federation to support compound keys per Apollo spec + +Summary: +Compound keys are not yet supported for federation in gqlgen. This diff adds support by modifying the federation plugin to handle a list of key fields on an entity rather than a single top-level key field. It will now look for "findBy..." in the resolver, rather than the original "FindBy". The federation plugin does not yet support more complicated FieldSets in the key, such as nested selections. + +References: +- Apollo federation spec: https://www.apollographql.com/docs/apollo-server/federation/federation-spec/ +- Selection sets: https://graphql.github.io/graphql-spec/draft/#sec-Selection-Sets + +Will update https://phabricator.khanacademy.org/D59469 with multiple key changes. + +Test Plan: +- Tested Go GQL services using both single- and multiple-key federated types (assignments and content-library in webapp/services) +- Ran gqlgen on non-federated services in webapp to ensure regular generation still works (donations service) +- WIP: creating unit tests; will submit as separate diff + +Reviewers: briangenisio, dhruv, csilvers, O4 go-vernors + +Reviewed By: dhruv, csilvers, O4 go-vernors + +Differential Revision: https://phabricator.khanacademy.org/D59569 + +
+ +
9f2a624b Make sure there's a Query node before trying to add a field to it. + +Federation adds some queries to the schema. There already existed +code to insert a Query node if none existed previously. But that code +was only put on addEntityToSchema(), and not the other place we update +the query, addServiceToSchema(). + +Almost always the old code was good enough, since we call +addEntityToSchema() before addServiceToSchema(). But there's on +addServiceToSchema(), so we need to do the query-existence check there +too. + +
+ +
b941b970 Merge pull request #1007 from niko0xdev/handle-invalid-autoload-path + +Give an appropriate error message when autoload isnt a valid package + +
+ +- 95b10809 bump appveyor go version for consistent behavour + +- 91a9ff97 fix bad copy from template + +- d5d6f830 Give an appropriate error message when autoload isnt a valid package + +
f7667e12 Merge pull request #1009 from niko0xdev/interface-regression + +Interface regression + +
+ +- ffc419f3 Fix interfaces used as normal object types + +- 44cfb926 Test example for interface regression + +
0ddb3ef3 Merge pull request #1006 from ravisastryk/entity-directives-lookup + +skip searching directives when entity is found + +
+ +- 395e1d73 skip searching directives when entity is found + +- e1f2282e bump to go 1.13 in ci + +
34c92eba Merge pull request #1003 from niko0xdev/fix-chat-example + +fix chat example + +
+ +- 6bf88417 fix chat example + +
8ed2ec59 Merge pull request #988 from niko0xdev/package-cache + +Cache all packages.Load calls in a central object + +
+ +- 9ccd7ed7 Cache all packages.Load calls in a central object + +
565619a8 Merge pull request #993 from niko0xdev/resolver-generator-v2 + +Resolver regenerator + +
+ +- cf4a3eb4 keep imports when scattering resolvers between files + +- da7c1e45 Update getting started docs + +- c233876e fix windows test paths + +- 93713a29 Add tests for code persistence + +- 3e507e0d separate resolver stubs by 1 empty line + +- 8a208af5 add tests covering ResolverConfig + +- f8e61961 set init to use new resolvers by default + +- dbaf355d copy through any unknown data + +- e7255580 copy old imports through before gofmt prunes + +- 6ec36504 Copy existing resolver bodies when regenerating new resolvers + +- 9e3b399d add resolver layout = follow-schema + +- 8a18895e Update to latest golangci-lint + +- f7a67722 Merge pull request #985 from Khan/no-key-needed + +
fa884991 Correctly generate a federated schema when no entity has a `[@key](https://github.com/key)`. + +Normally, when a service is taking part in graphql federation, it will +services can link to (that is, have an edge pointing to) the type that +this service provides. The previous federation code assumed that was +the case. + +types. It might seem that would mean the service is unreachable, +since there is no possibility of edges into the service, but there are +and top level Mutation edges. That is, if a service only provides a +top-level query or top-level mutation, it might not need to define a + +This commit updates the federation code to support that use case. + +
+ +
36aae4aa Merge pull request #994 from niko0xdev/feat-cache-ctx + +Add context.Context to graphql.Cache interface's methods + +
+ +
61e060bd Merge pull request #995 from alexsn/directiveroot_empty_lines + +Remove empty lines on DirectiveRoot generation + +
+ +- 30c295c4 Remove empty lines on DirectiveRoot generation + +- 85cfa8a3 Add context.Context to graphql.Cache interface's methods + +
a6c7aafb Merge pull request #931 from fridolin-koch/master + +Fix for Panic if only interfaces shall be generated + +
+ +
ec4f6b15 Merge pull request #989 from niko0xdev/fix-intermittent-test-ka-failure + +Fix intermittent websocket ka test failure + +
+ +- 76035df5 Fix intermittent websocket ka test failure + +
aa407b1f Merge pull request #979 from niko0xdev/capture-read-times + +Capture read times + +
+ +- 4dd10086 fix test race by only stubbing now where we need to + +- 8dbce3cf Capture the time spent reading requests from the client + +
c6b3e2a1 Merge pull request #983 from vikstrous/name-for-package-global + +single packages.Load for NameForPackage + +
+ +
ae79e75b Merge pull request #978 from niko0xdev/pluggable-error-code + +Allow customizing http and websocket status codes for errors + +
+ +- 7f6f1667 bump x/tools for consistent import formatting + +- 842fcc11 review feedback + +- f0bea5ff Allow customizing http and websocket status codes for errors + +- bd50bbcb single packages.Load for NameForPackage + +
28c032d1 Merge pull request #982 from DavidJFelix/patch-1 + +fix: explicitly exclude trailing comma from link + +
+ +
ac67050a fix: explicitly exclude trailing comma from link + +- this looks dumb, but when the page is rendered, the link resolves with the comma, despite the comma being excluded in github rendering. + +
+ +- 4e95b363 fix some version switcher paths + +- 08369dfe add missing trailing slash on paths + +- ea347ca7 fetch all tags + +- 8c1a8f57 fix branch switching + +- 324efc5c add origin if missing + +- cfa2907a Generate docs for all tags + +
8218c734 Merge pull request #851 from marwan-at-work/federation + +Apollo Federation MVP + +
+ +- 48dc29c1 go 1.12 generate, 1.14 failed + +- b2e81787 update gqlparse to v1.2.1 + +- d2a13d33 update go.mod + +
0eef2fe2 Merge pull request #970 from spiffyjr/master + +Fix extra trimspace on nillable Unmarshals + +
+ +
56b8eef2 Merge pull request #974 from oshalygin/docs/gqlgen-pg-example-repo + +Add Link to Sample Project with GQLGen and Postgres + +
+ +
f49936eb Add Link to Sample Project with GQLGen and Postgres + +This is a very straightforward project with numerous details in the README and the official +documentation, but questions continue to pop up around how to use this project, organize the files +and ultimately make data calls to some persistent layer. + +The `https://github.com/oshalygin/gqlgen-pg-todo-example` was built in order to show newcomers the +following: +- How to organize their graphql schema, resolvers, dataloaders and models +- How to create a new dataloader +- How to resolve with a dataloader and how to avoid some of the pitfalls(inconsistent db query to keys array order) +- How to map models from a gql schema to structs + +While the examples in this project are helpful, they could benefit from more elaborate explanations in the +code as well as the README to help newcomers get started. This PR is not intended to portray any of the examples +negatively and should not be interpreted as such. There are many findings/lessons learned from the work that folks +put together in those examples. + +README which covers a ton of the details on how to use this project: +- [README](https://github.com/oshalygin/gqlgen-pg-todo-example) + +
+ +- db499561 force rebuild + +- 0985a78e remove debug comments + +- 7f648425 add preliminary test_data + +- c9d6d94b add preliminary tests + +- 2345936e fix integration + +- aae7486d go generate + +- 555a9546 go generate + remove directives nil check + +- 368d546d Apollo Federation MVP + +- 21e0e676 Fix extra trimspace on nillable Unmarshals + +- f869f5a8 remove deprected handler call + +- f0b83cb1 fix merge conflict + +- cdf96721 update generated code + +- 21356ce3 markdown cleanup + +
412a72fe Merge pull request #885 from niko0xdev/handler-refactor + +Refactor handler package + +
+ +- bac79c54 force clean git checkout + +- dca9e4a5 Add migration docs + +
5106480b Merge pull request #947 from niko0xdev/handler-oc-handling + +always return OperationContext for postpone process + +
+ +- 922db1e3 always return OperationContext for postpone process + +- 8794f03e v0.10.2 postrelease bump + +- 14dbf1aa use new handler package in new test + +- a339a042 panic if operation context is missing when requested + +- a13a0f5f add docs on extension name conventions + +- 458fa0de Add more interface assertions + +- d0836b72 Expose APQ stats + +- cf14cf10 fix: Fix no code generation for only interfaces + +- dc76d029 Merge remote-tracking branch 'origin/master' into handler-refactor + +- 572fb419 remove all references to deprecated handler package + +- dc622346 Tune allocs for benchmarks + +- a6f94626 Merge remote-tracking branch 'origin/master' into handler-refactor + +- c3f93810 fix benchmark + +- 631b48a5 remove automatic field stat collection to reduce time calls + +- a77d9fc2 Add generated stanzas back in + +- 0ee185b8 fix duplicate header sends + +- 7cbd75db fix APQ signature + +- 67fa2104 allow extensions to declare their own stats + +- e9502ae0 Make extensions validatable + +- fc727c9c Add a signpost method to handler extension interface + +- 0a39ae20 add fixed complexity limit + +- f2ef5ec3 more deprecations and more compat + +- 2898a622 rename ResolverContext to FieldContext + +- 092ed95f collect field timing in generated code + +- 848c627c remove DirectiveMiddleware + +- 40f08868 add NewDefaultServer + +- 1b57bc3e Rename RequestContext to OperationContext + +- 3476ac44 fix linting issues + +- 479abbef update generated code + +- bc981569 Combine root handlers in ExecutableSchema into a single Exec method + +- 473a0d25 Implement bc shim for old handler package + +- 631142cf move writer all the way back to the transport + +- c7bb03a8 merge executable schema entrypoints + +- e7e913d9 Remove remains of old handler package + +- 8c5340c1 Add complexity limit plugin + +- 0965420a Add query document caching + +- aede7d1c Add multipart from transport + +- 64cfc9ad extract shared handler test server stubs + +- a70e93bc consistently name transports + +- 9d1d77e6 split context.go into 3 files + +- 72c47c98 rename result handler to response handler + +- 4a69bcd0 Bring operation middleware inline with other handler interfaces + +- ab5665ad Add result context + +- c3dbcf83 Add apollo tracing + +- f00e5fa0 use plugins instead of middleware so multiple hooks can be configured + +- a7c5e660 build middleware graph once at startup + +- 2e0c9cab mark validation and parse errors separately to execution errors + +- cb99b42e Add websocket transport + +- eed1515c Split middlware out of handler package + +- b5089cac Split transports into subpackage + +- d0f68303 port json post + +- afe241b5 port over tracing + +- 311887d6 convert APQ to middleware + +- da986181 port over the setter request context middleware + +- 249b602d Start drafting new handler interfaces + + + + + + +## [v0.10.2](https://github.com/niko0xdev/gqlgen/compare/v0.10.1...v0.10.2) - 2019-11-28 +- f276a4e6 release v0.10.2 + +
9e989d94 Merge pull request #929 from nmaquet/check-nil-interface-ptrs + +Don't crash when interface resolver returns a typed nil + +
+ +
6f20101c Merge pull request #940 from vikstrous/optional-modelgen + +make model generation optional + +
+ +
9b9dd562 Merge pull request #942 from vikstrous/disable-validation + +add skip_validation flag + +
+ +
f9f2063a Merge pull request #941 from vikstrous/qualify-package-path-faster + +shortcut QualifyPackagePath in go module mode + +
+ +- 4db0e6ec keep function private + +- c06f05b3 add doc + +- bd353b3e add skip_validation flag + +- b829628d shortcut QualifyPackagePath in go module mode + +- 3a05d2dd add mention in the docs + +- c2c2d7de make model generation optional + +
d3f63844 Merge pull request #939 from mjarkk/patch-1 + +(docs) graph-gophers now supports Struct Field resolving + +
+ +- ba3d0189 graph-gophers now supports Struct Field resolvers + +
e747d923 Merge pull request #938 from lulucas/master + +modelgen hook docs fixed + +
+ +
63be1d5e Merge pull request #1 from lulucas/modelgen-hook-patch-1 + +modelgen hook docs use plugin poitner + +
+ +
33fc16b1 modelgen hook docs use plugin poitner + +and add modelgen package to ModelBuild type + +
+ +- fcfe595e Add a comment + +
59946087 Add unit test for the interface resolver / typed nil interaction + +This added test shows that the `_Dog_species` automatically generated +resolver will crash unless the extra nil check is added in +`interface.gotpl`. + +
+ +- 201768f0 Regenerate examples + +
85ca9efe Return graphql.Null in interface resolver when passed a typed nil + +Go's dreaded _typed nil_ strikes again. Nil pointers of struct types +aren't equal to nil interface pointers. + +See https://golang.org/doc/faq#nil_error + +
+ +
15b30588 Merge pull request #894 from niko0xdev/enum-var-value-coercion + +Improve enum value (with vars) validation timing + +
+ +- 568433a2 fix ci failed + +- 0ccfc7e0 Merge branch 'master' into enum-var-value-coercion + +
9cfd817e Merge pull request #897 from mskrip/modelgen-hook + +Add possibility to hook into modelgen plugin + +
+ +- c1e64148 Merge pull request #900 from zannen/master (closes #896) + +- 8a8f0a0f Add autogenerated files (#896) + +- 531729df Move test schema file from example dir into codegen/testserver (#896) + +- 5144775f Add example to check for regression of #896 + +- 3b5df4ce Add check for obviously different TypeReferences (#896) + +- fb96756a Update generated content (#896) + +
fd201a8c Update UniquenessKey for when Element is/isn't nullable (#896) + +With a schema: +type Query { + things1: [Thing] # Note the lack of "!" +} + +type Subscription { + things2: [Thing!] # Note the "!" +} + +the UniquenessKey for the two lists is the same, which causes non-deterministic output. + +
+ +- 2a269dd3 Add modelgen hook recipe + +- 6ceb76b6 Test tag generation only by looking up extected tag strings + +
1f272d1b Add possibility to hook into modelgen plugin (closes #876) + +This change introduces option to implement custom hook for model +generation plugin without the need to completly copy the whole `modelgen` plugin. + +that can be: + +```golang +func mutateHook(b *ModelBuild) *ModelBuild { + for _, model := range b.Models { + for _, field := range model.Fields { + field.Tag += ` orm_binding:"` + model.Name + `.` + field.Name + `"` + } + } + + return b +} + +... + +func main() { + p := modelgen.Plugin { + MutateHook: mutateHook, + } + + ... +} + +``` + +
+ +
99a55da2 Merge pull request #927 from matiasanaya/feature/bind-to-embedded-interface + +Bind to embedded interface + +
+ +- 70e860cc Bind to embedded interface method + +- a745dc78 Fixes #843: Bind to embedded struct method or field + +
f80cab06 Merge pull request #923 from niko0xdev/gqlparser-1.2.0 + +Update to gqlparser-1.2.0 + +
+ +- 7508f4e5 Update to gqlparser-1.2.0 + +
7653a681 Merge pull request #916 from karthikraobr/patch-1 + +3->4 scalars + +
+ +
8faa0e3a Merge pull request #917 from colelawrence/patch-1 + +docs: Fix typo in title of "Resolvers" + +
+ +- f7d888f9 Merge branch 'master' into patch-1 + +- d722ac66 Update scalars.md + +
1172128c Merge pull request #904 from cfilby/fix-config-docs + +Minor Documentation Tweaks + +
+ +- 935f11ed Fix typo in title + +- 026d029c 3->4 scalars + +- 5eb6bef6 Fix weird indending + +- 756dcf6b Merge pull request #907 from lian-yue/patch-1 (closes #860) + +- 2a943eed Update directive.go (closes #860) + +
adbceeea Merge pull request #902 from cfilby/fix-int64-marshalling + +Add support for int64 IDs + +
+ +- 13c3d922 Update id function + +- 37191779 Add more tests + +- 0968e0cb Fix VSCode Weirdness, validate formatting + +- a20c96d5 More edits + +- e9e88b41 Stop double indending + +- 9f4df68e More minor doc fixes + +- 7abf0ac3 Fix documentation bug + +- e9730ab9 gofmt + +- c3930f57 Remove redundant paren, add test + +- 395fc85e Add support for int64 ids + +
dbc88428 Merge pull request #889 from thnt/fix-init-with-schema-arg + +fix init not use custom schema filename + +
+ +- fc4e513f add test for https://github.com/vektah/gqlparser/pull/109 + +- dd98bb13 fix init not use custom schema + +
4c35356c Merge pull request #883 from niko0xdev/handle-invalid-types + +Gracefully handle invalid types from invalid go packages + +
+ +- 25b70271 Gracefully handle invalid types from invalid go packages + +
046054db Merge pull request #882 from niko0xdev/testserver-autobind + +Use autobinding in testserver + +
+ +- 12c963a4 Use autobinding in testserver + +
305116a0 Merge pull request #879 from coderste/patch-1 + +Fixed broken GitHub link within the APQ page + +
+ +
b4867b3f Fixed broken GitHub link within the APQ page + +Small documentation change to fix a broken GitHub link. + +
+ +- 9f6b0ee4 v0.10.1 postrelease bump + + + + + + +## [v0.10.1](https://github.com/niko0xdev/gqlgen/compare/v0.10.0...v0.10.1) - 2019-09-25 +- efb6efe0 release v0.10.1 + +
955f3499 Merge pull request #877 from niko0xdev/fix-websocket-client + +Fix websocket connections on test client + +
+ +- ef24a1cc Fix websocket connections on test client + +- c997ec0c v0.10.0 postrelease bump + + + + + + +## [v0.10.0](https://github.com/niko0xdev/gqlgen/compare/v0.9.3...v0.10.0) - 2019-09-24 +- 75a83752 release v0.10.0 + +
0bc3cc86 Merge pull request #875 from niko0xdev/fix-clientwide-opts + +Fix client global options + +
+ +
b43edf5d Merge pull request #874 from niko0xdev/configurable-slice-element-pointers + +Add config option to omit pointers to slice elements + +
+ +- 921aa9cf Fix client global options + +- d0098e60 Add config option to omit pointers to slice elements + +
01893280 Merge pull request #819 from niko0xdev/fix-directive-interface-nils + +Fix directives returning nils from optional interfaces + +
+ +- 34d10975 Fix directives returning nils from optional interfaces + +
eea38e55 Merge pull request #862 from qhenkart/fixes-shareable-link-setting + +fixes shareable link button in playground + +
+ +
b5e78342 Merge pull request #870 from niko0xdev/ws-init-ctx + +Allow changing context in websocket init func + +
+ +
034aa627 Merge pull request #871 from niko0xdev/subscription-middleware + +Call middleware and directives for subscriptions + +
+ +
7b41ca3c Merge pull request #872 from niko0xdev/autobind-prefix + +Allow prefixes when using autobind + +
+ +
de8e559f Merge pull request #854 from wabain/nested-map-interface + +Fix for nested fields backed by map or interface + +
+ +
cc64f331 Merge pull request #828 from niko0xdev/feat-rc + +introduce RequestContext#Validate and use it instead of NewRequestContext function + +
+ +- ed2a8536 Allow prefixes when using autobind + +- 819cc71b Call middleware and directives for subscriptions + +- 5a7c5903 Allow changing context in websocket init func + +
17f32d28 Merge pull request #861 from niko0xdev/refactor-test-client + +Refactor test client + +
+ +
ed14cf04 Update playground.go + +fix formatting + +
+ +
ee8d7a17 Update playground.go + +fix formatting + +
+ +- 27389951 fixes shareable link button in playground + +- 4162d11e Refactor test client + +- 8ed6ffc7 Fix for nested fields backed by map or interface + +- 55b21442 Update stale.yml + +- feebee7d stalebot + +
7e643fdc Merge pull request #838 from niko0xdev/fix-directive-nil + +fix directives return nil handling + +
+ +- f33e09e8 Merge branch 'master' into fix-directive-nil + +
8590edef Merge pull request #839 from niko0xdev/fix-nil-directive + +refactor unimplemented directive handling + +
+ +- 1f7ed0d5 refactor unimplemented directive handling + +- 94ad3f2e fix directives return nil handling + +- 5c644a6f v0.9.3 postrelease bump + +- 82758be8 fix error + +- edde2d03 add OperationName field to RequestContext + +- 830e466e introduce RequestContext#Validate and use it instead of NewRequestContext function + + + + + + +## [v0.9.3](https://github.com/niko0xdev/gqlgen/compare/v0.9.2...v0.9.3) - 2019-08-16 +- a7bc468c release v0.9.3 + +
fc02cfe8 Merge pull request #829 from niko0xdev/fix-2directives + +fix go syntax issue when field has 2 directives + +
+ +
924f620c Merge pull request #831 from yudppp/patch-1 + +Fixed scalar reference documentation + +
+ +- ca4cc732 Fixed scalar documents + +- cc9fe145 fix go syntax issue when field has 2 directives + +- 6b70be03 v0.9.2 postrelease bump + + + + + + +## [v0.9.2](https://github.com/niko0xdev/gqlgen/compare/v0.9.1...v0.9.2) - 2019-08-08 +- 4eeacc6e release v0.9.2 + +
5628169d Merge pull request #822 from niko0xdev/windows-import-path-loop + +fix for windows infinite loop + +
+ +- a861aa52 lint fix + +- 6348a563 fix for windows infinite loop + +
12893fa4 Merge pull request #821 from niko0xdev/fix-init + +Fix config loading during gqlgen init + +
+ +- 5fafe79c Fix config loading during gqlgen init + +
2599f560 Merge pull request #820 from niko0xdev/keepalive-on-init + +send keepalive on init + +
+ +- 139e4e8d More directive docs + +- f93df340 send keepalive on init + +
8f0d9b48 Merge pull request #816 from nii236/patch-1 + +Update cors.md to allow CORS for websockets + +
+ +- 297e09c4 change origin check + +
410d8322 Merge pull request #805 from andrey1s/golangci + +enable-all linters on golangci-lint + +
+ +- 504a96bc set enabled linters + +- 91966ef4 add example to lint + +- bcddd7aa fix typo in readme + +- cce06f1d update lint in circleci + +
da1c208e Merge pull request #795 from oshalygin/feature/issue-794-resolve-dead-readme-link + +Update GraphQL Reference Link + +
+ +
8343c32c Merge pull request #784 from y15e/add-missing-header + +Add a missing "Upload" header + +
+ +
8302463f Merge pull request #797 from muesli/format-fixes + +Format import order using goimports + +
+ +
f2825e09 Merge pull request #801 from Schparky/patch-1 + +Documentation: getting-started edits + +
+ +
3db5627f Merge pull request #807 from flrossetto/patch-1 + +Fix doc + +
+ +- ab228f1b Update cors.md to allow CORS for websockets + +
c4ac9347 Fix doc + +map[string]{interface} -> map[string]interface{} + +
+ +- fbbed5b8 use alias when invalid pkg name + +- 2591ea36 fix lint prealloc + +- 3b0e44fe fix lint misspell + +- 6ff62b61 fix lint gocritic + +- cb7f482b fix lint unparam + +- 620552be fix lint goimports + +- 477e804e update config golangci + +- 5b203bcc clarify where the go:generate line should be added + +- 2a3df24e Replace the -v flag as described below. + +- f3eeb639 Clarify that the schema file will be generated + +- 3ac17960 Missing '*' in Todos resolver example + +- bd598c2c Format import order using goimports + +
419f966d Update GraphQL Reference Link (closes #794) + +- The link in the readme has been updated to reference a post by + Iván Corrales Solera, "Dive into GraphQL". The previous link + does not resolve, likely because the personal site is no longer + hosted. + +
+ +
373359de Merge pull request #781 from niko0xdev/fix-default-directives-init + +Set default directives after parsing config + +
+ +- ca8b21e3 Add a missing header + +- 8cab5fba Set default directives after parsing config + +
d2c5bf2a Merge pull request #780 from zdebra/master + +fixed generating a description to golang comments for enum type + +
+ +
bf2cc90e Merge pull request #768 from niko0xdev/fix-ptr-from-directive + +Fix pointer returns from directive + +
+ +- 446c3df3 fixed generating a description to golang comments for enum type + +- 414a4d34 Merge pull request #771 from sunfmin/master + +- 4d1484b0 Fix doc for how to use [@goField](https://github.com/goField) directives forceResolver option + +- 6f3d7310 Fix pointer returns from directive + +- 21b65112 v0.9.1 postrelease bump + + + + + + +## [v0.9.1](https://github.com/niko0xdev/gqlgen/compare/v0.9.0...v0.9.1) - 2019-06-27 +- b128a291 release v0.9.1 + +
1bbc0cd6 Update release process to keep tags on master + +this was affecting the version shown in go modules when using commits + +
+ +
5ffc2975 Merge pull request #764 from niko0xdev/fix-field-directives-on-roots + +fix field schema directives applied to roots + +
+ +- ef3830b5 fix field schema directives applied to roots + +
17ee40ba Merge pull request #761 from niko0xdev/autobinding + +Autobind models + +
+ +- b716bfac Autobind models + +
fc3755f1 Merge pull request #732 from niko0xdev/schemaconfig-plugin + +Add a plugin for configuring gqlgen via directives + +
+ +- c14f8650 Add docs + +- 64aca616 Merge remote-tracking branch 'origin/master' into schemaconfig-plugin + +
5e7e94c8 Merge pull request #756 from andrey1s/field + +generate field defenition and execute field directive + +
+ +
ad2ca304 Merge pull request #759 from niko0xdev/circle-workflows + +CircleCI workflows + +
+ +- 0fc822ca CircleCI workflows + +
2dc8423b Merge pull request #758 from franxois/patch-1 + +Update dataloaders.md + +
+ +
d0db28ab Update dataloaders.md + +Make SQL request use requested IDs + +
+ +- a58ecfe9 add example and test field directive + +- 526beecb update generate field + +- 6e9d7dab generate types directive by location + +- dfec7b68 define fieldDefinition template + +- be890ab9 use UnmarshalFunc in args directives implement + +- dd162f04 define implDirectives template + +
56f3f92b Merge pull request #755 from niko0xdev/fix-globbing-windows + +fix globbing on windows + +
+ +- a4480fb0 fix globbing on windows + +
ba176e2e Merge pull request #754 from niko0xdev/coveralls + +Add coveralls + +
+ +- f28ed264 Add coveralls + +
f4a69ab5 Merge pull request #744 from andrey1s/directive + +add Execute QUERY/MUTATION/SUBSCRIPTION Directives + +
+ +- dbd2cc6e simplify resolver test + +
7fed71b6 Merge pull request #728 from fgallina/make-generated-resolver-dependent-types-follow-configured-type + +resolvergen: use the resolver type as base name for dependent types + +
+ +
cb284c56 Merge pull request #734 from DBL-Lee/master + +Automatic Persisted Queries + +
+ +
726a94f4 Merge pull request #750 from niko0xdev/ws-connection-param-check + +[websocket] Add a config to reject initial connection + +
+ +- 69d7e282 move directive to directives.gotpl + +
090f0bd9 Merge pull request #722 from marwan-at-work/deps + +resolve all pkg dependencies + +
+ +- c397be0c Update websocketInitFunc to return error instead of boolean + +- be18ae1f Add a test + +- a6508b6d Update typing, function name and small code refactor + +- e6d791a9 Add websocketOnConnectFunc as a config that can be used to validate websocket init requests + +
c5acbead resolvergen: use the resolver type as base name for dependent types + +The template was outputing invalid code since the resolver type was +not used in places like the embedding at {query,mutation}Resolver. + +This change also ensures that objects like {query,mutation}Resolver +also use the user provided type name as suffix. + +Here's the resulting diff on the code generation with `type: +GeneratedResolver` in the resolver config: + +``` +diff -u resolver.go resolvernew.go +--- resolver.go 2019-05-26 20:04:15.361969755 -0300 ++++ resolvernew.go 2019-05-26 20:04:54.170737786 -0300 +@@ -7,20 +7,20 @@ + type GeneratedResolver struct{} + + func (r *GeneratedResolver) Mutation() MutationResolver { +- return &mutationResolver{r} ++ return &mutationGeneratedResolver{r} + } + func (r *GeneratedResolver) Query() QueryResolver { +- return &queryResolver{r} ++ return &queryGeneratedResolver{r} + } + +-type mutationResolver struct{ *Resolver } ++type mutationGeneratedResolver struct{ *GeneratedResolver } + +-func (r *mutationResolver) CreateTodo(ctx context.Context, input NewTodo) (*Todo, error) { ++func (r *mutationGeneratedResolver) CreateTodo(ctx context.Context, input NewTodo) (*Todo, error) { + panic("not implemented") + } + +-type queryResolver struct{ *Resolver } ++type queryGeneratedResolver struct{ *GeneratedResolver } + +-func (r *queryResolver) Todos(ctx context.Context) ([]*Todo, error) { ++func (r *queryGeneratedResolver) Todos(ctx context.Context) ([]*Todo, error) { + panic("not implemented") + } +``` + +
+ +- cfdbc39a update QueryDirectives + +- f32571ee add SUBSCRIPTION Directive + +- 32462d0f update example todo add directive with location QUERY and MUTATION + +- 3eec887a add Execute QUERY/MUTATION/SUBSCRIPTION Directives + +- 8fcc1868 format + +
e0e1e318 Merge pull request #1 from radev/master + +Support for external APQ cache + +
+ +- 9873d998 Add APQ documentation with example + +- 48292c10 Support pluggable APQ cache implementations. + +- 694f90aa Merge pull request #717 from cbelsole/schema_file_globbing (closes #631) + +- 9be5aad0 Don't inject builtins during schema config + +- 8dc17b47 support GET for apq + +- d36932c5 support automatic persisted query + +- de75743c Add plugin for providing config via schema directives + +- 17a82c37 Provide config to skip generating runtime for a directive + +
ba7092c5 Merge pull request #724 from saint1991/patch-1 + +added a missing close bracket + +
+ +- 9c1f8f2a added a missing close bracket + +- 3dd8baf5 resolve all pkg dependencies + +- 1617ff28 Merge pull request #718 from hh/fix-docs (closes #714) + +- 9d332a7d Fixing getting-started documentation + +- 39db1477 updated docs + +- e32c82be cleanup + +- e9389ef8 added schema file globbing fixes #631 + +
4f163cbc Merge pull request #713 from niko0xdev/faq + +Add faq section + +
+ +- 3a21b369 Add faq section + + + + + + +## [v0.9.0](https://github.com/niko0xdev/gqlgen/compare/v0.8.3...v0.9.0) - 2019-05-15 +- ea4652d2 release v0.9.0 + +
f3c8406d Merge pull request #710 from niko0xdev/slice-pointers + +Use pointers to structs inside slices + +
+ +- e669d476 fix imports for vendor based projects + +- 315141d9 Use pointers to structs inside slices + +
9a6a10ab Merge pull request #706 from niko0xdev/mapping-primitive + +Fix mapping object types onto go primitives + +
+ +- a5120054 fix binding to primitive non leaf types + +- b0cd95a1 Test mapping object types onto go string + +
eaa61bb5 Merge pull request #707 from niko0xdev/gomodules-performance + +make gqlgen generate 10x faster in some projects + +
+ +
ab961ce0 Merge pull request #705 from niko0xdev/fix-error-race + +Fix a data race when handling concurrent resolver errors + +
+ +- 71cc8554 make gqlgen generate 10x faster in projects with cgo + +- cab4babe Test mapping object types onto go primitives + +- 962470de Fix a data race when handling concurrent resolver errors + +
9ca43ba9 Merge pull request #701 from niko0xdev/modelgen-pointers + +Use pointers when embedding structs in generated structs + +
+ +- 4f5e9cf0 always use pointers when refering to structs in generated models + +
e2ac8480 Merge pull request #704 from tul/doc-typo + +Fix typo + +
+ +- 80ebe644 Fix typo + +
0bd90809 Merge pull request #700 from niko0xdev/fix-interface-caseing + +Fix interface casing + +
+ +
5586ee2c Merge pull request #702 from niko0xdev/drop-automatic-zeroisnull + +Drop automatic conversion of IsZero to null + +
+ +- 75aa99ad Drop automatic conversion of IsZero to null + +- 46c40b74 Fix interface casing (closes #694) + +
e49d44f7 Merge pull request #689 from tgwizard/enforce-request-content-type + +Enforce content type for POST requests + +
+ +- 78f277e9 run go generate + +- d4b3de3a Merge remote-tracking branch 'origin/master' into enforce-request-content-type + +
f8ef6d2e Merge pull request #668 from mbranch/complexity + +Fix: complexity case selection + +
+ +
c4805049 Merge pull request #655 from hantonelli/file-upload + +File upload + +
+ +- 5d1dea0a run go generate + +- 8a0c34a4 Merge branch 'master' into file-upload + +
4e359aa2 Merge pull request #686 from qhenkart/master + +Adds default custom scalar of interface{} + +
+ +- aeccbce0 Update test include an example that uses io.Read interface directly + +- d9dca642 Improve documentation + +- f30f1c31 Fix fmt + +- 54226cdb Add bytesReader to reuse read byte array + +
02e9dd8e Fix complexity case selection + +Use the GraphQL field name rather than the Go field name in the generated +`Complexity` func. + +Before this patch, overloading complexity funcs was ineffective because they +were never executed. + +It also ensures that overlapping fields are now generated; mapping all possible +field names to the associated complexity func. + +
+ +- bf2d07a4 moves naming convention to a non-go standard + +
d1e8acda Merge pull request #687 from stereosteve/fix-includeDeprecated + +Fix: omit deprecated fields when includeDeprecated=false + +
+ +- f7d0b9c8 Enforce content type for POST requests + +- 7d0b8eec Fix: omit deprecated fields when includeDeprecated=false + +- 89c87345 fix grammar in docs + +- 85643f5d fix import + +- ca96a155 update docs + +- 1de25d0c adds interface scalar type + +- 43fc53f9 Improve variable name + +- b961d34e Remove wrapper that is now not required + +- bb023476 Lint code + +- f8484159 Modify graphql.Upload to use io.ReadCloser. Change the way upload files are managed. + +
0306783e Revert "Change graphql.Upload File field to FileData." + +This reverts commit 7ade7c2 + +
+ +
afe33f73 Merge pull request #680 from asp24/collect-fields-performance + +Better CollectFields performance + +
+ +- 7ba1b3b2 graphql.CollectFields now accept *RequestContext as first arg It was done because RequestContext is a part of executionContext and can be passed directly without extraction from ctx. This is increasing performance when model depth is high + +- 5dfa2285 Pre-allocate mem for collectFields() method result slice + +- 88cdbdf1 Rename getOrCreateField to getOrCreateAndAppendField to describe behaviour + +- a74abc47 Early return in shouldIncludeNode if directives empty + +- 7ade7c21 Change graphql.Upload File field to FileData. + +- da52e810 Extend test and don't close form file. + +
1c95d42a Merge pull request #678 from jonatasbaldin/gin-context-recipe + +Fix unset key and comment block at Gin recipe docs + +
+ +- 0b39c445 Fix unset key and comment block + +
5aa6a20b Merge pull request #673 from marwan-at-work/tpl + +codegen/templates: allow templates to be passed in options instead of… + +
+ +- 37fd067e fix typo + +- e69b7399 add docs to the templates package + +
8cae895b Merge pull request #676 from jonatasbaldin/gin-context-recipe + +Add recipe to use gin.Context + +
+ +- 40c7b952 update test name + +- 5418a290 Add recipe to use gin.Context + +- 16f392ee add unit test + +- a0ee7172 codegen/templates: allow templates to be passed in options instead of os files + +- 2cf7f452 Fix comments (add request size limit, remove useless comments, improve decoding and function signature, improve documentation) + +
5ff60925 Merge pull request #665 from ezeql/patch-1 + +update README.md + +
+ +
b42e1ba6 update README.md + +fix link + +
+ +- d3770395 Fix tests. + +- 2c1f8573 Fix lint errors. + +- 73b3a536 Fmt graphql.go + +- 83cde4b6 Fix tests. Improve code format. + +- 425849a6 Improve fileupload example readme. Update scalars.md. Add file-upload.md + +- 849d4b1e Make uploadMaxMemory configurable + +- fc318364 Improve format, inline const. + +- 662dc337 Move Upload to injected if defined in the schema as scalars + +- f244442e Fix merge. Remove regexp check. + +
bf79bc92 Merge branch 'master' into next + +# Conflicts: +# codegen/config/config.go +# handler/graphql.go +# handler/graphql_test.go + +
+ +- bd4aeaa6 Merge remote-tracking branch 'upstream/master' + +- 3a6f2fb7 Improve test code + +- 239bc46f Add comments + +- be8d6d12 Improve test + +- 4d92696b Clean up code and add tests + +- 2c414edc Improve and add tests + +- 68446e17 Revert change to websocket_test + +- 61c1cb9c Improve examples + +- 493d9375 Improve examples + +- 3c5f8bb9 Improve some examples + +- db7a03b1 Improve tests and names + +- c493d1b9 Revert changing to websocket_test + +- 998f7674 Revert changing the stub file + +- a7e95c59 Fix tests. Improve file generation + +- 10beedb3 Remove not required file + +- 5afb6b40 Add file upload to default schema + +- 9c17ce33 Add file upload + +- b454621d Add support to upload files. + + + + + + +## [v0.8.3](https://github.com/niko0xdev/gqlgen/compare/v0.8.2...v0.8.3) - 2019-04-03 +- 010a79b6 release v0.8.3 + +
3623f7fc Merge pull request #650 from andcan/plugin-funcmap + +Allow plugins to provide additional template funcs + +
+ +
a2e59362 Merge pull request #652 from andrey1s/extraBuiltins + +add extra builtins types when no type exists + +
+ +
c93d92ba Merge pull request #654 from sharkyze/fix-introscpetion-doc + +doc: fix mistake on introspection doc page + +
+ +- 93e72b58 doc: fix error on introspection doc page + +
ef2e51ba Merge pull request #637 from niko0xdev/fix-is-slice + +Fix Mapping Custom Scalar to Slice + +
+ +- e5ff6bc2 add extra builtins types when no type exists + +- 8225f63a Allow plugins to provide additional template funcs + +- 7b533df1 Update ISSUE_TEMPLATE.md + +- 055157f9 Update ISSUE_TEMPLATE.md + +
a148229c Merge pull request #644 from Sauraus/master + +Fix Gin installation instruction + +
+ +
52624e53 Fix Gin installation instruction + +Current `go get gin` instruction results in an error from Go: `package gin: unrecognized import path "gin" (import path does not begin with hostname)` + +
+ +- 515f2254 Add test case for custom scalar to slice + +
2284a3eb Improve IsSlice logic to check GQL def + +Currently TypeReference.IsSlice only looks at the Go type to decide. +This should also take into account the GraphQL type as well, to cover +cases such as a scalar mapping to []byte + +
+ + + + + + +## [v0.8.2](https://github.com/niko0xdev/gqlgen/compare/v0.8.1...v0.8.2) - 2019-03-18 +- ee06517c release v0.8.2 + +
8ac8a1f8 Merge pull request #635 from niko0xdev/fix-inject-builtin-scalars + +Only Inject Builtin Scalars if Defined in Schema + +
+ +- d10e048e Add docs for built-in scalar implementations + +- d27e6eb6 Add example case for object type overriding builtin scalar + +- d567d5c8 Inject non-spec builtin values only if defined + +
3e39b57a Merge pull request #634 from niko0xdev/fallback-to-string + +Use graphql.String for types wrapping a basic string + +
+ +- a2cce0d1 Use graphql.String for types wrapping a basic string + +
fc05501b Merge pull request #633 from niko0xdev/fix-union-pointers + +Fix Having Pointers to Union Types + +
+ +- f02dabb7 Add test case for union pointer + +
8257d423 Check Go type rather than GQL type for ptr + +This is probably a more correct way to check whether we should wrap the +type in a pointer or not, rather than looking at the GrapQL definition. +There may be use-cases where a GraphQL interface/union might be mapped +to a Go stuct. + +
+ +
5df0938f Merge pull request #628 from niko0xdev/fix-ambient-imports + +Move ambient imports into cmd package + +
+ +
8e1590d7 Move ambient imports into cmd package + +The getting started docs for dep suggest creating a local gqlgen script, +however these ambient import are in the root, so dep misses them. + +This was changed in 0.8 but the ambient imports weren't moved. + +
+ +
58744de9 Merge pull request #622 from niko0xdev/handle-complexity-root-collisions + +Handle colliding fields in complexity root gracefully + +
+ +- c889b314 Handle colliding fields in complexity root gracefully + +
26c395b0 Merge pull request #620 from codyleyhan/cl/error + +Allow user to supply path to gqlerror + +
+ +- 12cf01aa Allow user to supply path to gqlerror + +
932322b6 Merge pull request #619 from niko0xdev/nil-slices + +Support returning nulls from slices + +
+ +- a48c55b2 Support returning nulls from slices + +
2b270e4d Merge pull request #618 from codyleyhan/cl/method + +Adds way to determine if a resolver is a function call or value + +
+ +- af6dc16d Add test for IsMethod in resolver + +- 27e97535 Expose IsMethod to resolver context + +- f52726de Update README.md + +
ac2422e3 Merge pull request #614 from wesovilabs/master + +Adding entry for workshop + +
+ +
db4f7255 Merge pull request #613 from icco/patch-2 + +Upgrade graphql-playground to 1.7.20 + +
+ +
163bfc76 Merge pull request #612 from niko0xdev/maps-changesets + +Maps as changesets + +
+ +- 6aa9dfc6 Adding entry for workshop + +
08f936e1 Upgrade graphql-playground to 1.7.20 + +CSS didn't change but js did. + +
+ +
8fb1fafd Merge pull request #611 from niko0xdev/gqlparser-1.1.2 + +Bump gqlparser to 1.1.2 + +
+ +- 37983a5f remove some invalid test schema + +- 765ff738 Add some docs on maps + +- 0a92ca46 Support map[string]interface{} in return types + +
ac56112b Merge pull request #610 from tgwizard/dynamic-complexity + +Allow configuring the complexity limit dynamically per request + +
+ +- a89050aa Bump gqlparser to 1.1.2 + +- dd288145 Allow configuring the complexity limit dynamically per request + +
485ddf30 Merge pull request #605 from niko0xdev/fix-default-scalars + +Fix default scalars + +
+ +
3ca2599a Merge pull request #606 from jonatasbaldin/add-gin-recipe + +Add Gin recipe + +
+ +- 386eede9 Add Gin recipe + +
22be59d1 Merge pull request #604 from cevou/arg-scalar + +Fix directives on args with custom type + +
+ +- d02736dc Added test for fix directives on args with custom type + +- 30d235bc Fix default scalars + +
d7b5dc28 Merge pull request #591 from niko0xdev/fix-577 + +Fix mixed case name handling in ToGo, ToGoPrivate + +
+ +- bef6c0a9 Fix directives on args with custom type + +- bc386d79 Fix mixed case name handling in ToGo, ToGoPrivate + + + + + + +## [v0.8.1](https://github.com/niko0xdev/gqlgen/compare/v0.8.0...v0.8.1) - 2019-03-07 +- 229185e4 release v0.8.1 + +
d872af63 Merge pull request #582 from demdxx/master + +Load the playground sources from HTTPS by default + +
+ +
8e66832f Merge pull request #589 from niko0xdev/fix-autocasing-modelgen-bugs + +Fix autocasing modelgen bugs + +
+ +- de3b7cb8 Fix autocasing modelgen bugs + +
8e00703e Merge pull request #588 from niko0xdev/fix-default-scalar-implementation-regression + +Fix default scalar implementation regression + +
+ +- b27139ed Fix default scalar implementation regression + +
737a59a3 Merge pull request #579 from niko0xdev/fix-camelcase + +Take care about commonInitialisms in ToGo + +
+ +- 52838cca fix ci + +- 2c3783f1 some refactoring + +- eb453674 address comment + +- dcd208d9 Merge pull request #584 from niko0xdev/fix-deprecated-directive + +
5ba8c8ea Add builtin flag for build directives + +These have an internal implementation and should be excluded from the +DirectiveRoot. In the future this may be a func that plugins could use +to add custom implementations. + +
+ +
b8526698 Load the playground sources from HTTPS by default + +For some browsers on non-secure domains resources from CDN doesn't loads, so I made all cdn.jsdelivr.net resources of the playground by HTTPS by default + +
+ +- 6ea48ff6 Take care about commonInitialisms in ToCamel + +
1968a7bc Merge pull request #576 from jflam/patch-1 + +Update README.md + +
+ +
44becbbe Update README.md + +Fixed typo in MD link ttps -> https + +
+ + + + + + +## [v0.8.0](https://github.com/niko0xdev/gqlgen/compare/v0.7.2...v0.8.0) - 2019-03-04 +- f24e79d0 release v0.8.0 + +
55df9b8d Merge pull request #574 from niko0xdev/next + +v0.8.0 + +
+ +
aedcc68a Merge pull request #573 from niko0xdev/plugin-docs + +Very rough first pass at plugin docs + +
+ +- 8f91cf56 Very rough first pass at plugin docs + +
3d9ad75e Merge pull request #572 from niko0xdev/handle-nonexistant-directories-when-genreating-packagenames + +Handle non-existant directories when generating default package names + +
+ +- 08923334 Handle non-existant directories when generating default package names + +
2ef4b443 Merge pull request #571 from niko0xdev/automatically-bind-to-int32-int64 + +Automatically bind to int32 and int64 + +
+ +
2888e96c Merge pull request #570 from niko0xdev/vendor-packages-workaround + +Workaround for using packages with vendored code + +
+ +- fb87dc39 Automatically bind to int32 and int64 + +
f2d9c3f7 Merge pull request #569 from niko0xdev/improve-introduction + +Introduction Improvements + +
+ +- 1e7aab63 Workaround for using packages with vendored code + +- 5c692e29 User README as canonical introduction + +- 25bdf3d6 Consolidate Introduction documents + +- d81670d8 Add initial contributing guidelines + +- d9a9a532 playground: secure CDN resources with Subresource Integrity + +
cb38b4be Merge pull request #568 from MichaelMure/secured-playground + +playground: secure CDN resources with Subresource Integrity + +
+ +
0258e1a2 Merge pull request #565 from steebchen/next + +Fix cli config getters + +
+ +- 6ad1d97e Move feature comparison + +- 37cbbd6d playground: secure CDN resources with Subresource Integrity + +- da12fd11 Fix cli config getters + +
51266b8f Merge pull request #554 from niko0xdev/fix-missing-recover + +Recover from panics in unlikly places + +
+ +- 67795c95 Recover from panics in unlikly places + +
56163b45 Merge pull request #553 from niko0xdev/getting-started-0.8 + +Update Getting Started for 0.8 and Go Modules + +
+ +- 0bd120b5 Update dep code as well + +- 6c576032 Update getting started with 0.8 generated code + +- ba761dcf Reintroduce main package in root + +- cdc575a2 Update getting started with Go Modules support + +- 378510e5 Move Getting Started above Configuration + +- d261b3fb Fix navigation font weights + +
327a1a34 Merge pull request #551 from niko0xdev/improved-collect-fields-api + +Improved Collect Fields API and Documentation + +
+ +
6439f197 Merge pull request #552 from niko0xdev/always-return-struct-pointers + +Always return *Thing from resolvers for structs + +
+ +- 318639bb Always return *Thing from resolvers for structs + +- e61b3e0b Add Field Collection docs + +
ef0223cf Merge pull request #541 from niko0xdev/fix-underscore-only-fields + +Allow underscore only fields and naming collisions to be aliased explicitly + +
+ +- 58b2c74f drive by config fix + +- f6c52666 Add a test for aliasing different cases (closes #376) + +- 8c2d15ee Fix underscore only fields (closes #473) + +- 0eb8b5c1 Merge remote-tracking branch 'origin/master' into HEAD + +
015d02eb Merge pull request #542 from Elgarni/add-more-validation-checks-on-yml-config-file + +Add more validation checks on .yml config file + +
+ +
647c62a5 Merge pull request #550 from niko0xdev/fix-unstable-marshaler-func + +Fix unstable external marshaler funcs with same name as type + +
+ +- 3a8bf33f Add CollectAllFields test cases + +- 9ebe7717 Fix unstable external marshaler funcs with same name as type + +
a1195843 Merge pull request #544 from enjoylife/fix-directive + +Fix directives on fields with custom scalars + +
+ +- dc925c46 Added a test for config checking + +- b56cb659 Refactored config check so that it runs after being normalized + +- dc6a7a36 Add CollectAllFields helper method + +
a2e61b3d Added a model and used directive on an input field within the integration schema + +Added to the integration schema such that the build will catch the directive bug in question. + +
+ +- 0b0e4a91 Fix directives on fields with custom scalars + +- 8ac0f6e4 Removed redundant semicolons + +- 3645cd3e Add more validation checks on .yml config file + +
1b8b1ea1 Fix typo in README + +Fix typo in README in selection example directory to point to the selection example, not the todo example. + +
+ +
66120d8f Merge pull request #535 from awiede/master + +Fix typo in README + +
+ +- fcacf200 Merge remote-tracking branch 'origin/master' into HEAD + +
b9819b21 Merge pull request #540 from niko0xdev/check-is-zero + +Automatically convert IsZero to null + +
+ +
03a655dc Merge pull request #526 from niko0xdev/union-fragment-bug + +Union Fragment Bug Fix + +
+ +- 99e9f41f Use Implements for type Implementors in codegen + +
ccca823f Separate out conditionals in collect fields + +These conditions are not really related, and I missed the second +conditional when reading through the first time. + +
+ +- efe8b026 Add reproducable test cases + +- 306da15f Automatically convert IsZero to null + +- f81c61d3 Merge pull request #539 from niko0xdev/test-nullable-interface-pointers (closes #484) + +
f5200c80 Merge pull request #498 from vilterp/playground-content-type + +add `content-type: text/html` header to playground handler + +
+ +- de148d13 Test for #484 + +- 9a48a007 Merge pull request #538 from niko0xdev/test-input-marshalling (closes #487) + +- 7a82ab43 Test for #487 + +
48a7e07f Merge pull request #537 from niko0xdev/stub-generation + +Stub generation + +
+ +- 787b38d8 Break testserver tests down into smaller files using stubs + +- c5e3dd44 add stub generation plugin + +
43db679a Merge pull request #534 from niko0xdev/multiple-bind-types + +Multiple bind types + +
+ +- b26b915e Move input validation into gqlparser see https://github.com/vektah/gqlparser/pull/96 + +
7d394222 Fix typo in README + +Fix typo in README in selection example directory to point to the selection example, not the todo example. + +
+ +- 42131868 Linting fixes + +- 956d0306 Arg type binding + +- 6af3d85d Allow multiple field bind types + +- 3015624b Regen dataloader with correct version + +- 50f7d9c8 Add input field directives back in + +- 8047b82a Fix nullability checks in new marshalling + +- b3f139c9 Cleanup field/method bind code + +- cf94d3ba Removed named types + +
82ded321 Merge pull request #532 from niko0xdev/fix-missing-json-content-type + +Fix set header to JSON earlier in GraphQL response + +Update the GraphQL handler to set the Response Header to JSON earlier for +error messages to be returned as JSON and not text/html. + +Fixes https://github.com/niko0xdev/gqlgen/issues/519 + +## Notes: +- Add checks for JSON Content-Type checks in decode bad queries tests + +
+ +
b4c5a074 Fix set header to JSON earlier in GraphQL response + +Update the GraphQL handler to set the Response Header to JSON earlier for +error messages to be returned as JSON and not text/html. + +Fixes https://github.com/niko0xdev/gqlgen/issues/519 + +== Notes: +- Add checks for JSON Content-Type checks in decode bad queries tests + +
+ +- 533b08b6 remove wonky input directives + +- 60473555 Shared arg unmarshaling logic + +
a7c8abe6 Merge pull request #529 from niko0xdev/websocket-keepalive + +Add websocket keepalive support + +
+ +- 555d7468 Remove TypeDefinition from interface building + +- cfa012de Enable websocket connection keepalive by default + +
c5b9b5a8 Use constant tick rate for websocket keepalive + +Some clients (e.g. apollographql/subscriptions-transport-ws) expect a +constant tick rate for the keepalive, not just a keepalive after x +duration of inactivity. + +
+ +- 693753fc Add websocket keepalive support + +- 162afad7 enums dont exist in runtime + +
d0b6485b Merge pull request #525 from niko0xdev/stop-grc-panic + +Stop GetResolverContext from panicking when missing + +
+ +
78cfff48 Merge pull request #528 from niko0xdev/fix-todo-directive + +Fix Todo Example Directive + +
+ +
5e1bcfaf Remove parent check in directive + +This should always be true, and currently has a bug when comparing +pointers to structs. Can just be removed. + +
+ +- c1b50cec Stop GetResolverContext from panicking when missing + +- 44aabbd3 Move all build steps back into file containing defs + +- 4e49d489 Merge object build and bind + +- 97764aec move generated gotpl to top + +- d380eccf promote args partial to full template + +- 1bc51010 Everything is a plugin + +
055fb4bc Merge pull request #514 from niko0xdev/gomod + +Add support for go modules + +
+ +- 48eb6c52 Update appveyor + +- 9e02a977 fix integration test + +- 251e8514 Add support for go modules + +
62175eab Merge pull request #502 from niko0xdev/model-plugin + +Model plugin + +
+ +- 0f884493 linting fixes + +- c6eb1a85 Extract model generation into a plugin + +
d3f1195c add `content-type: text/html` header to playground handler + +This ensures that the browser doesn't think it should download the page +instead of rendering it, if the handler goes through a gzipping +middleware. + +
+ +
f94b4b78 Merge pull request #497 from azavorotnii/small_fixes + +Small fixes + +
+ +- 21769d93 Ensure no side affect from preceding tests in wont_leak_goroutines test + +- 10f4ccde newRequestContext: remove redundant else part + +- a76e0228 Add cache usage for websocket connection + +- 940db1f9 Fix cacheSize usage in handler + +
fba9a378 Merge pull request #492 from niko0xdev/unified-merge-pass + +Unified merge pass + +
+ +- a7f719a3 update appveyour to not rely on main + +- f46b7c8e Reclaim main package for public interface to code generator + +- 6b829037 Extract builder object + +- 87b37b0c Replace string based type comparisons with recursive types.Type check + +
82b1917d Merge pull request #490 from niko0xdev/bind-directly-to-types + +Bind directly to AST types, instead of copying out random bits + +
+ +- 1d86f988 extract argument construction + +- 4b85d1b0 Merge buildInput into buildObject + +- db33d7b7 Extract graphql go merge into its own package + +- afc773b1 Use ast definition directly, instead of copying + +- 8298acb0 bind to types.Types in field / arg references too + +- 38add2c2 Remove definition embedding, use normal field instead + +- 950ff42c Bind to types.Type directly to remove TypeImplementation + +- 70c852eb Add lookup by go type to import collection + +- eb101161 Remove aliased types, to be replaced by allowing multiple backing types + +
e79252b0 Merge pull request #488 from niko0xdev/refactor-config + +Refactor config + +
+ +- 4138a372 rename generator receiver + +- bec38c7e Extract config into its own package + +- 34b87871 Rename core types to have clearer meanings + +- f10fc649 Merge remote-tracking branch 'origin/next' into HEAD + +
dd972081 Merge pull request #486 from nicovogelaar/feature/list-of-enums + +add list of enums + +
+ +- 1140dd85 add unit test for list of enums + +- 1e3e5e9b add list of enums + +- f87ea6e8 Merge remote-tracking branch 'origin/master' into HEAD + +
473f4f0c Merge pull request #465 from niko0xdev/performance-improvments + +Performance improvments + +
+ +- f9ee6ce0 return arg in middleware + +
5c8b1e24 Avoid unnessicary goroutines + +goos: linux +goarch: amd64 +pkg: github.com/niko0xdev/gqlgen/example/starwars +BenchmarkSimpleQueryNoArgs-8 300000 25093 ns/op 6453 B/op 114 allocs/op +PASS +ok github.com/niko0xdev/gqlgen/example/starwars 10.807s + +
+ +
b0ffa22a Remove strconv.Quote call in hot path to avoid some allocs + +go test -benchtime=5s -bench=. -benchmem +goos: linux +goarch: amd64 +pkg: github.com/niko0xdev/gqlgen/example/starwars +BenchmarkSimpleQueryNoArgs-8 200000 32125 ns/op 6277 B/op 118 allocs/op +PASS +ok github.com/niko0xdev/gqlgen/example/starwars 9.768s + +
+ +
2cf5a5b8 Add a benchmark + +go test -benchtime=5s -bench=. -benchmem +goos: linux +goarch: amd64 +pkg: github.com/niko0xdev/gqlgen/example/starwars +BenchmarkSimpleQueryNoArgs-8 200000 32680 ns/op 6357 B/op 126 allocs/op +PASS +ok github.com/niko0xdev/gqlgen/example/starwars 9.901s + +
+ +- 5e0456fe fix fmt anf metalint generated code + +- b32ebe14 check nullable value for go1.10 + +- d586bb61 use arg value for the ResolveArgs + +- e201bcb5 set default nil arg to ResolverContext + +- 6fa63640 remove empty line in generated files + +- 139ed9fb fix go10 assign exist variable by eq + +- 428c6300 add nullable argument to directives + +- 74096033 move chainFieldMiddleware to generate code for BC + +- be51904c check nullable arguments + +- 6b005094 add test directives generate + +- 047f2ebc update inline template + +- a13b31e9 metalinter + +- 526bef0b generate servers and add path to error + +- 29770d64 resolve = in template + +- 3a729cc3 update recursive middleware + +- 8b3e634e update tempate and set Dump public + +- e268bb75 Merge remote-tracking branch 'upstream/master' into directives + +- e8f0578d add execute ARGUMENT_DEFINITION and INPUT_FIELD_DEFINITION directive + + + + + + +## [v0.7.2](https://github.com/niko0xdev/gqlgen/compare/v0.7.1...v0.7.2) - 2019-02-05 +- da1e07f5 release v0.7.2 + +
8c0562c1 Merge pull request #530 from niko0xdev/websocket-keepalive-master + +Add websocket keepalive support + +
+ +- 43fdb7da Suppress staticcheck lint check on circleci + +
9c4b877a Use constant tick rate for websocket keepalive + +Some clients (e.g. apollographql/subscriptions-transport-ws) expect a +constant tick rate for the keepalive, not just a keepalive after x +duration of inactivity. + +
+ +- d36d3dc5 Add websocket keepalive support + +
39216361 Merge pull request #476 from svanburen/patch-1 + +Update config.md + +
+ +
9f6f2bb8 Update config.md + +Add a missed word and add an apostrophe + +
+ +- c033f5fc Fix edit link positioning + +- b3f163d8 Add not about relative generate path + +- 675ba773 Update errors.md + +
5c870a48 Merge pull request #461 from ryota548/patch-1 + +Update getting-started.md + +
+ +
9bcd27c1 Update getting-started.md + +modify `graph/graph.go` to `resolver.go` + +
+ + + + + + +## [v0.7.1](https://github.com/niko0xdev/gqlgen/compare/v0.7.0...v0.7.1) - 2018-11-29 +
3a7f37c7 Merge pull request #455 from niko0xdev/fix-deprecated-fields + +Fix deprecated fields + +
+ +- b365333b Fix graphiql deprecating all fields + +- 99610be9 Get chat example up to date + + + + + + +## [v0.7.0](https://github.com/niko0xdev/gqlgen/compare/v0.6.0...v0.7.0) - 2018-11-28 +- a81fe503 release v0.7.0 + +
4bfc82d7 Merge pull request #453 from niko0xdev/deprecate-binary + +Add Deprecation Warning to Binary + +
+ +
8dd29b85 Merge pull request #454 from niko0xdev/update-gqlparser + +Update gqlparser to latest + +
+ +- 747c3f9c Update gqlparser to latest + +
d6d9885f Merge pull request #416 from niko0xdev/improved-getting-started + +Improve Getting Started Documentation — No Binary Approach + +
+ +- d22f03c6 Add deprecation warning + +- 878f3945 Minor fixes to getting started code examples + +
6a02657c Merge pull request #447 from niko0xdev/disable-introspection + +Add config option to disable introspection + +
+ +- b9fbb642 Mention recursive-ness of generate ./... + +- e236d8f3 Remove generate command from resolver.go + +- 04a72430 Re-add final touches section to getting started + +- 3a7a5062 Add handler import to root cmd + +- 9dba96d5 Fix GraphQL capitalisation + +- 1dfaf637 Minor updates to getting started from feedback + +- 94b95d97 Some CSS fixes + +- a36fffd2 Updated getting started with new no-binary approach + +- 601354b3 Add blockquote breakout style + +
6bea1d88 Merge remote-tracking branch 'origin/master' into disable-introspection + +Regenerate + +
+ +
e4bad0e6 Merge pull request #449 from niko0xdev/increase-float-precision + +Increase float precision + +
+ +
c5589792 Merge pull request #450 from niko0xdev/import-refactor + +Refactor import handling + +
+ +- 62f0d085 Edit copy for introspection docs + +
63fc2753 Merge pull request #452 from cemremengu/patch-1 + +Fix typo in directives.md + +
+ +
da31e8ed Update directives.md + +Fix small typo + +
+ +- 83e33c13 Remove a debug print + +- 6c575914 fix doc indentation + +- f03b32d3 Use new import handling code + +- c45546e5 Increase float precision + +- 77f2e284 Start moving import management to templates + +- c114346d Decouple loader creation from schema + +
9d636e78 Merge pull request #448 from niko0xdev/update-gqlparser + +Update to latest gqlparser + +
+ +- d6ce42df Update to latest gqlparser + +- b0acd078 Add config option to disable introspection + +
f9c880b6 Merge pull request #446 from niko0xdev/fix-flakey-test + +Fix flakey goroutine test + +
+ +
5461e967 Merge pull request #445 from niko0xdev/remove-graphqlgen + +Remove graphqlgen link + +
+ +- 8a5039d8 Fix flakey goroutine test + +
4b082518 Merge pull request #439 from snormore/pointer-slice + +Fix type binding validation for slices of pointers like []*foo + +
+ +- 293b9eaf Remove graphqlgen link + +
77b27884 Merge pull request #443 from mgutz/patch-1 + +fix generate stubs sentence + +
+ +- ae1c7732 fix generate stubs sentence + +- 827dac5e Fix type binding validation for slices of pointers like []*foo + +
f7932b40 Merge pull request #435 from matiasanaya/update-readme + +Update README.md comparison with graph-gophers + +
+ +- a816208b Update README.md comparison with graph-gophers + +
d25e3b4b Merge pull request #422 from gracenoah/model-method-context + +accept an optional ctx parameter on model methods + +
+ +
0ac6fa57 Merge pull request #434 from urakozz/patch-1 + +Tracer: fixed nil pointer issue + +
+ +- d4f7c954 Update context.go + +
4c4ccf47 Update context.go + +Right now code generated with latest master fails since there are usages of Trace but there is no any single write to this variable + +
+ +- 5faf3a2b re-generate + +- 6fed8947 rebase fixes + +- 4c10ba55 fix generated code + +- 8066edb7 add tests + +- 9862c30f mention contexts on model methods in docs + +- 602a83d6 make ctx method resolvers concurrent + +- 49755120 accept an optional ctx parameter on model methods + +
02a19352 Merge pull request #429 from niko0xdev/refactor-gofmt + +apply go fmt ./... + +
+ +- 6a77af13 apply gofmt on ./.circleci/test.sh + +- c656dc31 apply go fmt ./... + +
3f598bdc Merge pull request #427 from anurag/patch-1 + +Fix docs typo + +
+ +- cac61bb2 Fix docs typo + +
9f4afe3a Merge pull request #425 from niko0xdev/render + +Switch to hosting docs on render.com + +
+ +
9875e74b Switch to hosting docs on render.com + +Render.com has offered to host our static site for free, and have +a pretty simple setup for rebuilding on merge to master. I've +switched the DNS records and updated the docs. + +
+ +
981fd10a Merge pull request #419 from niko0xdev/fix-capture-ctx + +fix unexpected ctx variable capture on Tracing + +
+ +- 027803d2 address comment + +- 2b090de9 address comment + +- d3238d54 chore + +- a2c33f13 write ctx behavior test & refactoring tracer test + +- 5c28d011 fix unexpected ctx variable capture on Tracing + +
4bda3bc1 Merge pull request #411 from niko0xdev/feat-geterrors + +add GetErrors to RequestContext + +
+ +- a4eaa400 add tests for RequestContext#GetErrors + +
53f33f77 Merge pull request #410 from niko0xdev/move-tracing-to-contrib + +Move tracing to contrib + +
+ +- 19403832 add GetErrors to RequestContext + +- f0dbce5a Move tracing to contrib + +
a3a92775 Merge pull request #409 from niko0xdev/graphql-playground-1.7.8 + +Bump to the latest version of graphql-playground + +
+ +
d2648580 Merge pull request #402 from niko0xdev/feat-opencensus + +add Tracer for OpenCensus + +
+ +- 7286e244 fix shadowing + +- af38cc5a Bump to the latest version of graphql-playground + +- 8bbb5eb7 fix some tests + +- 256e741f add complexityLimit and operationComplexity to StartOperationExecution + +- 4e7e6a1c Merge branch 'master' into feat-opencensus + +
926ad17a Merge pull request #403 from niko0xdev/feat-complexity + +copy complexity to RequestContext + +
+ +- 2d3026cb Merge branch 'master' into feat-complexity + +- 59ef91ad merge master + +- c9368904 Merge branch 'master' into feat-opencensus + +
b26ee6b4 Merge pull request #404 from niko0xdev/feat-apollo-tracing + +add apollo-tracing support + +
+ +- fd4f5587 fix timing issue + +- 91e3e88d address comment + +- a905efa8 fix lint warning + +- b2ba5f86 address comment + +- 561be1c0 add Apollo Tracing sample implementation + +- 83c7b2cb add Start/EndOperationParsing & Start/EndOperationValidation methods to Tracer + +- b5305d75 address comment + +- 784dc01f oops... + +- a027ac21 copy complexity to RequestContext + +- ececa23c add Tracer for OpenCensus + +
0d5c65b6 Merge pull request #400 from niko0xdev/fix-ci + +fix Circle CI test + +
+ +- 00d11794 add mutex to logger + +- 884d35c6 fix race condition + +- f70cedc2 fix Circle CI test + +
1b17b5a2 Merge pull request #392 from niko0xdev/feat-tracer + +Add Tracer layer + +
+ +
184e48cb Merge pull request #396 from niko0xdev/remove-ci-exclusion + +Run generate ./... and test ./... in circle + +
+ +
fd5d9eca Merge pull request #395 from niko0xdev/feat-extension-example + +add Type System Extension syntax example + +
+ +- 686c71a4 Run generate ./... and test ./... in circle + +- 304d3495 fix https://github.com/niko0xdev/gqlgen + +- 85322586 address comment + +
195f952b fix CI failed + +AppVeyor handle this test, But Circle CI is not + +
+ +- b5b767c4 address comment + +- d723844b add Type System Extension syntax example + +- df685ef7 change timing of EndFieldExecution calling + +- 94b7ab02 refactor Tracer interface signature that fit to apollo-tracing specs + +
8eb2675a Revert "change field marshaler return process that make it easy to insert other processing" + +This reverts commit 583f98047f5d1b6604d87e7b8d6f8fd38082d459. + +
+ +- c8af48cd rename Tracer method name + +- a3060e80 refactor Tracer signature + +- d319afe6 add support request level tracer + +- 1c5aedde add support field level tracer + +- 583f9804 change field marshaler return process that make it easy to insert other processing + +- ab4752c2 Update README.md + +
3447dd2d Merge pull request #389 from niko0xdev/multiple-schemas + +Support multiple schemas + +
+ +- a230eb04 Support multiple schemas + +
20a5b6c7 Merge pull request #369 from vetcher/master + +reverse errors and data order in response + +
+ +- f1f043b9 reverse 'data' and 'error' fields order in failure tests + +
3eab22a3 Merge pull request #370 from rodrigo-brito/fix-underscore + +Underscore on field name finder + +
+ +- 0ad3d3ce fix on struct name finder + +- 42e11045 reverse errors and data order in response + + + + + + +## [v0.6.0](https://github.com/niko0xdev/gqlgen/compare/v0.5.1...v0.6.0) - 2018-10-03 +- 6f486bde release v0.6.0 + +
7833d0cb Merge pull request #365 from niko0xdev/dont-guess-imports + +Don't let goimports guess import paths + +
+ +- 732be395 Don't let goimports guess import paths + +
926eb9d8 Merge pull request #364 from niko0xdev/query-cache-test + +Add a stress test on query cache + +
+ +- bab70df5 Add a stress test on query cache + +
84481761 Merge pull request #362 from niko0xdev/fix-error-docs + +fix error docs + +
+ +- 23b58f6d fix error docs + +
8f0ef777 Merge pull request #361 from niko0xdev/revert-360-revert-335-typed-interfaces + +Revert "Revert "Generate typed interfaces for gql interfaces & unions"" + +
+ +- 77257d1e Revert "Revert "Generate typed interfaces for gql interfaces & unions"" + +
1cae19bb Merge pull request #359 from niko0xdev/fix-null-arg-error + +Fix Issue With Argument Pointer Type + +
+ +
ee862717 Merge pull request #360 from niko0xdev/revert-335-typed-interfaces + +Revert "Generate typed interfaces for gql interfaces & unions" + +
+ +- 02658647 Revert "Generate typed interfaces for gql interfaces & unions" + +
bc35d730 Merge pull request #335 from niko0xdev/typed-interfaces + +Generate typed interfaces for gql interfaces & unions + +
+ +- 48724dea Removed redundant file + +- 2432ab3c Fix other tests with pointer change + +- 20add126 Fix test case + +
f5c03401 Do not strip ptr for args with defaults + +This fails if a client still sends a null value. If an arg is nullable +but has a default, then null is still a valid value to send through. + +
+ +- 0c399270 Add test case + +
b836a976 Merge pull request #358 from niko0xdev/fix-embedded-pointer + +Fix Embedded Pointer + +
+ +- d3e27553 Bump gqlparser to latest master + +- b8af0c81 Use types.Implements to check if an interface implementor accepts value recievers + +
2ab05daf Merge pull request #353 from niko0xdev/resolver-ctx-parenting + +Parent middleware generated contexts + +
+ +- faf0416b Parent resolver generated contexts + +- caa474c6 Check for embedded pointer when finding field on struct + +- f302b408 Added reproduce test case + +
14cf46bc Merge pull request #348 from gissleh/feat-websocket-initpayload + +Added parsing of the websocket init message payload + +
+ +- 3147d914 Updated example in docs to use handler.GetInitPayload instead of graphql.GetInitPayload + +- 32f0b843 Moved InitPayload from graphql to handler package, updated test to import it from there. + +- 01923de6 Moved initPayload to wsConnection member, changed wsConnection.init to return false on invalid payload + +- 25268ef9 Added information about it under recipes/authentication doc + +- 575f28e0 Fixed graphql.GetInitPayload panic if payload is nil. + +
380828fa Added parsing of the websocket init message payload, and making it available via the context passed to resolvers. + +* Added GetInitPayload(ctx) function to graphql +* Added WithInitPayload(ctx) function to graphql +* Added WebsocketWithPayload method to client.Client (Websocket calls it with a nil payload for backwards compability) +* Added tests for these changes in codegen/testserver/generated_test + +
+ +
2bd1cc2e Merge pull request #334 from niko0xdev/support-response-extensions + +Support Extensions in Response + +
+ +- 8fdf4fbb Add test case for extension response + +- 60196b87 Add extensions to response struct + +- cbde0ea9 Generate typed interfaces for gql interfaces & unions + + + + + + +## [v0.5.1](https://github.com/niko0xdev/gqlgen/compare/v0.5.0...v0.5.1) - 2018-09-13 +- 636435b6 release v0.5.1 + +- bfb48f2f Update README.md + +
869215a7 Merge pull request #339 from niko0xdev/fix-subscription-goroutine-leak + +Fix gouroutine leak when using subscriptions + +
+ +
535dd24b Merge pull request #338 from codyleyhan/cl/docs + +Adds docs for how resolvers are bound + +
+ +- baa99fc5 cleaned up resolver doc + +
647fbbc9 Merge pull request #340 from chris-ramon/patch-1 + +README.md: Updates `graphql-go/graphql` features. + +
+ +
729e09c8 README.md: Updates `graphql-go/graphql` features. + +- Subscription support: https://github.com/graphql-go/graphql/issues/49#issuecomment-404909227 +- Concurrency support: https://github.com/graphql-go/graphql/issues/389 +- Dataloading support: https://github.com/graphql-go/graphql/pull/388 + +
+ +- 229a81be Fix gouroutine leak when using subscriptions + +- c15a70ff Adds docs for how resolvers are bound + +- 35c15c94 Add link to talk by Christopher Biscardi + +
72edf98a Merge pull request #331 from edsrzf/arg-refactor + +Refactor arg codegen + +
+ +- 31505ff4 Use arg function for generated Complexity method + +- ebdbeba0 Just realized "if not" is allow in templates + +- 861a805c Regenerate code + +
639727b6 Refactor arg codegen + +Now a function is generated for each field and directive that has +arguments. This function can be used by both field methods as well as +the `Complexity` method. + +The `args.gotpl` template now generates the code for this function, so +its purpose is a little different than it used to be. + +
+ +
8026e63b Merge pull request #330 from edsrzf/string-compare + +Use built-in less than operator instead of strings.Compare + +
+ +- c770b4e7 Use built-in less than operator instead of strings.Compare + + + + + + +## [v0.5.0](https://github.com/niko0xdev/gqlgen/compare/v0.4.4...v0.5.0) - 2018-08-31 +- 5bc4665f release v0.5.0 + +
b48c6b92 Merge pull request #326 from niko0xdev/version + +Add version const + +
+ +- 14587a5f Add version const + +
7d44dd6b Merge pull request #315 from edsrzf/query-complexity + +Query complexity calculation and limits + +
+ +- 2ab857ee Merge branch 'master' into query-complexity + +- 6e408d5d Interfaces take max complexity of implementors + +
d08b9c4a Merge pull request #325 from edsrzf/no-get-mutations + +Only allow query operations on GET requests + +
+ +
82a28b57 Only allow query operations on GET requests (closes #317) + +This mitigates the risk of CSRF attacks. + +
+ +- 239b1d22 Don't emit complexity fields for reserved objects + +- 8da5d61b Generate complexity for all fields. Fix bugs. Re-generate examples. + +
40943c6d Merge pull request #322 from niko0xdev/drop-old-flags + +Drop old cli flags + +
+ +
8c17eea9 Merge pull request #320 from andrioid/master + +Description added to generated Model code + +
+ +
988b367a Merge pull request #316 from niko0xdev/feat-concurrent-each-element + +use goroutine about processing each array elements + +
+ +- e5265ac2 Fix complexity template bug + +- 7c040045 now with field values + +- 08ab33be starting to look better + +- e834f6b9 Query complexity docs + +- a0158a4e Drop old cli flags + +- bb78d2fa go generate ./.. + +- 2488e1b3 Merge branch 'master' of https://github.com/niko0xdev/gqlgen + +
f6a733ae Merge pull request #308 from codyleyhan/tags + +Finds fields by configurable struct tag + +
+ +
f7aeb88a Merge pull request #321 from niko0xdev/remove-typemap + +Remove support for the old json typemap + +
+ +- d63449b9 Remove support for the old json typemap + +- fce4c722 address comment + +- 8c3aed7d Merge branch 'master' into query-complexity + +
cecd84c6 Add complexity package tests + +Also some small behavior fixes to complexity calculations. + +
+ +
002ea476 Merge pull request #318 from edsrzf/query-cache + +Add query cache + +
+ +- fcd700b6 Panic on lru cache creation error + +
78c57079 Add query cache + +This commit adds a query cache with a configurable maximum size. +Past this size, queries are evicted from the cache on an LRU basis. + +The default cache size is 1000, chosen fairly arbitrarily. If the size +is configured with a non-positive value, then the cache is disabled. + +Also ran `dep ensure` to add the new dependency to `Gopkg.lock`. + +
+ +- 076f9eac removed dirt + +- 6ae82383 trying to get description with generated models + +- 7d6f8ed4 fixes case where embeded structs would cause no field to be found + +- 02873495 use goroutine about processing each array elements + +- 40f904a6 Merge branch 'master' of github.com:niko0xdev/gqlgen into tags + +- 56768d6b adds tests for findField + +- 556b93ac Run go generate ./... + +
2dcb2dd8 Merge pull request #314 from niko0xdev/directive-obj + +Add obj to Directives + +
+ +- 0e2aaa9e Merge branch 'master' of github.com:niko0xdev/gqlgen into tags + +- 7cfd9772 fixes field selection priority + +- 238a7e2f Add complexity support to codegen, handler + +- 95ed529b New complexity package + +- 1fda3ede Add obj to Directives + +
9b247102 Merge pull request #301 from niko0xdev/feat-directive-parent + +add Result field to ResolverContext + +
+ +- 9ec385d1 Merge branch 'tags' of github.com:codyleyhan/gqlgen into tags + +- c5849929 adds binding by passed tag + +- 6ef2035b refactor set Result timing + +- 568a72e9 add some refactor + +
50588a8a Merge pull request #299 from niko0xdev/test-init-on-windows + +Test gqlgen init on windows + +
+ +- 9148adfc Test gqlgen init on windows + +- c7fd8416 Merge branch 'master' into feat-directive-parent + +
3f8a601b Merge pull request #312 from niko0xdev/validate-gopath + +Validate gopath when running gqlgen + +
+ +
77e69552 Merge pull request #310 from niko0xdev/sitemap-404s + +Remove 404s from sitemap + +
+ +
0b6cedfb Merge pull request #311 from jekaspekas/fix-mapstructure-err + +fix mapstructure unit test error + +
+ +- b07736ef Validate gopath when running gqlgen + +
b082227d fix mapstructure unit test error + +fix unit test error "mapstructure: result must be a pointer". It appears instead of resolver returned error. + +
+ +- 25b12cb6 Remove 404s from sitemap + +
4a6f505d Merge pull request #309 from niko0xdev/pr-template + +Add a PR template + +
+ +- 64f3518e run generate + +- a81147df Add a PR template + +- 15d8d4ad Merge branch 'introspection-directive-args' into HEAD + +- 12efa2d5 add tests + +- 95b6f323 finds fields by json struct tag + +- 07ee49f3 Added args to introspection scheme directives. + +- e57464fe refactor ResolverContext#indicies and suppress lint error + +- 09e4bf8c add Result field instead of ParentObject field + +
b8695fb5 Merge pull request #304 from niko0xdev/newline-for-init-response + +Put newline at end of `gqlgen init` output + +
+ +- fabc6f8f Merge branch 'master' into feat-directive-parent + +- e53d224e Merge branch 'master' into feat-directive-parent + +
de750645 Merge pull request #298 from niko0xdev/handle-response-nulls + +Nulls in required fields should cause errors and bubble + +
+ +- c8552729 Put newline at end of gqlgen init output + +- 072363c7 add ParentObject field to ResolverContext + +
e15d7890 Merge pull request #300 from niko0xdev/fix-starwars-connection-example + +fix connection example + +
+ +- d6acec16 fix connection example + +- 7d1cdaca Nulls in required fields should cause errors and bubble + +
2c4e6cbf Merge pull request #294 from niko0xdev/simplfy-concurrent-resolvers + +Simplfy concurrent resolver logic + +
+ +- 7926c688 Simplfy concurrent resolver logic + + + + + + +## [v0.4.4](https://github.com/niko0xdev/gqlgen/compare/0.4.3...v0.4.4) - 2018-08-21 +- 6f6622c6 Bump gqlparser to latest version + +
72659af4 Merge pull request #297 from niko0xdev/fix-dep-pruning + +Explicitly import ambient imports so dep doesn't prune them + +
+ +- cac3c729 Explicitly import ambient imports so dep doesn't prune them + +
e6af26e0 Merge pull request #296 from heww/master + +sort directives by name when gen + +
+ +- fd09cd99 sort directives by name when gen + +
71917267 Merge pull request #292 from m4ppi/fix-doc + +Fix broken links in docs + +
+ +- 05c73d9f Fix broken links in docs + +
5a0b56aa Merge pull request #285 from niko0xdev/fix-force-type + +Stop force resolver from picking up types from matching fields + +
+ +- 31478cf4 Stop force resolver from picking up types from matching fields + +
ebdcf740 Merge pull request #283 from niko0xdev/speed-up-tests + +Speed up tests + +
+ +- 36e84073 Speed up tests + + + + + + +## [0.4.3](https://github.com/niko0xdev/gqlgen/compare/0.4.2...0.4.3) - 2018-08-10 +
3575c289 Merge pull request #281 from niko0xdev/introspection-default-args + +Fix missing default args on types + +
+ +- b808253f Fix missing default args on types + +
bf235296 Merge pull request #282 from niko0xdev/flakey-tests + +Remove sleeps in tests + +
+ +- e9c68f08 make appveyor less flakey + + + + + + +## [0.4.2](https://github.com/niko0xdev/gqlgen/compare/0.4.1...0.4.2) - 2018-08-10 +- 06b00d45 Update README.md + +
5c379a33 Merge pull request #279 from niko0xdev/integration-tests + +Integration tests + +
+ +- 7f20bdef disable tty for jest + +- bb0a89a0 exclude generated code from tests + +- c2bcff79 regenerate + +- 45e22cb1 Add introspection schema check + +
53109cd0 Merge pull request #270 from niko0xdev/feat-handlers + +stop pickup "github.com/vektah/gqlgen/handler" from GOPATH + +
+ +- ae82b94a convert existing tests to jest + +- f04820b1 address comment + +- 88730e2c Convert test directory into integration test server + +- f372b1c9 Use docker in docker for the existing testsuite + +
0eb08ab9 Merge pull request #274 from niko0xdev/fix-variable-validation-data + +Prevent executing queries on variable validation failures + +
+ +- 47a7ac35 Prevent executing queries on variable validation failures + +- e6e323d0 stop pickup "github.com/vektah/gqlgen/handler" from GOPATH + +- e6005f6b fix mobile nav + +
5cdbc975 Merge pull request #267 from niko0xdev/authentication-docs + +Authentication docs + +
+ +- 1871c4ce Add bold variant of Roboto to docs + +- fc9fba09 Some minor edits to authentication docs + +- d151ec8d Add docs on user authentication + +- 8db3c143 Add structure to menu + +
c57619e0 Merge pull request #260 from niko0xdev/init-improvements + +Init Config Improvement + +
+ +
336b62ec Merge pull request #266 from niko0xdev/lint-friendly-decollision + +Make keyword decollision more lint friendly + +
+ +- 2acbc245 Make keyword decollision more lint friendly + +
f12f08a7 Merge pull request #264 from niko0xdev/docs + +CORS docs + +
+ +- a2a7c0e7 Eliminate font resize popin + +- 8a7ed618 Fix errors docs + +- 96e6aab2 Add CORS docs + +
0ab1c685 Merge pull request #263 from niko0xdev/add-logo + +Add logo to doc site + +
+ +- 6d39f868 Add logo to doc site + +- d7241728 Better error on init if file exists + +- fb03bad9 Run init even if config is found + +- 52b78793 Fix hard-coded server filename in init + + + + + + +## [0.4.1](https://github.com/niko0xdev/gqlgen/compare/0.4.0...0.4.1) - 2018-08-04 +
42f10ec9 Merge pull request #255 from niko0xdev/introspection-fixes + +Fix introspection api + +
+ +- 7400221c Fix introspection api + +
b35804ba Merge pull request #254 from oskanberg/patch-1 + +Fix typo in introduction docs + +
+ +- 84552437 Fix typo in introduction docs + +- b5a48e3e Update README.md + +- c20bb134 update badges + + + + + + +## [0.4.0](https://github.com/niko0xdev/gqlgen/compare/0.3.0...0.4.0) - 2018-08-03 +
7b5a3d74 Merge pull request #247 from niko0xdev/next + +0.4.0 Release + +
+ +
c0be9c99 Merge pull request #251 from niko0xdev/rewrite-imports + +Rewrite import paths + +
+ +- 4361401a Rewrite import paths + +
f042328a Merge pull request #252 from niko0xdev/move-doc-site + +Move doc site + +
+ +- 658a24d9 Move doc site + +
07b7e6ca Merge pull request #248 from niko0xdev/json-usenumber + +use json.Decoder.UseNumber() when unmarshalling vars + +
+ +- 95fe07fe use json.Decoder.UseNumber() when unmarshalling vars + +
c555f54c Merge pull request #245 from vektah/new-feature-docs + +New feature docs + +
+ +
825840aa Merge pull request #244 from vektah/array-coercion + +Add implicit value to array coercion + +
+ +
90b40769 Merge pull request #246 from vektah/fix-introspection + +Fix introspection + +
+ +- ef208c76 add docs for resolver generation + +- e44d798d Add directives docs + +- 62d4c8aa Ignore __ fields in instrospection + +- bc204c64 Update getting started guide + +- b38c580a Return the correct mutation & subscription type + +- 9397920c Add field name config docs + +- d2265f3d Add implicit value to array coercion + +
191c8ba0 Merge pull request #239 from vektah/directive-args + +Directive args + +
+ +- 3bef596d regenerate + +- 4f37d170 Add directive args + +
f78a6046 Merge pull request #241 from vektah/feat-lintfree + +Make more golint free generated code + +
+ +- 19b58175 Merge remote-tracking branch 'origin/master' into HEAD + +- c3fa1a55 Merge branch 'next' into feat-lintfree + +
17bfa2cb Merge pull request #240 from vektah/doc-fonts + +Use fonts from golang styleguide + +
+ +- 64ef0571 Use fonts from golang styleguide + +
6b532383 Merge pull request #237 from vektah/feat-fieldmapping + +Add model field mapping + +
+ +- 4fb721ae address comment + +- bf43ab3d Merge branch 'next' into feat-fieldmapping + +- 353319ca Refactor GoVarName and GoMethodName to GoFieldName etc... + +- d7e24664 Add method support + +
17bcb322 Merge pull request #236 from vektah/generate-handler-on-init + +Generate server on running init + +
+ +
600f4675 Merge pull request #238 from vektah/variable-validation + +Add missing variable validation + +
+ +- d6a76254 Add missing variable validation + +- 121e8db4 Generate server on running init + +- 108bb6b4 Rename govarname to modelField + +- f7f6f916 Make more lint friendly + +- 69eab938 Add model field mapping + +
ffee020c Merge pull request #235 from vektah/generate-resolver-on-init + +Generate resolver on init + +
+ +- df95f003 Generate code after init + +- 58831ac1 Generate resolver if configured + +
7031264d Merge pull request #229 from vektah/fix-init-command + +Fixing init command + +
+ +
078bc985 Fixing init command + +The init command always return file already exists if there are no +configFilename specified + +This is caused by codegen.LoadDefaultConfig() hiding the loading details +and always return the default config with no error while the init +command code expects it to tell us if config exists in default +locations. + +To avoid confusion I have splitted the loading config from default +locations out into its own method so we can handle different cases +better. + +Additionally I also moved default config into a method so we always +generating new a config instead of passing it around and potentially +mutating the default config. + +
+ +
803711e9 Merge pull request #221 from vektah/middleware-stack + +Implement FieldMiddleware Stack + +
+ +- 0ec918bf Switch GoName to Name|ucFirst + +- 5dc104eb Add middleware example for Todo + +- 73a8e3a3 Fix some issues with directive middlewares + +- 84163247 Regenerate + +
0e16f1fc Generate FieldMiddleware + +Moves it off of RequestContext and into generated land. This change +has a basic implementation of how directive middlewares might work. + +
+ +- 2748a19b Require Config object into NewExecutableSchema + +- 09242061 Add Directives to Build + +
69e790c2 Add *Field to CollectedField + +We need the Field Definition so that we can run directive middlewares +for this field. + +
+ +- d6813f6d Generarte + +
764c6fda Refactor ResolverMiddleware to FieldMiddleware + +This will allow us to include DirectiveMiddleware in the same middleware +setup, that will run after Resolver middlewares. + +
+ +
7226e573 Merge pull request #225 from rongfengliang/patch-1 + +Update getting-started.md + +
+ +- 66593ffe Merge remote-tracking branch 'origin/master' into HEAD + +- 8714f7fb hush metalinter + +
0dfb92a7 Update getting-started.md + +CreateTodo UserID input should be UserId not User + +
+ +
0fa7977f Merge pull request #217 from vektah/resolver-middleware-all + +Run Resolver Middleware For All Fields + +
+ +
7292be78 Rename CastType to AliasedType + +This field stores a Ref if a type is a builtin that has been aliased. In +most cases if this is set, we want to use this as the type signature +instead of the named type resolved from the schema. + +
+ +- ec928cad Regenerate examples + +
97f13184 Remove comment about ResolverMiddleware + +Not true anymore! + +
+ +- b512176c Run resolver middleware for all fields + +
f67f8390 Merge pull request #218 from vektah/remove-old-resolvers + +Remove old resolvers + +
+ +
1a3e4e99 Merge pull request #220 from vektah/feat-race + +turn back -race option + +
+ +- 40989b19 turn back -race option + +
1ba61fcb Update test & examples to use new resolver pattern + +* chat +* dataloader +* scalar +* selection +* starwars +* todo + +
+ +
38708961 Stop generating two types of resolvers + +In recent refactor we introduced a new pattern of resolvers which is +better structured and more readable. To keep Gqlgen backward compatible +we started generate two styles of resolvers side by side. + +It is now time to sunset the old resolver. This commit removes the old +resolver and update the generation code to use the new resolver +directly. + +
+ +- ffe42658 Merge pull request #208 from vektah/directives-skip-include + +
a69071e3 Pass context to CollectFields instead of RequestContext + +Internally it can still get to RequestContext as required. + +
+ +- d02d17ae Add method for generating method name from field + +- c7ff3208 Update gqlparser version to include default resolution + +- ce17cd90 Add default value test case + +
cbfae3d3 Add skip/include test cases + +Adds a set of test cases for skip and include directives to the todo +example. Also now conforms to spec if both are included. + +
+ +
ea0f821c Add skip/include directive implementation + +This is a snowflake implementation for skip/include directives based on +the graphql-js implementation. Skip takes precedence here. + +
+ +- ebfde103 Pass request context through to CollectFields + +
bab7abb2 Merge pull request #210 from vektah/feat-init + +introduce gen & init subcommand + +
+ +
6ba508f9 Merge pull request #214 from vektah/gqlparser-schema-validation + +Bump gqlparser to get schema validation + +
+ +- 138b4cea Bump gqlparser to get schema validation + +- 08d7f7d0 Merge branch 'next' into feat-init + +- 39f9dbf6 fix error from breaking change + +- 41147f6f update Gopkg.lock + +- 87d8fbea remove unused flag + +- eff49d04 support init subcommand + +- c5810170 introduce cobra library + +- c3c20f8f Merge remote-tracking branch 'origin/master' into HEAD + +
90df37f6 Merge pull request #205 from vektah/forward-credential-to-graphql-endpoint + +Use original credential for query request in playground + +
+ +
52343745 Merge pull request #206 from vektah/validation-locations + +Update gqlparser for validation locations + +
+ +- f4d31aa4 Update gqlparser for validation locations + +
9d473f8b Merge pull request #203 from vektah/niko0xdev-announcement + +Announcement: niko0xdev is now sponsoring gqlgen + +
+ +
c2f1570d Merge pull request #204 from vektah/gqlparser-prelude + +Use shared prelude + +
+ +- 004ec6a9 Add niko0xdev sponsorship news + +- 548aed14 Use shared prelude + +
edb3ea4e Use original credential for query request in playg + +Currently the playground doesn't forward any credentials when making +query calls. This can cause problems if your playground requires +credential logins. + +
+ +
f855a89c Merge pull request #201 from cocorambo/remove-trailing-println + +Remove trailing Println + +
+ +- c41a6c36 Remove trailing Println + +
2692d3e0 Merge pull request #197 from vektah/new-parser + +Integrate gqlparser + +
+ +- 5796d47d Integrate gqlparser + +- 55179a61 Update badges + +
01a4c677 Merge pull request #195 from jonstaryuk/master + +Update playground version + +
+ +- c52f24af Update playground version to 1.6.2 + + + + + + +## [0.3.0](https://github.com/niko0xdev/gqlgen/compare/0.2.5...0.3.0) - 2018-07-14 +
381b3469 Merge pull request #194 from vektah/multiline-comments + +Fix multiline comments + +
+ +- 112d68a6 only build master branch + +- 4b3778e3 Fix multiline comments + +
eb44925c Merge pull request #193 from vektah/validate-method-returns + +validate method return types + +
+ +- 164acaed validate method return types + +
f478f816 Merge pull request #192 from vektah/strict-config + +Strict config + +
+ +- a1c02e7b Strict config + +
533dcba7 Merge pull request #191 from vektah/nullable-list-elements + +Support nullable list elements + +
+ +- e0bf6afd Support nullable list elements + +
0780bf2e Merge pull request #190 from vektah/generated-forced-resolvers + +Allow forcing resolvers on generated types + +
+ +- bf1823cd Allow forcing resolvers on generated types + +
febd0358 Merge pull request #186 from vektah/error-redux + +Error redux + +
+ +- b884239a clarify error response ordering + +- 58e32bbf Drop custom graphql error methods + +- d390f9c6 Errors redux + + + + + + +## [0.2.5](https://github.com/niko0xdev/gqlgen/compare/0.2.4...0.2.5) - 2018-07-13 +
0a9709db Merge pull request #188 from vektah/fix-windows-gopath + +Fix windows gopath issue + +
+ +- ea4f26c6 more fixes + +- 1066953d Appveyor config + +- f08d8b61 Fix windows gopath issue + +- 9ade6b7a Update gettingstarted to use new resolvers + + + + + + +## [0.2.4](https://github.com/niko0xdev/gqlgen/compare/0.2.3...0.2.4) - 2018-07-10 +
ac9e5a66 Merge pull request #180 from vektah/import-alias-before-finalize + +Fix a bug custom scalar marshallers in external packages + +
+ +- 160ebab5 Fix a bug custom scalar marshallers in external packages + +
43212c04 Merge pull request #179 from vektah/models-config-error + +Improve Output Filename and Package Handling + +
+ +- 936bc76e Better handling of generated package name + +- 5d3c8ed2 Inline ImportPath strings + +- fc43a92a Check that exec and model filenames end in *.go + +- 6d38f77d Handle package name mismatch with dirname + +- ebf1b2a5 Add error message when specifying path in package name + +- c8355f48 Check models config for package-only specs + + + + + + +## [0.2.3](https://github.com/niko0xdev/gqlgen/compare/0.2.2...0.2.3) - 2018-07-08 +- 6391596d Add some basic docs on the new config file + +
a9c3af86 Merge pull request #176 from vektah/config-search-paths + +Search for config + +
+ +- 25cfbf08 Search for config + +
bff3356b Merge pull request #175 from vektah/lint-all-packages + +gometalinter should cover all packages + +
+ +- 61f37173 gometalinter should cover all packages + +
ce657044 Merge pull request #173 from vvakame/feat-resolver-hint + +add resolver option support to field + +
+ +
57b8279e Merge pull request #172 from vvakame/feat-newconfig + +switch to .gqlgen.yml + +
+ +- fcfceefb add resolver option support to field + +- c7ce1cbb update docs + +- 42948153 move to .gqlgen.yml + +
325c45a4 Merge pull request #171 from vvakame/add-gitignore + +add .idea/ to .gitignore + +
+ +- aa4cec9b add .idea/ to .gitignore + + + + + + +## [0.2.2](https://github.com/niko0xdev/gqlgen/compare/0.2.1...0.2.2) - 2018-07-05 +- f79b6a52 cleanup new config + +
f0a08617 Merge pull request #163 from vvakame/feat-types-json + +support .gqlgen.yml + +
+ +
faf095fc Merge pull request #166 from vektah/validate-at-end + +Validate at end + +
+ +- fca1e08e shh errcheck + +- cc78971e Dont show compilation errors until after codegen + +- 9f6ff0cf Convert todo example to new resolver syntax + +- 8577ceab address comment + +- 86dcce73 Add format check to -typemap argument + +- 5debbc6a Implement types.yaml parsing + +- ecf56003 Refactor types.json parsing + +
b16e8429 Merge pull request #159 from vektah/enum-only-generation + +Dont skip model generation if there are enums defined + +
+ +- 3f751a40 Dont skip model generation if there are enums defined + +- 588aeacb more tutorial fixes + +
dc472965 Merge pull request #157 from johncurley/fix-docs-argument + +Updated mutation to take correct argument + +
+ +- 88a84f83 Updated mutation to take correct argument + +
404f0b0d Merge pull request #151 from qdentity/fix-longer-gopath + +Fix bug with multiple GOPATH full package name resolving + +
+ +
f66e2b3b Fix bug with multiple GOPATH full package name resolving + +This commit fixes the bug where GOPATH values that are longer than the input package name cause 'slice bounds out of range' errors. + +
+ + + + + + +## [0.2.1](https://github.com/niko0xdev/gqlgen/compare/0.2.0...0.2.1) - 2018-06-26 +
cb87a2cb Merge pull request #147 from vektah/import-overhaul + +Improve import handling + +
+ +
9fa3f0fb Merge pull request #134 from mastercactapus/small-interfaces + +add lint-friendly small interfaces option for resolvers + +
+ +
e8c30acd fix template error on generated defaults (#146) + +* fix template error on generated defaults + +* go fmt + +* add test for default fix + +* . + +* add key sort for default values + +
+ +- 769a97e2 fix race in chat example test - t.Parallel() doesn't guarantee parallel execution - moved goroutine so the test can execute independently + +- 5b77e4c2 remove deprecation warning for now + +- 59a5d752 remove trailing S + +- b04846f6 fix time race in scalar test + +- a80b720f name updates, deprecation, some code comments + +- 2bbbe054 Merge branch 'master' into small-interfaces + +- 4ffa2b24 case insensitive compare to determine self package + +- c0158f54 make sure colliding imports are stable + +- abf85a10 get package name from package source + +- a39c63a5 remove a random json tag from tutorial + +- f48cbf03 tutorial fixes + +
0a85d4f2 Update generated headers to match convention. (#139) + +* Update generated.gotpl + +* Update models.gotpl + +* Update data.go + +* update go generate + +* revert code changes + +
+ +- 4a6827bd Update getting started guide + +- a21f3273 Use recognized `Code generated` header + +- 038c6fd2 change from `ShortResolver` to `ShortResolvers` - prevents possible collision with an object type named `Short` + +- 0bc592cd run go generate + +- db2cec07 fix template formatting + +- 59ee1b5c from probably makes more sense + +- 620f7fb4 add "short" resolver interface + + + + + + +## [0.2.0](https://github.com/niko0xdev/gqlgen/releases/tag/0.2.0) - 2018-06-21 +
d26ef2a2 Merge pull request #136 from tianhai82/master + +fix GOPATH case mismatch issue + +
+ +
a34b4de4 Merge pull request #137 from appleboy/patch-1 + +fix example links + +
+ +
c1cde36c Merge pull request #133 from mastercactapus/skip-type-mismatch + +skip struct fields with incompatible types + +
+ +- c1b4574c fix example links + +- 63976d5f fix GOPATH case mismatch issue + +- 8771065f skip fields with incompatible types + +
40d9a11b Merge pull request #127 from jon-walton/windows-path-slash + +convert windows input path separators to slash + +
+ +- 7db9d122 convert windows input path separators to slash + +
a5f72601 Merge pull request #122 from vektah/json-encoding-fixes + +Fix json string encoding + +
+ +- f207c62c review feedback + +- 578d8415 Fix json string encoding + +
e9b40666 Merge pull request #123 from vektah/drop-fk-generation + +BC Break: Stop generating foreign keys in models + +
+ +
a8419e20 Merge pull request #124 from vektah/fix-backtick-escaping + +Fix backtick escaping + +
+ +- 47eaff4d Fix backtick escaping + +- a5c02e6c BC Break: Stop generating foreign keys in models + +
94d5c89e Merge pull request #120 from andrewmunro/bugfix/fix-panic-on-invalid-array-type + +Fixing panic when non array value is passed to array type + +
+ +- 5680ee49 Adding dataloader test to confirm no panic on malformed array query + +- 55cc161f Fixing panic when non array value is passed to array type + +- 6b3b338d Add gitter link to readme + +- 6c823beb add doc publish script + +
a25232d8 Merge pull request #113 from mikeifomin/patch-1 + +Fix typo in url dataloaden + +
+ +- 3a129c77 Fix typo in url dataloaden + +- e1fd79fe Merge pull request #111 from imiskolee/master (closes #110) + +- e38cb497 1. fix bug: #110 + +
3990eacf Merge pull request #108 from imiskolee/master + +generate json tag to model field by gql name. + +
+ +- abb7502a 1. run go generate + +- e1f90946 1. add json tag in models_gen.go 2. use gqlname to model filed json tag. + +
35e09717 Merge pull request #107 from vektah/fix-vendor-normalization + +Fix vendor normalization + +
+ +
63ee4199 Fix vendor normalization + +When refering to vendored types in fields a type assertion would fail. This +PR makes sure that both paths are normalized to not include the vendor +directory. + +
+ +
2a437c23 Merge pull request #105 from vektah/keyword-input-args + +Automatically add a _ suffix to reserved words + +
+ +
26ac13ff Merge pull request #104 from vektah/new-request-context + +Add a NewRequestContext method + +
+ +- 309e5c6d Automatically add a _ suffix to reserved words + +- a2fb1421 Add a NewRequestContext method + +
ab6e65bd Merge pull request #97 from vektah/add-input-defaults + +Default values for input unmarshalers + +
+ +- 1cd80c4a Default values for input unmarshalers + +
79c69d15 Merge pull request #96 from vektah/refactor-tests + +Refactor tests + +
+ +- 7b1c8198 Refactor tests + +
0c7bdfc6 Merge pull request #95 from vektah/custom-error-types + +Custom error types + +
+ +- 4bdc1e1f regenerate + +- 20250f18 Add fully customizable resolver errors + +- a0f66c88 Update README.md + +- 8f62d505 Update README.md + +- a1043da6 Add feature comparison table to readme + +
22128e0e Merge pull request #93 from vektah/input-type-error-handling + +Input type error handling + +
+ +- e7539f11 Add an error message when using types inside inputs + +- a780ce69 Add a better error message when passing a type into an input + +- 0424f043 Refactor main so tests can execute the generator + +
ab3803a6 Merge pull request #89 from vektah/opentracing-parent-span + +Add parent opentracing span around root query/mutation/resolvers + +
+ +
d157ac35 Add context to recover func + +This makes the request and resolver contexts available during panic +so that you can log the incoming query, user info etc with your bug +tracker + +
+ +- 3ceaa189 add request middleware + +- 877f75a0 remove debugging trace (closes #81) + +
091d25ab Merge pull request #87 from jon-walton/windows-paths + +fix package paths on windows + +
+ +- 53a6e814 fix package paths on windows + +
546b7b76 Merge pull request #84 from yamitzky/master + +Fix collectFields to handle aliased fields properly + +
+ +- ba2ecb16 Add test case for aliased field + +- 78f3a56c Fix collectFields to handle aliased fields + +
4d2eece0 Merge pull request #77 from vektah/opentracing + +Add resolver middleware Add opentracing support + +
+ +- f0def668 better opentracing tags + +- 600bff7a bump metalinter deadline + +- 2e32c121 regenerate code + +- 5b908507 opentracing middleware + +- 57adb244 Add resolver middleware + +- 28d0c81f capture args in map + +
e266fab9 Merge pull request #75 from mathewbyrne/fix-import-dash + +Replace Invalid Characters in Package Name with an Underscore + +
+ +
b0d79115 Replace invalid package characters with an underscore + +This will sanatise local import names to a valid go identifier by +replacing any non-word characters with an underscore. + +
+ +
66a91503 Merge pull request #72 from vektah/custom-enum + +Add support for custom enums + +
+ +- 61a34a74 Add support for custom enums + +- 74ac827a move docs to new domain + +
ebcc94d1 Merge pull request #70 from vektah/models-in-separate-package + +Allow generated models to go into their own package + +
+ +- 9a532131 Allow generated models to go into their own package + +
6129fd26 Merge pull request #69 from vektah/support-options + +Support OPTIONS requests + +
+ +- af38cf05 Support OPTIONS requests + +
893ead12 Merge pull request #67 from vektah/raw-schema-string + +Use a raw string for schema + +
+ +- af6178a7 Use a raw string for schema + +
c0753bed Merge pull request #66 from vektah/generate-enums + +Generate enums + +
+ +- 85a51268 Generate enums + +
71c4e265 Merge pull request #65 from vektah/context + +Make field selections available in context + +
+ +- c60336bf regenerate + +- c5ccfe4e Add an example for getting the selection sets from ctx + +- e7007746 add fields to resolver context + +- 40918d52 move request scoped data into context + +
4e13262e Merge pull request #64 from vektah/vendor-gen-path + +Fix vendored import paths in generated models + +
+ +- 2ff9f32f Fix vendored import paths + +- 630a3cfc failing test + +- 99dec54c fix missing deps + +- 652c567e Remove missing field warning and add test for scalar resolvers (closes #63) + +- 3dc87e1b gtm + +- c76c3434 Add dataloader tutorial + +- 449fe8f8 Optimize frontmatter + +- b90ae60e flatten menus + +
a508ecb0 Merge pull request #45 from dvic/fix-resolver-public-errors + +Retain orignal resolver error and support overriding error message + +
+ +- ab4e7010 Retain orignal resolver error and support overriding error message (closes #38) + +
a05a18d5 Merge pull request #61 from vektah/import-resolver-collisions + +Deal with import collisions better + +
+ +- d81ea2c2 Deal with import collisions better + +
fb131a94 Merge pull request #59 from vektah/map-support + +Add map[string]interface{} escape hatch + +
+ +- 49d92164 Add map[string]interface{} escape hatch + +
5abdba16 Merge pull request #57 from vektah/null-input-fields + +Null input fields + +
+ +- f8add9d2 remove more unneeded whitespace + +- 84b06617 Allow nulls in input fields + +
54fbe16a Merge pull request #56 from vektah/getting-started-fixes + +Getting started fixes + +
+ +- 17fd17a4 Update the tutorial + +- e65d2a5a detect correct FK type + +- b66cfa03 small fixes to entry point + +- 0b62315a Create ISSUE_TEMPLATE.md + +
f3a70dac Merge pull request #55 from vektah/fix-input-ptr-unpacking + +Fix ptr unpacking in input fields + +
+ +- 10541f19 Fix ptr unpacking in input fields + +
15b3af2d Fix value receivers for unions too + +fixes 42 + +
+ +
46103bdc Merge pull request #53 from vektah/docs + +Docs + +
+ +- d0211a0a Custom scalar docs + +- e6ed4de5 Update readme link + +- 51f08a9e start of docs + +
ac832dea Merge pull request #51 from vektah/support-embedding + +Support embedding in models + +
+ +- 9d710712 add embedding support + +- 0980df0e Embedding example + +
cb34e6db Merge pull request #50 from vektah/valuer-receiver + +Don't generate value receivers for types that cant fit the interface + +
+ +- ec5f5e66 check for valuer receivers before generating type switch + +- dc898409 add test case + +
8ef253cb Merge pull request #49 from vektah/default-entrypoints + +default to Query / Mutation / Subscription if no entry points are specified + +
+ +- 302058a7 Use default entry points for Query/Mutation/Subscription + +
13949fdf Merge pull request #37 from vektah/generate-interfaces + +generate interfaces + +
+ +- acc45bf0 generate interfaces + +
e47d5038 Merge pull request #34 from vektah/root-types-only + +Only bind to types in the root package scope + +
+ +- ffe972a8 Only bind to types in the root package scope + +
0e78c0ae Merge pull request #33 from vektah/unset-arguments + +Allow unset arguments + +
+ +- bc9e0e54 Allow unset arguments + +
94718351 Merge pull request #31 from vektah/recover-handler + +Customizable recover func + +
+ +- e4e249ea Customizable recover func + +
69277045 Merge pull request #30 from vektah/complex-input-types + +Fix complex input types + +
+ +- 9b64dd22 Fix complex input types + +
1d074b89 Merge pull request #29 from vektah/multi-stage-model-build + +Split model generation into its own stage + +
+ +- cf580c24 Split model generation into its own stage + +
926384db Merge pull request #28 from vektah/default-args + +add default args + +
+ +- 68c54a14 add default args + +- d63128f6 appease the linting gods + +
7b6b124e Merge pull request #20 from vektah/codegen-cleanup + +Codegen cleanup + +
+ +- 78c34cb3 regenerate + +- 5ebd157c Only use one gofunc per subscription + +- 79a70376 Move generated field resolvers into separate methods + +
e676abe4 Merge pull request #19 from vektah/generate-input-types + +Generate input models too + +
+ +- f094e79c Generate input models too + +- 1634f088 Add a missed error check + +
4feb1689 Merge pull request #18 from vektah/array-input-args + +Fix input array processing + +
+ +- 98176297 Fix input array processing + +
4880497f Merge pull request #16 from vektah/better-templates + +Better templates + +
+ +- 278df9de Better templates + +
f3731c73 Merge pull request #14 from vektah/autogenerate-models + +Autogenerate models + +
+ +- cfe902a0 Autogenerate models + +- 287bf7f4 more docs + +
9d896f40 Merge pull request #13 from vektah/autocast + +Automatically add type conversions around wrapped types + +
+ +- 85fa63b9 Automatically add type conversions around wrapped types + +
c8c2e40f Merge pull request #11 from vektah/subscriptions + +Add support for subscriptions + +
+ +- d514b829 Add some go tests to the chat app + +- ec2916d9 chat example for subscriptions using CRA+apollo + +- 8f93bf8d get arg errors working in both contexts + +- 62a18ff1 Update generator to build a new ExecutableSchema interface + +- c082c3a4 prevent concurrent writes in subscriptions + +- f555aec6 switch to graphql playground for better subscription support + +- 18219541 add websocket support to the handler + +- d4c7f3b9 update resolver definition to use channels for subscriptions + +
d0244d24 Merge pull request #10 from vektah/newtypes + +User defined custom types + +
+ +- 5d86eeb6 fix jsonw test + +- 944ee088 regenerate + +- 4722a855 add scalar example + +- 83b001ae rename marshaler methods + +- e0b7c25f move collectFields out of generated code + +- 146c6538 generate input object unpackers + +- d94cfb1f allow primitive scalars to be redefined + +- 402e0730 rename jsonw to graphql + +- 3e7d80df Update README.md + +- 9c77e7a0 Update dataloaden dep + +- 530f7895 Make gql client work with older versions of mapstructure + +- 5c04d1ad __typename support + +
51292db9 Merge pull request #4 from vektah/cleanup-type-binding + +Cleanup schema binding code + +
+ +- c89a8774 Cleanup schema binding code + +
030954a5 Merge pull request #2 from ulrikstrid/patch-1 + +Fix typo in README + +
+ +- cb507bd0 Fix typo in README + +- e3167785 Fix template loading from inside vendor + +- 261b52ce fix an error handling bug + +- 1da57f59 Split starwars models out from resolvers + +- 743b2cf9 fix indenting + +- fb2d5817 use gorunpkg to vendor go generate binaries + +- 7f4d0405 encourage dep use + +- 3276c782 Do not bind to unexported vars or methods + +- 5fabffaf heading tweaks + +- e032c1d5 Prior art + +- 45b79a1e Add a test for multidimensional arrays + +- ec73a50a fix race + +- 75a3a05c Dont execute mutations concurrently + +- 3900a41d tidy up json writing + +- 0dcf7f6b add circle ci badge + +- 2c9bf21c get dataloaden + +- 4fff3241 install dataloaden in ci + +- 951f41b2 circle ci + +- 8fa5f628 less whitespace + +- c76f3b98 clean up template layout + +- 4a6cea5e readme fixes + +- b814ad52 rename repo + +- 9c79a37a Cleanup and add tests + +- 5afb5caa update dataloaden + +- d00fae08 Add dataloader example + +- 86cdf3a0 Fix package resolution + +- 41306cba Better readme + +- ce5e38ed Add GET query param support to handler + +- dd9a8e4d parallel execution + +- 4468127e pointer juggling + +- 9e99c149 Use go templates to generate code + +- 41f74970 Support go versions earlier than 1.9 + +- c20ef3d0 add missing nulls + +- bb753776 Use goimports instead of gofmt on generated code + +- c2cf3835 coerce types between similar types + +- 5297dd40 Add support for RFC3339 formatted Time as time.Time + +- 61291ce9 support vendor + +- 6d437d7e allow map[string]interface{} arg types + +- 39a8090a cleanup + +- a9352e32 gometalinter pass + +- 9ab81d67 Finish fleshing out the connection example + +- e04b1e50 inline supporting runtime funcs + +- 9cedf012 complex arg handling + +- 0c9c009f Clean up json writer + +- e7e18c40 much cleaner generated code + +- 6a76bbf6 Interfaces and starwars example + +- 29110e76 Generate ESS to remove it interface{} casts completly + +- 2f358e7d graphiql autocomplete working + +- 2e2c3135 create separate type objects in prep for fragment support + +- 22c0ad0a Add basic introspection support + +- c1c2cb64 Code generation + +- 4be5ac84 args + +- bde800e1 imports + +- 596554da start of code generator + +- 62fa8184 split generated vs exec code + +- 0ea104cd remove internal package + +- f81371e8 Args + +- 01896b3b Hand written codegen example + +- 5a756bda Rewrite paths and add readme + +
b4663703 trace: Log graphql.variables rather than tag + +According to the OT documentation tag values can be numeric types, strings, or +bools. The behavior of other tag value types is undefined at the OpenTracing +level. For example `github.com/lightstep/lightstep-tracer-go` generates error +events. + +
+ +- 5d3b13f2 Support context injection in testing + +
beff0841 Separate literal arg parsing cases (int, float) + +This change allows the ID scalar implementation to more semantically +handle the case for unmarshalling integer IDs. + +
+ +
ab1dd4b5 Add tests for ID scalar input + +This commit adds two tests cases for ID scalar input: +- a string literal +- an integer literal + +Both of these literal types are covered by the GraphQL specification as +valid input for the ID scalar. + +Reference the ID section of the spec for more information: +http://facebook.github.io/graphql/October2016/#sec-ID + +
+ +
d8c57437 Extract ID scalar implmentation + +This change moves the ID scalar implementation out of `graphql.go` and +into its own file `id.go` for consistency with the Time scalar +implementation. + +
+ +- 10eb949b cleaned up example to use MustParseSchema + +
52080e1f Rename friendsConenctionArgs to friendsConnectionArgs + +Fix spelling error in friendsConnectionArgs type + +
+ +- 3965041f Update GraphiQL interface (add history) + +
6b9bc3e2 Add `(*Schema).Validate` (#99) + +* Add `(*Schema).Validate` + +This adds a `Validate` method to the schema, which allows you to find out if a query is valid without actually running it. This is valuable when you have a client with static queries and want to statically determine whether they are valid. + +* Fix Validate doc string + +
+ +- 7f3f7120 Set content-type header to `application/json` + +- c76ff4d8 moved packer into separate package + +- 073edccd updated tests from graphql-js + +- 3a9ac368 validation: improved overlap check + +- f86c8b01 allow multiple schemas in tests + +- 77750960 validation: OverlappingFieldsCanBeMerged + +- e7ca4fde refactor: remove SelectionSet type + +- 7aad6ba7 refactor: use schema.NamedType + +- fddcbcb7 resolves #92: fix processing of negative scalars during parse literals + +- 48c1a0fb Small fix based on feedback. + +- e90d1089 allow custom types as input arguments + +- dd3d39e2 fix panic when variable name not declared + +- c2bc105f validation: NoUnusedVariables + +- 4aff2976 refactor + +- 0933d241 validation: VariablesInAllowedPosition + +- 83e2f31a validation: NoUndefinedVariables + +- c39ffeca validation: PossibleFragmentSpreads + +- 47c5cde7 validation: UniqueInputFieldNames + +- 94cb2918 big refactoring around literals + +- 3d63ae80 some refactoring + +- 969dab9d merged lexer into package "common" + +- a9de6171 renamed lexer.Literal to lexer.BasicLit + +- 88c492bb validation: NoFragmentCycles (closes #38) + +- d39712c8 refactor addErrMultiLoc + +- ee5e1c3b validation: updated tests + +- 490ad6b2 validation: NoUnusedFragments + +- da85f09d add path to errors on resolver error or panic (closes #86) + +- 04cb2550 allow structs without pointers (closes #78) + +- 4c40b305 show all locations in error string + +- 5c26f320 fix limiter + +- dbc3f0a0 fix composing of fragments (closes #75) + +
213a5d01 Warn if an interface's resolver has a ToTYPE implementation that does not return two values. + +Currently this instead crashes fairly inscrutably at runtime here: https://github.com/neelance/graphql-go/blob/master/internal/exec/exec.go#L117 + +An alternate fix would be to check len(out) there and perhaps rely on out[0] being nil to continue if there's only one return value. + +
+ +- 00c4c574 Fix panic when resolver is not a pointer + +- d0df6d8a small cleanup + +- 036945e2 fix hang on panic (fixes #82) + +- 01ab5128 Add supports for snake case (#77) + +
67e6f91d use encoding/json to encode scalars + +There are some edge cases that are better handled by the proven encoder of encoding/json, for example special characters in strings. + +
+ +- 3f1cb6f8 implement user defined logger (with sensible defaults) + +- b357f464 built-in json encoding + +- 2d828770 refactor: collect fields to resolve + +- 32f8b6ba refactor: replaced MetaField + +- b95c566e simplify schema introspection + +- 4200a584 split internal/exec into multiple packages + +- c11687a7 refactored internal/exec + +- bd742d84 WIP + +- d09dd543 added SchemaOpt + +- 1dcc5753 fix Schema.ToJSON + +- 4f07e397 pass variable types to tracer + +- 36e6c97e readme: remove outdated section about opentracing + +- 0b143cca refactor: apply before exec + +
a9920602 pluggable tracer + +Improved performance while keeping flexibility. + +
+ +- 58d3d5b8 refactored exec.Request + +- 9dd714ec refactored execField some more + +- a43ef241 refactor: meta fields + +- 48931d17 refactor fieldExec + +- ee95710d small cleanup + +- 84baade5 perf: create span label only once + +- a16ed600 improved concurrency architecture + +
aef3d9cf Add testing.go into its own package (gqltesting) + +This is done so that "testing" (and especially its registered cli flags) +aren't included in any production builds. + +
+ +- f78108a3 validation: meta fields + +- c6ab2374 added empty file to make CI happy + +- d59c1709 fix introspection of default value + +- 42608a03 clean up now unnecessary check + +- e45f26dd validation: UniqueDirectivesPerLocation + +- dcf7e59f validation: UniqueFragmentNames + +- eeaa510b validation: UniqueOperationNames + +- a5a11604 refactor: Loc on Field + +- b5919db4 validation: UniqueVariableNames + +- 8632753a validation: ScalarLeafs + +- 45844984 validation: ProvidedNonNullArguments + +- c741ea84 validation: VariablesAreInputTypes + +- 0875d74f validation: UniqueArgumentNames + +- 1fdab07f validation: LoneAnonymousOperation + +- 090df527 validation: KnownTypeNames + +- f99ca95e refactor: validation context + +- 8aac2817 validation: KnownFragmentNames + +- eae3efc9 validation: KnownDirectives + +- 70581168 refactor: separate InlineFragment and FragmentSpread + +- d6aec0d6 renamed schema.Directive to DirectiveDecl + +- b616eeca validation: KnownArgumentNames + +- 885af607 refactor: Location without pointer + +- 5a40251c tests: filter errors to currently tested rule + +- 9c054f53 refactor: lexer.Ident + +- 254afa8a validation: fragment type + +- b6ef81af added test export script + +- 95a4ecd8 validation: fields + +- c387449f validation: default values + +- 44c6e634 validation: arguments + +- 30dcc339 directive arguments as slice + +- d331ac27 input values as slice + +- 615afd61 fields as slice + +- 60759904 arguments as slice + +- f7d9ff4e refactor literals + +- 2e1fef01 keep track of location of arguments + +- 29e0b375 added EnumValue type + +- aa868e8d resolve fragments early + +- adeb53d6 remove resolver from query package + +- 2e23573f parse directive decl without arguments + +- 36f8ba8b fix introspection of default value (closes #65) + +- e06f5855 support for "deprecated" directive on enum values + +- 498fe396 support for [@deprecated](https://github.com/deprecated) directive on fields (fixes #64) + +- 93ddece9 refactor: DirectiveArgs + +- 8f5605a1 refactor directives + +- faf5384a simplify parseArguments + +- b2c2e906 some more docs + +- f4516523 added some method documentations + +- 91bd7f88 improved meta schema + +- 10dc8ee6 added support for directive declarations in schema + +- 28028f66 readme: more info on current project status + +- e9afca38 hint in error if method only exists on pointer type (fixes #60) + +- 356ebd93 nicer error messages (fixes #56) + +- e413f4ed make gocyclo happy + +- 6e92795e fix spelling + +- 306e27ef gofmt -s + +- 612317b2 fix ToJSON + +- 728e57a9 improved doc for MaxParallelism + +- e8590a10 don't execute any further resolvers after context got cancelled + +- 644435cc added MaxParallelism + +- 21802a33 readme: add Sourcegraph badge + +- 5b2978fc added support for recursive input values + +- 8c84afb1 improved structure of "make exec" code + +- d5a6ca49 make sure internal types don't get exposed + +- c9d4d865 fixed some null handling + +- a336dd4b added request.resolveVar + +- 943f80f4 added unmarshalerPacker type + +- f77f7339 refactored non-null handling in packer + +- ae0f1689 remove hasDefault flag from makePacker + +- 9cbad485 allow Unmarshaler for all types, not just scalars + +- f565a119 refactored "make exec" code + +- 07a09e5d properly check scalar types of result values + +- ecceddec Add ResolverError field to QueryError for post processing + +- b7c59ab9 renamed type + +- 5817d300 moved some introspection code into new package, added Schema.Introspect + +
cdef8563 removed SchemaBuilder + +It is not necessary any more. Simpler API wins. + +
+ +
518a5fe7 Merge pull request #45 from nicksrandall/master + +fix wrong import statement + +
+ +- 8112e719 fix wrong import statement + +- 7fafcc6e allow single value as implicit list (fixes #41) + +- 2b513d7e improved custom types + +- 191422c4 merged code for value coercion and packing + +- 232356b3 introspection for "skip" and "include" directives (fixes #30) + +- 2e10f7b8 readme: spec version and link (fixes #35) + +- 61eca4c7 pretty print SchemaBuilder.ToJSON + +- 5e09ced1 fix "null" value for empty descriptions of types + +- 33cd194f SchemaBuilder.ToJSON instead of SchemaToJSON (fixes #29) + +- fff173bc proper error message when using non-input type as input (#19) + +- b94f2afe improved support for null + +- 4130d540 added support for input object literals + +- 663e466f moved some code into separate file + +- 728e071e added support for lists as input values (fixes #19) + +- 86f0f145 fix Float literals + +- b07f277b raise error on unexported input field (fixes #24) + +- 4838c6f3 fix optional input fields (fixes #25) + +- a15deed4 better way to implement GraphQL interfaces (#23) + +- 7a66d0e0 add support for description comments (fixes #20) + +- 0b3be40c improved tracing + +- da879f4f small improvements to readme + +- f3f24cf6 added some documentation + +- 38598d83 added CI badge to readme + +- bab81332 starwars example: fix pagination panic (#12) + +- 5ce3ca69 testing: proper error on invalid ExpectedResult + +- 8f7d2b1e added relay.Handler + +- fce75a50 properly coerce Int input values (#8) + +- 0dd38747 star wars example: pass operation name and variables (#8) + +- 3b7efd5c fix __typename for concrete object types (fixes #9) + +- 35667eda testing tools + +- 84571820 only create schema once for tests + +- de113f96 added MustParseSchema + +- d5e5f609 improved structure for tests + +- 947a1a3a added package with tools for Relay + +- 65f3e2b1 fix SchemaToJSON + +- cec7cea1 better error handling + +- e3386b06 improved type coercion and explicit ID type + +- 2ab9d765 support for custom scalars (fixes #3) + +- bdfd5ce3 use custom error type less + +- 0a7a37d1 more flexible API for creating a schema + +- bd20a165 improved type handling + +- ffa9fea4 renamed GraphQLError to QueryError + +- fcfa135a refactor + +- c28891d8 added support for OpenTracing + +- 2cf7fcc8 added SchemaToJSON + +- f6b498ac stricter type mapping for input values + +- 3c15e177 execute mutations serially + +- 1faf6661 fix missing error + +- de9b7fed add support for mutations + +- 094061d8 improved error handling a bit + +- cdb088d6 refactor: args as input object + +- b06d3941 refactor: values + +- 4fd33958 refactor: improved type system + +
1d03e667 refactor: new package "common" + +package "query" does not depend on "schema" any more + +
+ +- 1a959516 refactor + +- f8cb11c1 example/starwars: use interface base type to make type assertions nicer + +- 746da4b8 star wars example: friendsConnection + +- bec45364 parse type in query + +- be87a8fa remove unused code + +- 042e306a simpler way to resolve type refs in schema + +- 7cbf85fb improved type checking of arguments + +- 2b6460ae type check for scalars + +- 17034fe7 improved null handling + +- e6b6fbca small cleanup + +- 7b8cd1bc meta schema from graphql-js + +- 9333c0b3 introspection: inputFields + +- c4faac56 introspection: ofType + +- 86da8492 introspection: interfaces and possibleTypes + +- 20dbb845 proper nil support for lists + +- 2e3369ae resolve types in schema package + +- 7da95f4a introspection: enum values + +- cb423e6e improved handling of scalar types + +- 5b07780f introspection: original order for fields and args + +- 1e2d180c introspection: arguments + +- f21131bb refactored schema to be more in line with introspection + +- 0152d4f2 introspection: currently no descriptions and deprecations + +- ad5689bb field introspection + +- 2749d814 removed query.TypeReference + +
2eb105ec Revert "resolve scalar types in exec" + +This reverts commit fb3a6fc969b0c8c286c7d024a108f5696627639c. + +
+ +- 40682d68 removed exec.typeRefExec + +- 64ea90fe makeWithType + +- 2966f213 added nonNilExec + +- c12a8ad3 added support for ints and floats in query + +- 0f85412b improved example + +- 22ce46d1 support for optional error result + +- 0fe56128 optional context parameter + +- f1bc9b21 syntax errors with proper line and column + +- ae299efc proper response format + +- 9619721b added support for contexts + +- 267fc631 refactor + +- 2e56e7ea renamed NewSchema to ParseSchema + +- 356b6e6b added godoc badge + +- 03f2e72d added README.md + +- 1134562a added non-null type + +- 8fa41551 renamed Input to InputObject + +- 6f2399aa introspection: type kind + +- e2c58f2f refactor: schema types for interface and input + +- 0c8c9436 introspection: __type + +- 99a37521 refactoring: calculate "implemented by" in schema package + +- 1cac7e56 introspection: queryType + +- cc348faf first bit of introspection + +- fb3a6fc9 resolve scalar types in exec + +- 4cb8dcc0 panic handlers + +- c7a528d4 proper error handling when creating schema + +- ae37381c add support for __typename + +- 4057080f add support for union types + +- d304a418 attribute source of star wars schema + +- 0fcab871 added LICENSE + +- 0dc0116d support for inline fragments + +- f5e7d070 support for type assertions + +- fcb853c6 refactoring: addResultFn + +- 741343f8 explicit fragment spread exec + +- 73759258 all missing stubs for star wars example + +- edc78e2b parallelism + +- fb633714 collect fields + +- 08f02a2b execs + +- d70d16c4 added server example + +- 6f9a89db separate example/starwars package + +- e4060db5 added support for directives + +- 89b06652 added support for variables + +- 78065ecb added support for enums + +- 18645e60 added support for query fragments + +- 84f532b9 added support for aliases + +- 59d2a619 improved support for arguments + +- edce4ec8 proper star wars data + +- d6ffc01d syntax support for full star wars schema + +- b5824104 support for comments + +- 2f9ce9b4 support for entry points + +- 0b3d1038 support for arguments + +- cff8b302 support for arrays + +- 565e59f5 schema package + +- 1ae71ba2 query package + +- 42c13e7a named types, complex objects + +- bf64e5da initial commit + + + + + + + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..c2181d4 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,27 @@ +# Contribution Guidelines + +Want to contribute to gqlgen? Here are some guidelines for how we accept help. + +## Getting in Touch + +Our [discord](https://discord.gg/DYEq3EMs4U) server is the best place to ask questions or get advice on using gqlgen. + +## Reporting Bugs and Issues + + We use [GitHub Issues](https://github.com/niko0xdev/gqlgen/issues) to track bugs, so please do a search before submitting to ensure your problem isn't already tracked. + +### New Issues + +Please provide the expected and observed behaviours in your issue. A minimal GraphQL schema or configuration file should be provided where appropriate. + +## Proposing a Change + +If you intend to implement a feature for gqlgen, or make a non-trivial change to the current implementation, we recommend [first filing an issue](https://github.com/niko0xdev/gqlgen/issues/new) marked with the `proposal` tag, so that the engineering team can provide guidance and feedback on the direction of an implementation. This also help ensure that other people aren't also working on the same thing. + +Bug fixes are welcome and should come with appropriate test coverage. + +New features should be made against the `next` branch. + +### License + +By contributing to gqlgen, you agree that your contributions will be licensed under its MIT license. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..10bb21c --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2020 gqlgen authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..fd5ae7e --- /dev/null +++ b/README.md @@ -0,0 +1,164 @@ +![gqlgen](https://user-images.githubusercontent.com/980499/133180111-d064b38c-6eb9-444b-a60f-7005a6e68222.png) + + +# gqlgen [![Integration](https://github.com/niko0xdev/gqlgen/actions/workflows/integration.yml/badge.svg)](https://github.com/niko0xdev/gqlgen/actions) [![Coverage Status](https://coveralls.io/repos/github/niko0xdev/gqlgen/badge.svg?branch=master)](https://coveralls.io/github/niko0xdev/gqlgen?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/niko0xdev/gqlgen)](https://goreportcard.com/report/github.com/niko0xdev/gqlgen) [![Go Reference](https://pkg.go.dev/badge/github.com/niko0xdev/gqlgen.svg)](https://pkg.go.dev/github.com/niko0xdev/gqlgen) [![Read the Docs](https://badgen.net/badge/docs/available/green)](http://gqlgen.com/) + +## What is gqlgen? + +[gqlgen](https://github.com/niko0xdev/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. +- **gqlgen enables Codegen** — We generate the boring bits, so you can focus on building your app quickly. + +Still not convinced enough to use **gqlgen**? Compare **gqlgen** with other Go graphql [implementations](https://gqlgen.com/feature-comparison/) + +## 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/niko0xdev/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/niko0xdev/gqlgen"\n _ "github.com/niko0xdev/gqlgen/graphql/introspection")' | gofmt > tools.go + + go mod tidy + +3. Initialise gqlgen config and generate models + + go run github.com/niko0xdev/gqlgen init + + go mod tidy + +4. Start the graphql server + + go run server.go + +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/niko0xdev/gqlgen/tree/master/_examples) show how to create GraphQL applications + - [Reference docs](https://pkg.go.dev/github.com/niko0xdev/gqlgen) for the APIs + +## Reporting Issues + +If you think you've found a bug, or something isn't behaving the way you think it should, please raise an [issue](https://github.com/niko0xdev/gqlgen/issues) on GitHub. + +## Contributing + +We welcome contributions, Read our [Contribution Guidelines](https://github.com/niko0xdev/gqlgen/blob/master/CONTRIBUTING.md) to learn more about contributing to **gqlgen** +## Frequently asked questions + +### How do I prevent fetching child objects that might not be used? + +When you have nested or recursive schema like this: + +```graphql +type User { + id: ID! + name: String! + friends: [User!]! +} +``` + +You need to tell gqlgen that it should only fetch friends if the user requested it. There are two ways to do this; + +- #### Using Custom Models + +Write a custom model that omits the friends field: + +```go +type User struct { + ID int + Name string +} +``` + +And reference the model in `gqlgen.yml`: + +```yaml +# gqlgen.yml +models: + User: + model: github.com/you/pkg/model.User # go import path to the User struct above +``` + +- #### Using Explicit Resolvers + +If you want to Keep using the generated model, mark the field as requiring a resolver explicitly in `gqlgen.yml` like this: + +```yaml +# gqlgen.yml +models: + User: + fields: + friends: + resolver: true # force a resolver to be generated +``` + +After doing either of the above and running generate we will need to provide a resolver for friends: + +```go +func (r *userResolver) Friends(ctx context.Context, obj *User) ([]*User, error) { + // select * from user where friendid = obj.ID + return friends, nil +} +``` + +You can also use inline config with directives to achieve the same result + +```graphql +directive @goModel(model: String, models: [String!]) on OBJECT + | INPUT_OBJECT + | SCALAR + | ENUM + | INTERFACE + | UNION + +directive @goField(forceResolver: Boolean, name: String, omittable: Boolean) on INPUT_FIELD_DEFINITION + | FIELD_DEFINITION + +type User @goModel(model: "github.com/you/pkg/model.User") { + id: ID! @goField(name: "todoId") + friends: [User!]! @goField(forceResolver: true) +} +``` + +### Can I change the type of the ID from type String to Type Int? + +Yes! You can by remapping it in config as seen below: + +```yaml +models: + ID: # The GraphQL type ID is backed by + model: + - github.com/niko0xdev/gqlgen/graphql.IntID # a go integer + - github.com/niko0xdev/gqlgen/graphql.ID # or a go string +``` + +This means gqlgen will be able to automatically bind to strings or ints for models you have written yourself, but the +first model in this list is used as the default type and it will always be used when: + +- Generating models based on schema +- As arguments in resolvers + +There isn't any way around this, gqlgen has no way to know what you want in a given context. + +### Why do my interfaces have getters? Can I disable these? +These were added in v0.17.14 to allow accessing common interface fields without casting to a concrete type. +However, certain fields, like Relay-style Connections, cannot be implemented with simple getters. + +If you'd prefer to not have getters generated in your interfaces, you can add the following in your `gqlgen.yml`: +```yaml +# gqlgen.yml +omit_getters: true +``` + +## Other Resources + +- [Christopher Biscardi @ Gophercon UK 2018](https://youtu.be/FdURVezcdcw) +- [Introducing gqlgen: a GraphQL Server Generator for Go](https://niko0xdev.com.au/blog/engineering/gqlgen-a-graphql-server-generator-for-go/) +- [Dive into GraphQL by Iván Corrales Solera](https://medium.com/@ivan.corrales.solera/dive-into-graphql-9bfedf22e1a) +- [Sample Project built on gqlgen with Postgres by Oleg Shalygin](https://github.com/oshalygin/gqlgen-pg-todo-example) +- [Hackernews GraphQL Server with gqlgen by Shayegan Hooshyari](https://www.howtographql.com/graphql-go/0-introduction/) diff --git a/RELEASE-CHECKLIST.md b/RELEASE-CHECKLIST.md new file mode 100644 index 0000000..5b94430 --- /dev/null +++ b/RELEASE-CHECKLIST.md @@ -0,0 +1,15 @@ +# When gqlgen gets released, the following things need to happen +Assuming the next version is $NEW_VERSION=v0.16.0 or something like that. + +1. Run the https://github.com/niko0xdev/gqlgen/blob/master/bin/release: +``` +./bin/release $NEW_VERSION +``` +2. git-chglog -o CHANGELOG.md +3. go generate ./...; cd _examples; go generate ./...; cd .. +4. git commit and push the CHANGELOG.md +5. Go to https://github.com/niko0xdev/gqlgen/releases and draft new release, autogenerate the release notes, and Create a discussion for this release +6. Comment on the release discussion with any really important notes (breaking changes) + +I used https://github.com/git-chglog/git-chglog to automate the changelog maintenance process for now. We could just as easily use go releaser to make the whole thing automated. + diff --git a/TESTING.md b/TESTING.md new file mode 100644 index 0000000..2677b33 --- /dev/null +++ b/TESTING.md @@ -0,0 +1,39 @@ +How to write tests for gqlgen +=== + +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 +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. + + +### Testing the errors generated by the binary + +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/testserver/input_test.go` for an example. + +### Testing introspection + +Introspection is tested by diffing the output of `graphql get-schema` against an expected output. + +Setting up the integration environment is a little tricky: +```bash +cd integration +go generate ./... +go run ./server/cmd/integration/server.go +``` +in another terminal +```bash +cd integration +npm install +./node_modules/.bin/graphql-codegen +``` + +will write the schema to `integration/schema-fetched.graphql`, compare that with `schema-expected.graphql` + +CI will run this and fail the build if the two files don't match. diff --git a/_examples/chat/.gitignore b/_examples/chat/.gitignore new file mode 100644 index 0000000..187e3b4 --- /dev/null +++ b/_examples/chat/.gitignore @@ -0,0 +1,22 @@ +# See https://help.github.com/ignore-files/ for more about ignoring files. + +# dependencies +/node_modules + +# testing +/coverage +/corpus + +# production +/build + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/_examples/chat/.gqlgen.yml b/_examples/chat/.gqlgen.yml new file mode 100644 index 0000000..b263ebb --- /dev/null +++ b/_examples/chat/.gqlgen.yml @@ -0,0 +1,3 @@ +models: + Chatroom: + model: github.com/niko0xdev/gqlgen/_examples/chat.Chatroom diff --git a/_examples/chat/chat_test.go b/_examples/chat/chat_test.go new file mode 100644 index 0000000..ddf01af --- /dev/null +++ b/_examples/chat/chat_test.go @@ -0,0 +1,77 @@ +package chat + +import ( + "fmt" + "runtime" + "sync" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +func TestChatSubscriptions(t *testing.T) { + c := client.New(handler.NewDefaultServer(NewExecutableSchema(New()))) + + const batchSize = 128 + var wg sync.WaitGroup + for i := 0; i < batchSize*8; i++ { + wg.Add(1) + go func(i int) { + defer wg.Done() + sub := c.Websocket(fmt.Sprintf( + `subscription @user(username:"vektah") { messageAdded(roomName:"#gophers%d") { text createdBy } }`, + i, + )) + defer sub.Close() + + var msg struct { + resp struct { + MessageAdded struct { + Text string + CreatedBy string + } + } + err error + } + + msg.err = sub.Next(&msg.resp) + require.NoError(t, msg.err, "sub.Next") + require.Equal(t, "You've joined the room", msg.resp.MessageAdded.Text) + require.Equal(t, "system", msg.resp.MessageAdded.CreatedBy) + + go func() { + var resp interface{} + err := c.Post(fmt.Sprintf(`mutation { + a:post(text:"Hello!", roomName:"#gophers%d", username:"vektah") { id } + b:post(text:"Hello Vektah!", roomName:"#gophers%d", username:"andrey") { id } + c:post(text:"Whats up?", roomName:"#gophers%d", username:"vektah") { id } + }`, i, i, i), &resp) + assert.NoError(t, err) + }() + + msg.err = sub.Next(&msg.resp) + require.NoError(t, msg.err, "sub.Next") + require.Equal(t, "Hello!", msg.resp.MessageAdded.Text) + require.Equal(t, "vektah", msg.resp.MessageAdded.CreatedBy) + + msg.err = sub.Next(&msg.resp) + require.NoError(t, msg.err, "sub.Next") + require.Equal(t, "Whats up?", msg.resp.MessageAdded.Text) + require.Equal(t, "vektah", msg.resp.MessageAdded.CreatedBy) + }(i) + // wait for goroutines to finish every N tests to not starve on CPU + if (i+1)%batchSize == 0 { + wg.Wait() + } + } + wg.Wait() + + // 1 for the main thread, 1 for the testing package and remainder is reserved for the HTTP server threads + // TODO: use something like runtime.Stack to filter out HTTP server threads, + // TODO: which is required for proper concurrency and leaks testing + require.Less(t, runtime.NumGoroutine(), 1+1+batchSize*2, "goroutine leak") +} diff --git a/_examples/chat/generated.go b/_examples/chat/generated.go new file mode 100644 index 0000000..d4bf547 --- /dev/null +++ b/_examples/chat/generated.go @@ -0,0 +1,4183 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package chat + +import ( + "bytes" + "context" + "embed" + "errors" + "fmt" + "io" + "strconv" + "sync" + "sync/atomic" + "time" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Mutation() MutationResolver + Query() QueryResolver + Subscription() SubscriptionResolver +} + +type DirectiveRoot struct { + User func(ctx context.Context, obj interface{}, next graphql.Resolver, username string) (res interface{}, err error) +} + +type ComplexityRoot struct { + Chatroom struct { + Messages func(childComplexity int) int + Name func(childComplexity int) int + Subscription func(childComplexity int) int + } + + Message struct { + CreatedAt func(childComplexity int) int + CreatedBy func(childComplexity int) int + ID func(childComplexity int) int + Subscription func(childComplexity int) int + Text func(childComplexity int) int + } + + Mutation struct { + Post func(childComplexity int, text string, username string, roomName string) int + } + + Query struct { + Room func(childComplexity int, name string) int + } + + Subscription struct { + MessageAdded func(childComplexity int, roomName string) int + } +} + +type MutationResolver interface { + Post(ctx context.Context, text string, username string, roomName string) (*Message, error) +} +type QueryResolver interface { + Room(ctx context.Context, name string) (*Chatroom, error) +} +type SubscriptionResolver interface { + MessageAdded(ctx context.Context, roomName string) (<-chan *Message, error) +} + +type executableSchema struct { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = ec + switch typeName + "." + field { + + case "Chatroom.messages": + if e.complexity.Chatroom.Messages == nil { + break + } + + return e.complexity.Chatroom.Messages(childComplexity), true + + case "Chatroom.name": + if e.complexity.Chatroom.Name == nil { + break + } + + return e.complexity.Chatroom.Name(childComplexity), true + + case "Chatroom.subscription": + if e.complexity.Chatroom.Subscription == nil { + break + } + + return e.complexity.Chatroom.Subscription(childComplexity), true + + case "Message.createdAt": + if e.complexity.Message.CreatedAt == nil { + break + } + + return e.complexity.Message.CreatedAt(childComplexity), true + + case "Message.createdBy": + if e.complexity.Message.CreatedBy == nil { + break + } + + return e.complexity.Message.CreatedBy(childComplexity), true + + case "Message.id": + if e.complexity.Message.ID == nil { + break + } + + return e.complexity.Message.ID(childComplexity), true + + case "Message.subscription": + if e.complexity.Message.Subscription == nil { + break + } + + return e.complexity.Message.Subscription(childComplexity), true + + case "Message.text": + if e.complexity.Message.Text == nil { + break + } + + return e.complexity.Message.Text(childComplexity), true + + case "Mutation.post": + if e.complexity.Mutation.Post == nil { + break + } + + args, err := ec.field_Mutation_post_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.Post(childComplexity, args["text"].(string), args["username"].(string), args["roomName"].(string)), true + + case "Query.room": + if e.complexity.Query.Room == nil { + break + } + + args, err := ec.field_Query_room_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Room(childComplexity, args["name"].(string)), true + + case "Subscription.messageAdded": + if e.complexity.Subscription.MessageAdded == nil { + break + } + + args, err := ec.field_Subscription_messageAdded_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Subscription.MessageAdded(childComplexity, args["roomName"].(string)), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap() + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + case ast.Mutation: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + 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._subscriptionMiddleware(ctx, rc.Operation, func(ctx context.Context) (interface{}, error) { + return ec._Subscription(ctx, rc.Operation.SelectionSet), nil + }) + + var buf bytes.Buffer + return func(ctx context.Context) *graphql.Response { + buf.Reset() + data := next(ctx) + + 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 + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + +//go:embed "schema.graphql" +var sourcesFS embed.FS + +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) +} + +var sources = []*ast.Source{ + {Name: "schema.graphql", Input: sourceData("schema.graphql"), BuiltIn: false}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (ec *executionContext) dir_user_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["username"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["username"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_post_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["text"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["text"] = arg0 + var arg1 string + if tmp, ok := rawArgs["username"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) + arg1, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["username"] = arg1 + var arg2 string + if tmp, ok := rawArgs["roomName"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("roomName")) + arg2, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["roomName"] = arg2 + return args, nil +} + +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_room_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_Subscription_messageAdded_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["roomName"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("roomName")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["roomName"] = arg0 + return args, nil +} + +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 ************************** + +func (ec *executionContext) _subscriptionMiddleware(ctx context.Context, obj *ast.OperationDefinition, next func(ctx context.Context) (interface{}, error)) func(ctx context.Context) graphql.Marshaler { + for _, d := range obj.Directives { + switch d.Name { + case "user": + rawArgs := d.ArgumentMap(ec.Variables) + args, err := ec.dir_user_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return func(ctx context.Context) graphql.Marshaler { + return graphql.Null + } + } + n := next + next = func(ctx context.Context) (interface{}, error) { + if ec.directives.User == nil { + return nil, errors.New("directive user is not implemented") + } + return ec.directives.User(ctx, obj, n, args["username"].(string)) + } + } + } + tmp, err := next(ctx) + if err != nil { + ec.Error(ctx, err) + return func(ctx context.Context) graphql.Marshaler { + return graphql.Null + } + } + if data, ok := tmp.(func(ctx context.Context) graphql.Marshaler); ok { + return data + } + ec.Errorf(ctx, `unexpected type %T from directive, should be graphql.Marshaler`, tmp) + return func(ctx context.Context) graphql.Marshaler { + return graphql.Null + } +} + +// endregion ************************** directives.gotpl ************************** + +// region **************************** field.gotpl ***************************** + +func (ec *executionContext) _Chatroom_name(ctx context.Context, field graphql.CollectedField, obj *Chatroom) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Chatroom_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Chatroom_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Chatroom", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Chatroom_messages(ctx context.Context, field graphql.CollectedField, obj *Chatroom) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Chatroom_messages(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Messages, 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.([]Message) + fc.Result = res + return ec.marshalNMessage2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋchatᚐMessageᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Chatroom_messages(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Chatroom", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Message_id(ctx, field) + case "text": + return ec.fieldContext_Message_text(ctx, field) + case "createdBy": + return ec.fieldContext_Message_createdBy(ctx, field) + case "createdAt": + return ec.fieldContext_Message_createdAt(ctx, field) + case "subscription": + return ec.fieldContext_Message_subscription(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Message", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Chatroom_subscription(ctx context.Context, field graphql.CollectedField, obj *Chatroom) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Chatroom_subscription(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + res := Subscription{} + fc.Result = res + return ec.marshalNSubscription2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋchatᚐSubscription(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Chatroom_subscription(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Chatroom", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "messageAdded": + return ec.fieldContext_Subscription_messageAdded(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Subscription", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Message_id(ctx context.Context, field graphql.CollectedField, obj *Message) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Message_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Message_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Message", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Message_text(ctx context.Context, field graphql.CollectedField, obj *Message) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Message_text(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Text, 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) fieldContext_Message_text(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Message", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Message_createdBy(ctx context.Context, field graphql.CollectedField, obj *Message) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Message_createdBy(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.CreatedBy, 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) fieldContext_Message_createdBy(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Message", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Message_createdAt(ctx context.Context, field graphql.CollectedField, obj *Message) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Message_createdAt(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.CreatedAt, 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.(time.Time) + fc.Result = res + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Message_createdAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Message", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Message_subscription(ctx context.Context, field graphql.CollectedField, obj *Message) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Message_subscription(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + res := &Subscription{} + fc.Result = res + return ec.marshalNSubscription2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋchatᚐSubscription(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Message_subscription(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Message", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "messageAdded": + return ec.fieldContext_Subscription_messageAdded(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Subscription", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Mutation_post(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_post(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().Post(rctx, fc.Args["text"].(string), fc.Args["username"].(string), fc.Args["roomName"].(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.(*Message) + fc.Result = res + return ec.marshalNMessage2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋchatᚐMessage(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_post(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Message_id(ctx, field) + case "text": + return ec.fieldContext_Message_text(ctx, field) + case "createdBy": + return ec.fieldContext_Message_createdBy(ctx, field) + case "createdAt": + return ec.fieldContext_Message_createdAt(ctx, field) + case "subscription": + return ec.fieldContext_Message_subscription(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Message", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_post_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_room(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_room(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Room(rctx, fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Chatroom) + fc.Result = res + return ec.marshalOChatroom2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋchatᚐChatroom(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_room(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_Chatroom_name(ctx, field) + case "messages": + return ec.fieldContext_Chatroom_messages(ctx, field) + case "subscription": + return ec.fieldContext_Chatroom_subscription(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Chatroom", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_room_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Subscription_messageAdded(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { + fc, err := ec.fieldContext_Subscription_messageAdded(ctx, field) + if err != nil { + return nil + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Subscription().MessageAdded(rctx, fc.Args["roomName"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return nil + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return nil + } + return func(ctx context.Context) graphql.Marshaler { + select { + case res, ok := <-resTmp.(<-chan *Message): + if !ok { + return nil + } + return graphql.WriterFunc(func(w io.Writer) { + w.Write([]byte{'{'}) + graphql.MarshalString(field.Alias).MarshalGQL(w) + w.Write([]byte{':'}) + ec.marshalNMessage2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋchatᚐMessage(ctx, field.Selections, res).MarshalGQL(w) + w.Write([]byte{'}'}) + }) + case <-ctx.Done(): + return nil + } + } +} + +func (ec *executionContext) fieldContext_Subscription_messageAdded(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Subscription", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Message_id(ctx, field) + case "text": + return ec.fieldContext_Message_text(ctx, field) + case "createdBy": + return ec.fieldContext_Message_createdBy(ctx, field) + case "createdAt": + return ec.fieldContext_Message_createdAt(ctx, field) + case "subscription": + return ec.fieldContext_Message_subscription(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Message", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Subscription_messageAdded_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), 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.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), 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.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), 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.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Chatroom") + case "name": + out.Values[i] = ec._Chatroom_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "messages": + out.Values[i] = ec._Chatroom_messages(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "subscription": + out.Values[i] = ec._Chatroom_subscription(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Message") + case "id": + out.Values[i] = ec._Message_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "text": + out.Values[i] = ec._Message_text(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "createdBy": + out.Values[i] = ec._Message_createdBy(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "createdAt": + out.Values[i] = ec._Message_createdAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "subscription": + out.Values[i] = ec._Message_subscription(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_post(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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 + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_room(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var subscriptionImplementors = []string{"Subscription"} + +func (ec *executionContext) _Subscription(ctx context.Context, sel ast.SelectionSet) func(ctx context.Context) 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 "messageAdded": + return ec._Subscription_messageAdded(ctx, fields[0]) + default: + panic("unknown field " + strconv.Quote(fields[0].Name)) + } +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNMessage2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋchatᚐMessage(ctx context.Context, sel ast.SelectionSet, v Message) graphql.Marshaler { + return ec._Message(ctx, sel, &v) +} + +func (ec *executionContext) marshalNMessage2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋchatᚐMessageᚄ(ctx context.Context, sel ast.SelectionSet, v []Message) 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.marshalNMessage2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋchatᚐMessage(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) marshalNMessage2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋchatᚐMessage(ctx context.Context, sel ast.SelectionSet, v *Message) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Message(ctx, sel, v) +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNSubscription2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋchatᚐSubscription(ctx context.Context, sel ast.SelectionSet, v Subscription) graphql.Marshaler { + res := ec._Subscription(ctx, sel) + return res(ctx) +} + +func (ec *executionContext) marshalNSubscription2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋchatᚐSubscription(ctx context.Context, sel ast.SelectionSet, v *Subscription) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + res := ec._Subscription(ctx, sel) + return res(ctx) +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + 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) marshalOChatroom2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋchatᚐChatroom(ctx context.Context, sel ast.SelectionSet, v *Chatroom) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Chatroom(ctx, sel, v) +} + +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) marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/_examples/chat/models_gen.go b/_examples/chat/models_gen.go new file mode 100644 index 0000000..8fb80cf --- /dev/null +++ b/_examples/chat/models_gen.go @@ -0,0 +1,24 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package chat + +import ( + "time" +) + +type Message struct { + ID string `json:"id"` + Text string `json:"text"` + CreatedBy string `json:"createdBy"` + CreatedAt time.Time `json:"createdAt"` + Subscription *Subscription `json:"subscription"` +} + +type Mutation struct { +} + +type Query struct { +} + +type Subscription struct { +} diff --git a/_examples/chat/package.json b/_examples/chat/package.json new file mode 100644 index 0000000..9b1b7be --- /dev/null +++ b/_examples/chat/package.json @@ -0,0 +1,33 @@ +{ + "name": "chat", + "version": "0.1.0", + "private": true, + "dependencies": { + "@apollo/client": "^3.2.3", + "apollo-utilities": "^1.0.26", + "graphql": "^14.0.2", + "graphql-sse": "^2.0.0", + "graphql-tag": "^2.10.0", + "graphql-ws": "^5.8.1", + "react": "^16.6.3", + "react-dom": "^16.6.3", + "react-scripts": "^2.1.1", + "styled-components": "^5.2.0", + "subscriptions-transport-ws": "^0.9.5", + "typescript": "^4.9.4" + }, + "scripts": { + "start": "react-scripts start", + "start:graphql-transport-ws": "REACT_APP_WS_PROTOCOL=graphql-transport-ws npm run start", + "start:graphql-sse": "REACT_APP_SSE_PROTOCOL=true npm run start", + "build": "react-scripts build", + "test": "react-scripts test --env=jsdom", + "eject": "react-scripts eject" + }, + "browserslist": [ + ">0.2%", + "not dead", + "not ie <= 11", + "not op_mini all" + ] +} diff --git a/_examples/chat/public/index.html b/_examples/chat/public/index.html new file mode 100644 index 0000000..831ac82 --- /dev/null +++ b/_examples/chat/public/index.html @@ -0,0 +1,15 @@ + + + + + + + React App + + + +
+ + diff --git a/_examples/chat/readme.md b/_examples/chat/readme.md new file mode 100644 index 0000000..ada2396 --- /dev/null +++ b/_examples/chat/readme.md @@ -0,0 +1,40 @@ +# Chat App + +Example app using subscriptions to build a chat room. + +### Server + +```bash +go run ./server/server.go +``` + +### Client + +The react app uses two different implementation for the websocket link + +- [apollo-link-ws](https://www.apollographql.com/docs/react/api/link/apollo-link-ws) which uses the deprecated [subscriptions-transport-ws](https://github.com/apollographql/subscriptions-transport-ws) library +- [graphql-ws](https://github.com/enisdenjo/graphql-ws) + +First you need to install the dependencies + +```bash +npm install +``` + +Then to run the app with the `apollo-link-ws` implementation do + +```bash +npm run start +``` + +or to run the app with the `graphql-ws` implementation (and the newer `graphql-transport-ws` protocol) do + +```bash +npm run start:graphql-transport-ws +``` + +or to run the app with the `graphql-sse` implementation do + +```bash +npm run start:graphql-sse +``` diff --git a/_examples/chat/resolvers.go b/_examples/chat/resolvers.go new file mode 100644 index 0000000..9630418 --- /dev/null +++ b/_examples/chat/resolvers.go @@ -0,0 +1,136 @@ +//go:generate go run ../../testdata/gqlgen.go + +package chat + +import ( + "context" + "math/rand" + "sync" + "time" + + "github.com/niko0xdev/gqlgen/graphql" +) + +type ckey string + +type resolver struct { + Rooms sync.Map +} + +func (r *resolver) Mutation() MutationResolver { + return &mutationResolver{r} +} + +func (r *resolver) Query() QueryResolver { + return &queryResolver{r} +} + +func (r *resolver) Subscription() SubscriptionResolver { + return &subscriptionResolver{r} +} + +func New() Config { + return Config{ + Resolvers: &resolver{ + Rooms: sync.Map{}, + }, + Directives: DirectiveRoot{ + User: func(ctx context.Context, obj interface{}, next graphql.Resolver, username string) (res interface{}, err error) { + return next(context.WithValue(ctx, ckey("username"), username)) + }, + }, + } +} + +func getUsername(ctx context.Context) string { + if username, ok := ctx.Value(ckey("username")).(string); ok { + return username + } + return "" +} + +type Observer struct { + Username string + Message chan *Message +} + +type Chatroom struct { + Name string + Messages []Message + Observers sync.Map +} + +type mutationResolver struct{ *resolver } + +func (r *mutationResolver) Post(ctx context.Context, text string, username string, roomName string) (*Message, error) { + room := r.getRoom(roomName) + + message := &Message{ + ID: randString(8), + CreatedAt: time.Now(), + Text: text, + CreatedBy: username, + } + + room.Messages = append(room.Messages, *message) + room.Observers.Range(func(_, v interface{}) bool { + observer := v.(*Observer) + if observer.Username == "" || observer.Username == message.CreatedBy { + observer.Message <- message + } + return true + }) + return message, nil +} + +type queryResolver struct{ *resolver } + +func (r *resolver) getRoom(name string) *Chatroom { + room, _ := r.Rooms.LoadOrStore(name, &Chatroom{ + Name: name, + Observers: sync.Map{}, + }) + return room.(*Chatroom) +} + +func (r *queryResolver) Room(ctx context.Context, name string) (*Chatroom, error) { + return r.getRoom(name), nil +} + +type subscriptionResolver struct{ *resolver } + +func (r *subscriptionResolver) MessageAdded(ctx context.Context, roomName string) (<-chan *Message, error) { + room := r.getRoom(roomName) + + id := randString(8) + events := make(chan *Message, 1) + + go func() { + <-ctx.Done() + room.Observers.Delete(id) + }() + + room.Observers.Store(id, &Observer{ + Username: getUsername(ctx), + Message: events, + }) + + events <- &Message{ + ID: randString(8), + CreatedAt: time.Now(), + Text: "You've joined the room", + CreatedBy: "system", + } + + return events, nil +} + +var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") + +func randString(n int) string { + b := make([]rune, n) + for i := range b { + b[i] = letterRunes[rand.Intn(len(letterRunes))] + } + return string(b) +} diff --git a/_examples/chat/schema.graphql b/_examples/chat/schema.graphql new file mode 100644 index 0000000..5317b8f --- /dev/null +++ b/_examples/chat/schema.graphql @@ -0,0 +1,29 @@ +type Chatroom { + name: String! + messages: [Message!]! + subscription: Subscription! +} + +type Message { + id: ID! + text: String! + createdBy: String! + createdAt: Time! + subscription: Subscription! +} + +type Query { + room(name: String!): Chatroom +} + +type Mutation { + post(text: String!, username: String!, roomName: String!): Message! +} + +type Subscription { + messageAdded(roomName: String!): Message! +} + +scalar Time + +directive @user(username: String!) on SUBSCRIPTION diff --git a/_examples/chat/server/server.go b/_examples/chat/server/server.go new file mode 100644 index 0000000..a271bb7 --- /dev/null +++ b/_examples/chat/server/server.go @@ -0,0 +1,42 @@ +package main + +import ( + "log" + "net/http" + "time" + + "github.com/gorilla/websocket" + "github.com/rs/cors" + + "github.com/niko0xdev/gqlgen/_examples/chat" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/handler/extension" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" + "github.com/niko0xdev/gqlgen/graphql/playground" +) + +func main() { + c := cors.New(cors.Options{ + AllowedOrigins: []string{"http://localhost:3000"}, + AllowCredentials: true, + }) + + srv := handler.New(chat.NewExecutableSchema(chat.New())) + + srv.AddTransport(transport.SSE{}) + srv.AddTransport(transport.POST{}) + srv.AddTransport(transport.Websocket{ + KeepAlivePingInterval: 10 * time.Second, + Upgrader: websocket.Upgrader{ + CheckOrigin: func(r *http.Request) bool { + return true + }, + }, + }) + srv.Use(extension.Introspection{}) + + http.Handle("/", playground.Handler("Todo", "/query")) + http.Handle("/query", c.Handler(srv)) + + log.Fatal(http.ListenAndServe(":8085", nil)) +} diff --git a/_examples/chat/src/App.js b/_examples/chat/src/App.js new file mode 100644 index 0000000..38377b2 --- /dev/null +++ b/_examples/chat/src/App.js @@ -0,0 +1,33 @@ +import React, { useState } from 'react'; +import styled from 'styled-components'; +import { Room } from './Room'; + +const Input = styled.div` + padding: 4px; + margin: 0 0 4px; + + input { + border: 1px solid #ccc; + padding: 2px; + font-size: 14px; + } +`; + +export const App = () => { + const [name, setName] = useState('tester'); + const [channel, setChannel] = useState('#gophers'); + + return ( + <> + + name: setName(e.target.value)} /> + + + channel: setChannel(e.target.value)} /> + + + + + ); + +}; diff --git a/_examples/chat/src/Room.js b/_examples/chat/src/Room.js new file mode 100644 index 0000000..0d33697 --- /dev/null +++ b/_examples/chat/src/Room.js @@ -0,0 +1,148 @@ +import React, { useState, useEffect, useRef } from 'react'; +import gql from 'graphql-tag'; +import { useQuery, useMutation } from '@apollo/client'; +import { Chat, ChatContainer, Message, MessageReceived } from './components/room'; + +let queuedMessages = [] +export const Room = ({ channel, name }) => { + const messagesEndRef = useRef(null) + const [ text, setText ] = useState(''); + + const [ addMessage ] = useMutation(MUTATION, { + onCompleted: () => { + setText(''); + } + }); + + let { loading, error, data, subscribeToMore } = useQuery(QUERY, { + variables: { + channel + }, + }); + + if (data && data.room) { + data = Object.assign({}, data, { + room: Object.assign({}, data.room, { + messages: [ + ...data.room.messages, + ...queuedMessages.filter((queuedMessage) => ( + !data.room.messages.find((msg) => msg.id === queuedMessage.id) + )), + ], + }) + }); + } + + // subscribe to more messages + useEffect(() => { + const subscription = subscribeToMore({ + document: SUBSCRIPTION, + variables: { + channel, + }, + updateQuery: (prev, { subscriptionData }) => { + + if (!subscriptionData.data) { + return prev; + } + const newMessage = subscriptionData.data.messageAdded; + if (!prev.room) { + queuedMessages.push(newMessage) + return prev; + } + + if (prev.room.messages.find((msg) => msg.id === newMessage.id)) { + return prev + } + + prev = Object.assign({}, prev, { + room: Object.assign({}, prev.room, { + messages: [ + ...prev.room.messages, + ...queuedMessages.filter((queuedMessage) => ( + newMessage.id !== queuedMessage.id + && !prev.room.messages.find((msg) => msg.id === queuedMessage.id) + )), + newMessage, + ], + }), + }); + queuedMessages = []; + return prev; + }, + }); + + + return () => subscription(); + + }, [subscribeToMore, channel]); + + // auto scroll down + useEffect(() => { + messagesEndRef && messagesEndRef.current && messagesEndRef.current.scrollIntoView({ behavior: 'smooth' }) + }, [messagesEndRef, data]); + + if (loading) { + return
loading
+ } + + if (error) { + return
error
+ } + + return (<> + + + {data.room.messages.map((msg) => + msg.createdBy === name ? + {msg.text} + : + {msg.createdBy} + {msg.text} + + )} + +
+ + + setText(e.target.value)} /> + +

+ +

+ ); + +} + +const SUBSCRIPTION = gql` + subscription MoreMessages($channel: String!) { + messageAdded(roomName:$channel) { + id + text + createdBy + } + } +`; + +const QUERY = gql` + query Room($channel: String!) { + room(name: $channel) { + messages { id text createdBy } + } + } +`; + +const MUTATION = gql` + mutation sendMessage($text: String!, $channel: String!, $name: String!) { + post(text:$text, roomName:$channel, username:$name) { id } + } +`; diff --git a/_examples/chat/src/components/room.js b/_examples/chat/src/components/room.js new file mode 100644 index 0000000..d28ef7a --- /dev/null +++ b/_examples/chat/src/components/room.js @@ -0,0 +1,83 @@ +import styled from 'styled-components'; + +export const Chat = styled.div` + padding: 4px; + margin: 0 0 12px; + max-width: 400px; + max-height: 400px; + border: 1px solid #ccc; + background-color: #babdc6; + overflow-x: hidden; + overflow-y: scroll; + position: relative; + font: 14px verdana; +`; + +export const ChatContainer = styled.div` + &:after { + content: ""; + display: table; + clear: both; + } +`; + +const ChatLine = styled.div` + color: #000; + clear: both; + line-height: 120%; + padding: 8px; + position: relative; + margin: 8px 0; + max-width: 85%; + word-wrap: break-word; + z-index: 1; + + &:after { + position: absolute; + content: ""; + width: 0; + height: 0; + border-style: solid; + } + + span { + display: inline-block; + float: right; + padding: 0 0 0 7px; + position: relative; + bottom: -4px; + } + +}`; + +export const MessageReceived = styled(ChatLine)` + background: #fff; + border-radius: 0px 5px 5px 5px; + float: left; + + &:after { + border-width: 0px 10px 10px 0; + border-color: transparent #fff transparent transparent; + top: 0; + left: -4px; + } + + span { + display: block; + color: #bbb; + font-size: 10px; + } +`; + +export const Message = styled(ChatLine)` + background: #e1ffc7; + border-radius: 5px 0px 5px 5px; + float: right; + + &:after { + border-width: 0px 0 10px 10px; + border-color: transparent transparent transparent #e1ffc7; + top: 0; + right: -4px; + } +`; diff --git a/_examples/chat/src/graphql-sse.ts b/_examples/chat/src/graphql-sse.ts new file mode 100644 index 0000000..bc36216 --- /dev/null +++ b/_examples/chat/src/graphql-sse.ts @@ -0,0 +1,30 @@ +import { + ApolloLink, + Operation, + FetchResult, + Observable, +} from '@apollo/client/core'; +import { print } from 'graphql'; +import { createClient, ClientOptions, Client } from 'graphql-sse'; + +export class SSELink extends ApolloLink { + private client: Client; + + constructor(options: ClientOptions) { + super(); + this.client = createClient(options); + } + + public request(operation: Operation): Observable { + return new Observable((sink) => { + return this.client.subscribe( + { ...operation, query: print(operation.query) }, + { + next: sink.next.bind(sink), + complete: sink.complete.bind(sink), + error: sink.error.bind(sink), + }, + ); + }); + } +} diff --git a/_examples/chat/src/graphql-ws.js b/_examples/chat/src/graphql-ws.js new file mode 100644 index 0000000..8b9f498 --- /dev/null +++ b/_examples/chat/src/graphql-ws.js @@ -0,0 +1,46 @@ +import { createClient } from 'graphql-ws'; +import { print } from 'graphql'; +import { ApolloLink, Observable } from '@apollo/client'; + +export class WebSocketLink extends ApolloLink { + client; + + constructor(options) { + super(); + this.client = createClient(options); + } + + request(operation) { + return new Observable((sink) => { + return this.client.subscribe( + { ...operation, query: print(operation.query) }, + { + next: sink.next.bind(sink), + complete: sink.complete.bind(sink), + error: (err) => { + if (err instanceof Error) { + return sink.error(err); + } + + if (err instanceof CloseEvent) { + return sink.error( + // reason will be available on clean closes + new Error( + `Socket closed with event ${err.code} ${err.reason || ''}`, + ), + ); + } + + return sink.error( + new Error( + err + .map(({ message }) => message) + .join(', '), + ), + ); + }, + }, + ); + }); + } +} \ No newline at end of file diff --git a/_examples/chat/src/index.js b/_examples/chat/src/index.js new file mode 100644 index 0000000..15a6aa2 --- /dev/null +++ b/_examples/chat/src/index.js @@ -0,0 +1,64 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import { + ApolloClient, + ApolloProvider, + HttpLink, + split, + InMemoryCache, +} from '@apollo/client'; +import { WebSocketLink as ApolloWebSocketLink} from '@apollo/client/link/ws'; +import { getMainDefinition } from 'apollo-utilities'; +import { App } from './App'; +import { WebSocketLink as GraphQLWSWebSocketLink } from './graphql-ws' +import { SSELink } from './graphql-sse'; + +let subscriptionLink; +if (process.env.REACT_APP_SSE_PROTOCOL) { + subscriptionLink = new SSELink({ url: 'http://localhost:8085/query' }); +} else if (process.env.REACT_APP_WS_PROTOCOL === 'graphql-transport-ws') { + subscriptionLink = new GraphQLWSWebSocketLink({ + url: `ws://localhost:8085/query` + }); +} else { + subscriptionLink = new ApolloWebSocketLink({ + uri: `ws://localhost:8085/query`, + options: { + reconnect: true + } + }); +} + +const httpLink = new HttpLink({ uri: 'http://localhost:8085/query' }); + + +// depending on what kind of operation is being sent +const link = split( + // split based on operation type + ({ query }) => { + const { kind, operation } = getMainDefinition(query); + return kind === 'OperationDefinition' && operation === 'subscription'; + }, + subscriptionLink, + httpLink, +); + +const apolloClient = new ApolloClient({ + link: link, + cache: new InMemoryCache(), +}); + +if (module.hot) { + module.hot.accept('./App', () => { + const NextApp = require('./App').default; + render(); + }) +} + +function render(component) { + ReactDOM.render( + {component} + , document.getElementById('root')); +} + +render(); diff --git a/_examples/chat/src/react-app-env.d.ts b/_examples/chat/src/react-app-env.d.ts new file mode 100644 index 0000000..6431bc5 --- /dev/null +++ b/_examples/chat/src/react-app-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/_examples/chat/tsconfig.json b/_examples/chat/tsconfig.json new file mode 100644 index 0000000..0980b23 --- /dev/null +++ b/_examples/chat/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], + "allowJs": true, + "skipLibCheck": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "module": "esnext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "preserve" + }, + "include": [ + "src" + ] +} diff --git a/_examples/config/.gqlgen.yml b/_examples/config/.gqlgen.yml new file mode 100644 index 0000000..0ce078b --- /dev/null +++ b/_examples/config/.gqlgen.yml @@ -0,0 +1,24 @@ +# .gqlgen.yml _examples +# +# Refer to https://gqlgen.com/config/ +# for detailed .gqlgen.yml documentation. + +schema: "*.graphql" +exec: + filename: generated.go +model: + filename: models_gen.go +resolver: + type: Resolver + layout: follow-schema + dir: . + +models: + Todo: # Object + fields: + text: + fieldName: Description # Field + NewTodo: # Input + fields: + userId: + fieldName: UserID # Field diff --git a/_examples/config/generated.go b/_examples/config/generated.go new file mode 100644 index 0000000..96216c1 --- /dev/null +++ b/_examples/config/generated.go @@ -0,0 +1,4316 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package config + +import ( + "bytes" + "context" + "embed" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Mutation() MutationResolver + Query() QueryResolver + Todo() TodoResolver + Role() RoleResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + Mutation struct { + CreateTodo func(childComplexity int, input NewTodo) int + } + + Query struct { + Todos func(childComplexity int) int + } + + Todo struct { + DatabaseID func(childComplexity int) int + Description func(childComplexity int) int + Done func(childComplexity int) int + ID func(childComplexity int) int + Mutation func(childComplexity int) int + Query func(childComplexity int) int + User func(childComplexity int) int + } + + User struct { + FullName func(childComplexity int) int + ID func(childComplexity int) int + Role func(childComplexity int) int + } + + Role struct { + Name func(childComplexity int) int + } +} + +type MutationResolver interface { + CreateTodo(ctx context.Context, input NewTodo) (*Todo, error) +} +type QueryResolver interface { + Todos(ctx context.Context) ([]*Todo, error) +} +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 { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = ec + switch typeName + "." + field { + + case "Mutation.createTodo": + if e.complexity.Mutation.CreateTodo == nil { + break + } + + args, err := ec.field_Mutation_createTodo_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.CreateTodo(childComplexity, args["input"].(NewTodo)), true + + case "Query.todos": + if e.complexity.Query.Todos == nil { + break + } + + return e.complexity.Query.Todos(childComplexity), true + + case "Todo.databaseId": + if e.complexity.Todo.DatabaseID == nil { + break + } + + return e.complexity.Todo.DatabaseID(childComplexity), true + + case "Todo.text": + if e.complexity.Todo.Description == nil { + break + } + + return e.complexity.Todo.Description(childComplexity), true + + case "Todo.done": + if e.complexity.Todo.Done == nil { + break + } + + return e.complexity.Todo.Done(childComplexity), true + + case "Todo.id": + if e.complexity.Todo.ID == nil { + break + } + + return e.complexity.Todo.ID(childComplexity), true + + case "Todo.mutation": + if e.complexity.Todo.Mutation == nil { + break + } + + return e.complexity.Todo.Mutation(childComplexity), true + + case "Todo.query": + if e.complexity.Todo.Query == nil { + break + } + + return e.complexity.Todo.Query(childComplexity), true + + case "Todo.user": + if e.complexity.Todo.User == nil { + break + } + + return e.complexity.Todo.User(childComplexity), true + + case "User.name": + if e.complexity.User.FullName == nil { + break + } + + return e.complexity.User.FullName(childComplexity), true + + case "User.id": + if e.complexity.User.ID == nil { + break + } + + 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 +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap( + ec.unmarshalInputNewTodo, + ) + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + case ast.Mutation: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data := ec._Mutation(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + 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 + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + +//go:embed "schema.graphql" "todo.graphql" "user.graphql" +var sourcesFS embed.FS + +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) +} + +var sources = []*ast.Source{ + {Name: "schema.graphql", Input: sourceData("schema.graphql"), BuiltIn: false}, + {Name: "todo.graphql", Input: sourceData("todo.graphql"), BuiltIn: false}, + {Name: "user.graphql", Input: sourceData("user.graphql"), BuiltIn: false}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (ec *executionContext) field_Mutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 NewTodo + if tmp, ok := rawArgs["input"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) + arg0, err = ec.unmarshalNNewTodo2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋconfigᚐNewTodo(ctx, tmp) + if err != nil { + return nil, err + } + } + args["input"] = arg0 + return args, nil +} + +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___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) _Mutation_createTodo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createTodo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateTodo(rctx, fc.Args["input"].(NewTodo)) + }) + 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.(*Todo) + fc.Result = res + return ec.marshalNTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋconfigᚐTodo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_createTodo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Todo_id(ctx, field) + case "databaseId": + return ec.fieldContext_Todo_databaseId(ctx, field) + case "text": + return ec.fieldContext_Todo_text(ctx, field) + case "done": + return ec.fieldContext_Todo_done(ctx, field) + case "user": + return ec.fieldContext_Todo_user(ctx, field) + case "query": + return ec.fieldContext_Todo_query(ctx, field) + case "mutation": + return ec.fieldContext_Todo_mutation(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_createTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_todos(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Todos(rctx) + }) + 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.([]*Todo) + fc.Result = res + return ec.marshalNTodo2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋconfigᚐTodoᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_todos(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Todo_id(ctx, field) + case "databaseId": + return ec.fieldContext_Todo_databaseId(ctx, field) + case "text": + return ec.fieldContext_Todo_text(ctx, field) + case "done": + return ec.fieldContext_Todo_done(ctx, field) + case "user": + return ec.fieldContext_Todo_user(ctx, field) + case "query": + return ec.fieldContext_Todo_query(ctx, field) + case "mutation": + return ec.fieldContext_Todo_mutation(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Todo().ID(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.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Todo_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_databaseId(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DatabaseID, 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.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Todo_databaseId(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_text(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, 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) fieldContext_Todo_text(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_done(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Done, 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) fieldContext_Todo_done(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_user(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.User, 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.(*User) + fc.Result = res + return ec.marshalNUser2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋconfigᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Todo_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "role": + return ec.fieldContext_User_role(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_query(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_query(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + res := &Query{} + fc.Result = res + return ec.marshalNQuery2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋconfigᚐQuery(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Todo_query(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "todos": + return ec.fieldContext_Query_todos(ctx, field) + case "__schema": + return ec.fieldContext_Query___schema(ctx, field) + case "__type": + return ec.fieldContext_Query___type(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Query", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_mutation(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_mutation(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + res := &Mutation{} + fc.Result = res + return ec.marshalNMutation2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋconfigᚐMutation(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Todo_mutation(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "createTodo": + return ec.fieldContext_Mutation_createTodo(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Mutation", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.FullName(), 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) fieldContext_User_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_role(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_role(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋ_examplesᚋconfigᚐUserRole(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_role(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_role_name(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type role", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), 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.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), 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.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), 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.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _role_name(ctx context.Context, field graphql.CollectedField, obj *UserRole) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_role_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) +} + +func (ec *executionContext) fieldContext_role_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "role", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputNewTodo(ctx context.Context, obj interface{}) (NewTodo, error) { + var it NewTodo + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"text", "userId"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "text": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Text = data + case "userId": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userId")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.UserID = data + } + } + + return it, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +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) + deferred := make(map[string]*graphql.FieldSet) + 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.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_createTodo(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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 + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_todos(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Todo") + case "id": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Todo_id(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "databaseId": + out.Values[i] = ec._Todo_databaseId(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "text": + out.Values[i] = ec._Todo_text(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "done": + out.Values[i] = ec._Todo_done(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "user": + out.Values[i] = ec._Todo_user(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "query": + out.Values[i] = ec._Todo_query(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "mutation": + out.Values[i] = ec._Todo_mutation(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("User") + case "id": + out.Values[i] = ec._User_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec._User_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "role": + out.Values[i] = ec._User_role(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNMutation2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋconfigᚐMutation(ctx context.Context, sel ast.SelectionSet, v *Mutation) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Mutation(ctx, sel) +} + +func (ec *executionContext) unmarshalNNewTodo2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋconfigᚐNewTodo(ctx context.Context, v interface{}) (NewTodo, error) { + res, err := ec.unmarshalInputNewTodo(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNQuery2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋconfigᚐQuery(ctx context.Context, sel ast.SelectionSet, v *Query) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Query(ctx, sel) +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNTodo2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋconfigᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { + return ec._Todo(ctx, sel, &v) +} + +func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋconfigᚐTodoᚄ(ctx context.Context, sel ast.SelectionSet, v []*Todo) 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.marshalNTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋconfigᚐTodo(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) marshalNTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋconfigᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Todo(ctx, sel, v) +} + +func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋconfigᚐUser(ctx context.Context, sel ast.SelectionSet, v *User) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._User(ctx, sel, v) +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNrole2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋ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 { + 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) unmarshalOString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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 + } + 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) marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/_examples/config/model.go b/_examples/config/model.go new file mode 100644 index 0000000..4632c4e --- /dev/null +++ b/_examples/config/model.go @@ -0,0 +1,17 @@ +package config + +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/_examples/config/models_gen.go b/_examples/config/models_gen.go new file mode 100644 index 0000000..726dedb --- /dev/null +++ b/_examples/config/models_gen.go @@ -0,0 +1,24 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package config + +type Mutation struct { +} + +type NewTodo struct { + Text string `json:"text"` + UserID string `json:"userId"` +} + +type Query struct { +} + +type Todo struct { + ID string `json:"id"` + DatabaseID int `json:"databaseId"` + Description string `json:"text"` + Done bool `json:"done"` + User *User `json:"user"` + Query *Query `json:"query"` + Mutation *Mutation `json:"mutation"` +} diff --git a/_examples/config/resolver.go b/_examples/config/resolver.go new file mode 100644 index 0000000..182634a --- /dev/null +++ b/_examples/config/resolver.go @@ -0,0 +1,22 @@ +//go:generate go run ../../testdata/gqlgen.go + +package config + +func New() Config { + c := Config{ + Resolvers: &Resolver{ + todos: []*Todo{ + {DatabaseID: 1, Description: "A todo not to forget", Done: false}, + {DatabaseID: 2, Description: "This is the most important", Done: false}, + {DatabaseID: 3, Description: "Please do this or else", Done: false}, + }, + nextID: 3, + }, + } + return c +} + +type Resolver struct { + todos []*Todo + nextID int +} diff --git a/_examples/config/schema.graphql b/_examples/config/schema.graphql new file mode 100644 index 0000000..1823b5e --- /dev/null +++ b/_examples/config/schema.graphql @@ -0,0 +1,10 @@ +directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION +directive @goField(forceResolver: Boolean, name: String, omittable: Boolean) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION + +type Query { + todos: [Todo!]! +} + +type Mutation { + createTodo(input: NewTodo!): Todo! +} diff --git a/_examples/config/schema.resolvers.go b/_examples/config/schema.resolvers.go new file mode 100644 index 0000000..70ce1e0 --- /dev/null +++ b/_examples/config/schema.resolvers.go @@ -0,0 +1,38 @@ +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. +// Code generated by github.com/niko0xdev/gqlgen version v0.17.42-dev + +import ( + "context" +) + +// CreateTodo is the resolver for the createTodo field. +func (r *mutationResolver) CreateTodo(ctx context.Context, input NewTodo) (*Todo, error) { + newID := r.nextID + r.nextID++ + + newTodo := &Todo{ + DatabaseID: newID, + Description: input.Text, + } + + r.todos = append(r.todos, newTodo) + + return newTodo, nil +} + +// Todos is the resolver for the todos field. +func (r *queryResolver) Todos(ctx context.Context) ([]*Todo, error) { + return r.todos, nil +} + +// Mutation returns MutationResolver implementation. +func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } + +// Query returns QueryResolver implementation. +func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } + +type mutationResolver struct{ *Resolver } +type queryResolver struct{ *Resolver } diff --git a/_examples/config/server/server.go b/_examples/config/server/server.go new file mode 100644 index 0000000..ff4cec3 --- /dev/null +++ b/_examples/config/server/server.go @@ -0,0 +1,18 @@ +package main + +import ( + "log" + "net/http" + + todo "github.com/niko0xdev/gqlgen/_examples/config" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/playground" +) + +func main() { + http.Handle("/", playground.Handler("Todo", "/query")) + http.Handle("/query", handler.NewDefaultServer( + todo.NewExecutableSchema(todo.New()), + )) + log.Fatal(http.ListenAndServe(":8081", nil)) +} diff --git a/_examples/config/todo.graphql b/_examples/config/todo.graphql new file mode 100644 index 0000000..39590ed --- /dev/null +++ b/_examples/config/todo.graphql @@ -0,0 +1,14 @@ +type Todo { + id: ID! @goField(forceResolver: true) + databaseId: Int! + text: String! + done: Boolean! + user: User! + query: Query! + mutation: Mutation! +} + +input NewTodo { + text: String! + userId: String! +} diff --git a/_examples/config/todo.resolvers.go b/_examples/config/todo.resolvers.go new file mode 100644 index 0000000..77da66d --- /dev/null +++ b/_examples/config/todo.resolvers.go @@ -0,0 +1,26 @@ +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. +// Code generated by github.com/niko0xdev/gqlgen version v0.17.42-dev + +import ( + "context" + "fmt" +) + +// ID is the resolver for the id field. +func (r *todoResolver) ID(ctx context.Context, obj *Todo) (string, error) { + if obj.ID != "" { + return obj.ID, nil + } + + obj.ID = fmt.Sprintf("TODO:%d", obj.DatabaseID) + + return obj.ID, nil +} + +// Todo returns TodoResolver implementation. +func (r *Resolver) Todo() TodoResolver { return &todoResolver{r} } + +type todoResolver struct{ *Resolver } diff --git a/_examples/config/user.graphql b/_examples/config/user.graphql new file mode 100644 index 0000000..7b6881a --- /dev/null +++ b/_examples/config/user.graphql @@ -0,0 +1,11 @@ +type User +@goModel(model:"github.com/niko0xdev/gqlgen/_examples/config.User") { + id: ID! + name: String! @goField(name:"FullName") + role: role! +} + +type role +@goModel(model:"github.com/niko0xdev/gqlgen/_examples/config.UserRole") { + name: String! +} diff --git a/_examples/config/user.resolvers.go b/_examples/config/user.resolvers.go new file mode 100644 index 0000000..cac59f5 --- /dev/null +++ b/_examples/config/user.resolvers.go @@ -0,0 +1,22 @@ +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. +// Code generated by github.com/niko0xdev/gqlgen version v0.17.42-dev + +import ( + "context" +) + +// Name is the resolver for the name field. +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/_examples/dataloader/.gqlgen.yml b/_examples/dataloader/.gqlgen.yml new file mode 100644 index 0000000..59804d2 --- /dev/null +++ b/_examples/dataloader/.gqlgen.yml @@ -0,0 +1,5 @@ +models: + Order: + model: github.com/niko0xdev/gqlgen/_examples/dataloader.Order + Customer: + model: github.com/niko0xdev/gqlgen/_examples/dataloader.Customer diff --git a/_examples/dataloader/addressloader_gen.go b/_examples/dataloader/addressloader_gen.go new file mode 100644 index 0000000..c55a2c8 --- /dev/null +++ b/_examples/dataloader/addressloader_gen.go @@ -0,0 +1,222 @@ +// Code generated by github.com/vektah/dataloaden, DO NOT EDIT. + +package dataloader + +import ( + "sync" + "time" +) + +// AddressLoaderConfig captures the config to create a new AddressLoader +type AddressLoaderConfig struct { + // Fetch is a method that provides the data for the loader + Fetch func(keys []int) ([]*Address, []error) + + // Wait is how long wait before sending a batch + Wait time.Duration + + // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit + MaxBatch int +} + +// NewAddressLoader creates a new AddressLoader given a fetch, wait, and maxBatch +func NewAddressLoader(config AddressLoaderConfig) *AddressLoader { + return &AddressLoader{ + fetch: config.Fetch, + wait: config.Wait, + maxBatch: config.MaxBatch, + } +} + +// AddressLoader batches and caches requests +type AddressLoader struct { + // this method provides the data for the loader + fetch func(keys []int) ([]*Address, []error) + + // how long to done before sending a batch + wait time.Duration + + // this will limit the maximum number of keys to send in one batch, 0 = no limit + maxBatch int + + // INTERNAL + + // lazily created cache + cache map[int]*Address + + // the current batch. keys will continue to be collected until timeout is hit, + // then everything will be sent to the fetch method and out to the listeners + batch *addressLoaderBatch + + // mutex to prevent races + mu sync.Mutex +} + +type addressLoaderBatch struct { + keys []int + data []*Address + error []error + closing bool + done chan struct{} +} + +// Load a Address by key, batching and caching will be applied automatically +func (l *AddressLoader) Load(key int) (*Address, error) { + return l.LoadThunk(key)() +} + +// LoadThunk returns a function that when called will block waiting for a Address. +// This method should be used if you want one goroutine to make requests to many +// different data loaders without blocking until the thunk is called. +func (l *AddressLoader) LoadThunk(key int) func() (*Address, error) { + l.mu.Lock() + if it, ok := l.cache[key]; ok { + l.mu.Unlock() + return func() (*Address, error) { + return it, nil + } + } + if l.batch == nil { + l.batch = &addressLoaderBatch{done: make(chan struct{})} + } + batch := l.batch + pos := batch.keyIndex(l, key) + l.mu.Unlock() + + return func() (*Address, error) { + <-batch.done + + var data *Address + if pos < len(batch.data) { + data = batch.data[pos] + } + + var err error + // its convenient to be able to return a single error for everything + if len(batch.error) == 1 { + err = batch.error[0] + } else if batch.error != nil { + err = batch.error[pos] + } + + if err == nil { + l.mu.Lock() + l.unsafeSet(key, data) + l.mu.Unlock() + } + + return data, err + } +} + +// LoadAll fetches many keys at once. It will be broken into appropriate sized +// sub batches depending on how the loader is configured +func (l *AddressLoader) LoadAll(keys []int) ([]*Address, []error) { + results := make([]func() (*Address, error), len(keys)) + + for i, key := range keys { + results[i] = l.LoadThunk(key) + } + + addresss := make([]*Address, len(keys)) + errors := make([]error, len(keys)) + for i, thunk := range results { + addresss[i], errors[i] = thunk() + } + return addresss, errors +} + +// LoadAllThunk returns a function that when called will block waiting for a Addresss. +// This method should be used if you want one goroutine to make requests to many +// different data loaders without blocking until the thunk is called. +func (l *AddressLoader) LoadAllThunk(keys []int) func() ([]*Address, []error) { + results := make([]func() (*Address, error), len(keys)) + for i, key := range keys { + results[i] = l.LoadThunk(key) + } + return func() ([]*Address, []error) { + addresss := make([]*Address, len(keys)) + errors := make([]error, len(keys)) + for i, thunk := range results { + addresss[i], errors[i] = thunk() + } + return addresss, errors + } +} + +// Prime the cache with the provided key and value. If the key already exists, no change is made +// and false is returned. +// (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).) +func (l *AddressLoader) Prime(key int, value *Address) bool { + l.mu.Lock() + var found bool + if _, found = l.cache[key]; !found { + // make a copy when writing to the cache, its easy to pass a pointer in from a loop var + // and end up with the whole cache pointing to the same value. + cpy := *value + l.unsafeSet(key, &cpy) + } + l.mu.Unlock() + return !found +} + +// Clear the value at key from the cache, if it exists +func (l *AddressLoader) Clear(key int) { + l.mu.Lock() + delete(l.cache, key) + l.mu.Unlock() +} + +func (l *AddressLoader) unsafeSet(key int, value *Address) { + if l.cache == nil { + l.cache = map[int]*Address{} + } + l.cache[key] = value +} + +// keyIndex will return the location of the key in the batch, if its not found +// it will add the key to the batch +func (b *addressLoaderBatch) keyIndex(l *AddressLoader, key int) int { + for i, existingKey := range b.keys { + if key == existingKey { + return i + } + } + + pos := len(b.keys) + b.keys = append(b.keys, key) + if pos == 0 { + go b.startTimer(l) + } + + if l.maxBatch != 0 && pos >= l.maxBatch-1 { + if !b.closing { + b.closing = true + l.batch = nil + go b.end(l) + } + } + + return pos +} + +func (b *addressLoaderBatch) startTimer(l *AddressLoader) { + time.Sleep(l.wait) + l.mu.Lock() + + // we must have hit a batch limit and are already finalizing this batch + if b.closing { + l.mu.Unlock() + return + } + + l.batch = nil + l.mu.Unlock() + + b.end(l) +} + +func (b *addressLoaderBatch) end(l *AddressLoader) { + b.data, b.error = l.fetch(b.keys) + close(b.done) +} diff --git a/_examples/dataloader/dataloader_test.go b/_examples/dataloader/dataloader_test.go new file mode 100644 index 0000000..63166ff --- /dev/null +++ b/_examples/dataloader/dataloader_test.go @@ -0,0 +1,88 @@ +package dataloader + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/introspection" +) + +func TestTodo(t *testing.T) { + c := client.New(LoaderMiddleware(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: &Resolver{}})))) + + t.Run("create a new todo", func(t *testing.T) { + var resp interface{} + c.MustPost(`{ + customers { + name + address { + street + + } + orders { + id + amount + items { + name + } + } + } + }`, &resp) + }) + + t.Run("2d array marshaling", func(t *testing.T) { + var resp struct { + Torture2d [][]Customer + } + c.MustPost(`{ torture2d(customerIds:[[1,2],[3,4,5]]) { id name } }`, &resp) + + require.EqualValues(t, [][]Customer{ + {{ID: 1, Name: "0 0"}, {ID: 2, Name: "0 1"}}, + {{ID: 3, Name: "1 0"}, {ID: 4, Name: "1 1"}, {ID: 5, Name: "1 2"}}, + }, resp.Torture2d) + }) + + // Input coercion on arrays should convert non array values into an array of the appropriate depth + // http://facebook.github.io/graphql/June2018/#sec-Type-System.List + t.Run("array coercion", func(t *testing.T) { + t.Run("1d", func(t *testing.T) { + var resp struct { + Torture1d []Customer + } + c.MustPost(`{ torture1d(customerIds: 1) { id name } }`, &resp) + + require.EqualValues(t, []Customer{ + {ID: 1, Name: "0"}, + }, resp.Torture1d) + }) + + t.Run("2d", func(t *testing.T) { + var resp struct { + Torture2d [][]Customer + } + c.MustPost(`{ torture2d(customerIds: 1) { id name } }`, &resp) + + require.EqualValues(t, [][]Customer{ + {{ID: 1, Name: "0 0"}}, + }, resp.Torture2d) + }) + }) + + t.Run("introspection", func(t *testing.T) { + // Make sure we can run the graphiql introspection query without errors + var resp interface{} + c.MustPost(introspection.Query, &resp) + }) + + t.Run("customer array torture malformed array query", func(t *testing.T) { + var resp struct { + Torture [][]Customer + } + err := c.Post(`{ torture2d(customerIds:{}) { id name } }`, &resp) + + require.EqualError(t, err, "[{\"message\":\"map[string]interface {} is not an int\",\"path\":[\"torture2d\",\"customerIds\",0,0]}]") + }) +} diff --git a/_examples/dataloader/dataloaders.go b/_examples/dataloader/dataloaders.go new file mode 100644 index 0000000..144f185 --- /dev/null +++ b/_examples/dataloader/dataloaders.go @@ -0,0 +1,120 @@ +//go:generate go run github.com/vektah/dataloaden AddressLoader int *github.com/niko0xdev/gqlgen/_examples/dataloader.Address +//go:generate go run github.com/vektah/dataloaden OrderSliceLoader int []*github.com/niko0xdev/gqlgen/_examples/dataloader.Order +//go:generate go run github.com/vektah/dataloaden ItemSliceLoader int []*github.com/niko0xdev/gqlgen/_examples/dataloader.Item + +package dataloader + +import ( + "context" + "fmt" + "math/rand" + "net/http" + "strconv" + "strings" + "time" +) + +type ctxKeyType struct{ name string } + +var ctxKey = ctxKeyType{"userCtx"} + +type loaders struct { + addressByID *AddressLoader + ordersByCustomer *OrderSliceLoader + itemsByOrder *ItemSliceLoader +} + +// nolint: gosec +func LoaderMiddleware(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ldrs := loaders{} + + // set this to zero what happens without dataloading + wait := 250 * time.Microsecond + + // simple 1:1 loader, fetch an address by its primary key + ldrs.addressByID = &AddressLoader{ + wait: wait, + maxBatch: 100, + fetch: func(keys []int) ([]*Address, []error) { + var keySql []string + for _, key := range keys { + keySql = append(keySql, strconv.Itoa(key)) + } + + fmt.Printf("SELECT * FROM address WHERE id IN (%s)\n", strings.Join(keySql, ",")) + time.Sleep(5 * time.Millisecond) + + addresses := make([]*Address, len(keys)) + errors := make([]error, len(keys)) + for i, key := range keys { + addresses[i] = &Address{Street: "home street", Country: "hometon " + strconv.Itoa(key)} + } + return addresses, errors + }, + } + + // 1:M loader + ldrs.ordersByCustomer = &OrderSliceLoader{ + wait: wait, + maxBatch: 100, + fetch: func(keys []int) ([][]*Order, []error) { + var keySql []string + for _, key := range keys { + keySql = append(keySql, strconv.Itoa(key)) + } + + fmt.Printf("SELECT * FROM orders WHERE customer_id IN (%s)\n", strings.Join(keySql, ",")) + time.Sleep(5 * time.Millisecond) + + orders := make([][]*Order, len(keys)) + errors := make([]error, len(keys)) + for i, key := range keys { + id := 10 + rand.Int()%3 + orders[i] = []*Order{ + {ID: id, Amount: rand.Float64(), Date: time.Now().Add(-time.Duration(key) * time.Hour)}, + {ID: id + 1, Amount: rand.Float64(), Date: time.Now().Add(-time.Duration(key) * time.Hour)}, + } + + // if you had another customer loader you would prime its cache here + // by calling `ldrs.ordersByID.Prime(id, orders[i])` + } + + return orders, errors + }, + } + + // M:M loader + ldrs.itemsByOrder = &ItemSliceLoader{ + wait: wait, + maxBatch: 100, + fetch: func(keys []int) ([][]*Item, []error) { + var keySql []string + for _, key := range keys { + keySql = append(keySql, strconv.Itoa(key)) + } + + fmt.Printf("SELECT * FROM items JOIN item_order WHERE item_order.order_id IN (%s)\n", strings.Join(keySql, ",")) + time.Sleep(5 * time.Millisecond) + + items := make([][]*Item, len(keys)) + errors := make([]error, len(keys)) + for i := range keys { + items[i] = []*Item{ + {Name: "item " + strconv.Itoa(rand.Int()%20+20)}, + {Name: "item " + strconv.Itoa(rand.Int()%20+20)}, + } + } + + return items, errors + }, + } + + dlCtx := context.WithValue(r.Context(), ctxKey, ldrs) + next.ServeHTTP(w, r.WithContext(dlCtx)) + }) +} + +func ctxLoaders(ctx context.Context) loaders { + return ctx.Value(ctxKey).(loaders) +} diff --git a/_examples/dataloader/generated.go b/_examples/dataloader/generated.go new file mode 100644 index 0000000..2672e16 --- /dev/null +++ b/_examples/dataloader/generated.go @@ -0,0 +1,4620 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package dataloader + +import ( + "bytes" + "context" + "embed" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + "time" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Customer() CustomerResolver + Order() OrderResolver + Query() QueryResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + Address struct { + Country func(childComplexity int) int + ID func(childComplexity int) int + Street func(childComplexity int) int + } + + Customer struct { + Address func(childComplexity int) int + ID func(childComplexity int) int + Name func(childComplexity int) int + Orders func(childComplexity int) int + } + + Item struct { + Name func(childComplexity int) int + } + + Order struct { + Amount func(childComplexity int) int + Date func(childComplexity int) int + ID func(childComplexity int) int + Items func(childComplexity int) int + } + + Query struct { + Customers func(childComplexity int) int + Torture1d func(childComplexity int, customerIds []int) int + Torture2d func(childComplexity int, customerIds [][]int) int + } +} + +type CustomerResolver interface { + Address(ctx context.Context, obj *Customer) (*Address, error) + Orders(ctx context.Context, obj *Customer) ([]*Order, error) +} +type OrderResolver interface { + Items(ctx context.Context, obj *Order) ([]*Item, error) +} +type QueryResolver interface { + Customers(ctx context.Context) ([]*Customer, error) + Torture1d(ctx context.Context, customerIds []int) ([]*Customer, error) + Torture2d(ctx context.Context, customerIds [][]int) ([][]*Customer, error) +} + +type executableSchema struct { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = ec + switch typeName + "." + field { + + case "Address.country": + if e.complexity.Address.Country == nil { + break + } + + return e.complexity.Address.Country(childComplexity), true + + case "Address.id": + if e.complexity.Address.ID == nil { + break + } + + return e.complexity.Address.ID(childComplexity), true + + case "Address.street": + if e.complexity.Address.Street == nil { + break + } + + return e.complexity.Address.Street(childComplexity), true + + case "Customer.address": + if e.complexity.Customer.Address == nil { + break + } + + return e.complexity.Customer.Address(childComplexity), true + + case "Customer.id": + if e.complexity.Customer.ID == nil { + break + } + + return e.complexity.Customer.ID(childComplexity), true + + case "Customer.name": + if e.complexity.Customer.Name == nil { + break + } + + return e.complexity.Customer.Name(childComplexity), true + + case "Customer.orders": + if e.complexity.Customer.Orders == nil { + break + } + + return e.complexity.Customer.Orders(childComplexity), true + + case "Item.name": + if e.complexity.Item.Name == nil { + break + } + + return e.complexity.Item.Name(childComplexity), true + + case "Order.amount": + if e.complexity.Order.Amount == nil { + break + } + + return e.complexity.Order.Amount(childComplexity), true + + case "Order.date": + if e.complexity.Order.Date == nil { + break + } + + return e.complexity.Order.Date(childComplexity), true + + case "Order.id": + if e.complexity.Order.ID == nil { + break + } + + return e.complexity.Order.ID(childComplexity), true + + case "Order.items": + if e.complexity.Order.Items == nil { + break + } + + return e.complexity.Order.Items(childComplexity), true + + case "Query.customers": + if e.complexity.Query.Customers == nil { + break + } + + return e.complexity.Query.Customers(childComplexity), true + + case "Query.torture1d": + if e.complexity.Query.Torture1d == nil { + break + } + + args, err := ec.field_Query_torture1d_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Torture1d(childComplexity, args["customerIds"].([]int)), true + + case "Query.torture2d": + if e.complexity.Query.Torture2d == nil { + break + } + + args, err := ec.field_Query_torture2d_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Torture2d(childComplexity, args["customerIds"].([][]int)), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap() + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } +} + +type executionContext struct { + *graphql.OperationContext + *executableSchema + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + +//go:embed "schema.graphql" +var sourcesFS embed.FS + +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) +} + +var sources = []*ast.Source{ + {Name: "schema.graphql", Input: sourceData("schema.graphql"), BuiltIn: false}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// 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_torture1d_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["customerIds"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("customerIds")) + arg0, err = ec.unmarshalOInt2ᚕintᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["customerIds"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_torture2d_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["customerIds"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("customerIds")) + arg0, err = ec.unmarshalOInt2ᚕᚕint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["customerIds"] = arg0 + return args, nil +} + +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) _Address_id(ctx context.Context, field graphql.CollectedField, obj *Address) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Address_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Address_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Address", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Address_street(ctx context.Context, field graphql.CollectedField, obj *Address) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Address_street(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Street, 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) fieldContext_Address_street(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Address", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Address_country(ctx context.Context, field graphql.CollectedField, obj *Address) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Address_country(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Country, 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) fieldContext_Address_country(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Address", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Customer_id(ctx context.Context, field graphql.CollectedField, obj *Customer) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Customer_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Customer_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Customer", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Customer_name(ctx context.Context, field graphql.CollectedField, obj *Customer) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Customer_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Customer_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Customer", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Customer_address(ctx context.Context, field graphql.CollectedField, obj *Customer) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Customer_address(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Customer().Address(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Address) + fc.Result = res + return ec.marshalOAddress2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋdataloaderᚐAddress(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Customer_address(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Customer", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Address_id(ctx, field) + case "street": + return ec.fieldContext_Address_street(ctx, field) + case "country": + return ec.fieldContext_Address_country(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Address", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Customer_orders(ctx context.Context, field graphql.CollectedField, obj *Customer) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Customer_orders(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Customer().Orders(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*Order) + fc.Result = res + return ec.marshalOOrder2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋdataloaderᚐOrderᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Customer_orders(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Customer", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Order_id(ctx, field) + case "date": + return ec.fieldContext_Order_date(ctx, field) + case "amount": + return ec.fieldContext_Order_amount(ctx, field) + case "items": + return ec.fieldContext_Order_items(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Order", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Item_name(ctx context.Context, field graphql.CollectedField, obj *Item) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Item_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Item_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Item", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Order_id(ctx context.Context, field graphql.CollectedField, obj *Order) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Order_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Order_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Order", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Order_date(ctx context.Context, field graphql.CollectedField, obj *Order) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Order_date(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Date, 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.(time.Time) + fc.Result = res + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Order_date(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Order", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Order_amount(ctx context.Context, field graphql.CollectedField, obj *Order) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Order_amount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Amount, 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.(float64) + fc.Result = res + return ec.marshalNFloat2float64(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Order_amount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Order", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Order_items(ctx context.Context, field graphql.CollectedField, obj *Order) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Order_items(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Order().Items(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*Item) + fc.Result = res + return ec.marshalOItem2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋdataloaderᚐItemᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Order_items(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Order", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_Item_name(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Item", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_customers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_customers(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Customers(rctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*Customer) + fc.Result = res + return ec.marshalOCustomer2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋdataloaderᚐCustomerᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_customers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Customer_id(ctx, field) + case "name": + return ec.fieldContext_Customer_name(ctx, field) + case "address": + return ec.fieldContext_Customer_address(ctx, field) + case "orders": + return ec.fieldContext_Customer_orders(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Customer", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_torture1d(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_torture1d(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Torture1d(rctx, fc.Args["customerIds"].([]int)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*Customer) + fc.Result = res + return ec.marshalOCustomer2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋdataloaderᚐCustomerᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_torture1d(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Customer_id(ctx, field) + case "name": + return ec.fieldContext_Customer_name(ctx, field) + case "address": + return ec.fieldContext_Customer_address(ctx, field) + case "orders": + return ec.fieldContext_Customer_orders(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Customer", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_torture1d_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_torture2d(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Torture2d(rctx, fc.Args["customerIds"].([][]int)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([][]*Customer) + fc.Result = res + return ec.marshalOCustomer2ᚕᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋdataloaderᚐCustomer(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_torture2d(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Customer_id(ctx, field) + case "name": + return ec.fieldContext_Customer_name(ctx, field) + case "address": + return ec.fieldContext_Customer_address(ctx, field) + case "orders": + return ec.fieldContext_Customer_orders(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Customer", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_torture2d_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), 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.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), 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.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), 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.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Address") + case "id": + out.Values[i] = ec._Address_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "street": + out.Values[i] = ec._Address_street(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "country": + out.Values[i] = ec._Address_country(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Customer") + case "id": + out.Values[i] = ec._Customer_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "name": + out.Values[i] = ec._Customer_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "address": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Customer_address(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "orders": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Customer_orders(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Item") + case "name": + out.Values[i] = ec._Item_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Order") + case "id": + out.Values[i] = ec._Order_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "date": + out.Values[i] = ec._Order_date(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "amount": + out.Values[i] = ec._Order_amount(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "items": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Order_items(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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 + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_customers(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "torture1d": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_torture1d(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "torture2d": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_torture2d(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNCustomer2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v *Customer) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Customer(ctx, sel, v) +} + +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, "the requested element is null which the schema does not allow") + } + } + return graphql.WrapContextMarshaler(ctx, 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNItem2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋdataloaderᚐItem(ctx context.Context, sel ast.SelectionSet, v *Item) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Item(ctx, sel, v) +} + +func (ec *executionContext) marshalNOrder2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋdataloaderᚐOrder(ctx context.Context, sel ast.SelectionSet, v *Order) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Order(ctx, sel, v) +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalOAddress2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋdataloaderᚐAddress(ctx context.Context, sel ast.SelectionSet, v *Address) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Address(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 { + 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) marshalOCustomer2ᚕᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v [][]*Customer) 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.marshalOCustomer2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋdataloaderᚐCustomerᚄ(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) marshalOCustomer2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋdataloaderᚐCustomerᚄ(ctx context.Context, sel ast.SelectionSet, v []*Customer) 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.marshalNCustomer2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋdataloaderᚐCustomer(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) unmarshalOInt2ᚕintᚄ(ctx context.Context, v interface{}) ([]int, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]int, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNInt2int(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalOInt2ᚕintᚄ(ctx context.Context, sel ast.SelectionSet, v []int) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNInt2int(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) unmarshalOInt2ᚕᚕint(ctx context.Context, v interface{}) ([][]int, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([][]int, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalOInt2ᚕintᚄ(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalOInt2ᚕᚕint(ctx context.Context, sel ast.SelectionSet, v [][]int) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalOInt2ᚕintᚄ(ctx, sel, v[i]) + } + + return ret +} + +func (ec *executionContext) marshalOItem2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋdataloaderᚐItemᚄ(ctx context.Context, sel ast.SelectionSet, v []*Item) 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.marshalNItem2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋdataloaderᚐItem(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) marshalOOrder2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋdataloaderᚐOrderᚄ(ctx context.Context, sel ast.SelectionSet, v []*Order) 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.marshalNOrder2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋdataloaderᚐOrder(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) 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) marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/_examples/dataloader/itemsliceloader_gen.go b/_examples/dataloader/itemsliceloader_gen.go new file mode 100644 index 0000000..f5a3850 --- /dev/null +++ b/_examples/dataloader/itemsliceloader_gen.go @@ -0,0 +1,223 @@ +// Code generated by github.com/vektah/dataloaden, DO NOT EDIT. + +package dataloader + +import ( + "sync" + "time" +) + +// ItemSliceLoaderConfig captures the config to create a new ItemSliceLoader +type ItemSliceLoaderConfig struct { + // Fetch is a method that provides the data for the loader + Fetch func(keys []int) ([][]*Item, []error) + + // Wait is how long wait before sending a batch + Wait time.Duration + + // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit + MaxBatch int +} + +// NewItemSliceLoader creates a new ItemSliceLoader given a fetch, wait, and maxBatch +func NewItemSliceLoader(config ItemSliceLoaderConfig) *ItemSliceLoader { + return &ItemSliceLoader{ + fetch: config.Fetch, + wait: config.Wait, + maxBatch: config.MaxBatch, + } +} + +// ItemSliceLoader batches and caches requests +type ItemSliceLoader struct { + // this method provides the data for the loader + fetch func(keys []int) ([][]*Item, []error) + + // how long to done before sending a batch + wait time.Duration + + // this will limit the maximum number of keys to send in one batch, 0 = no limit + maxBatch int + + // INTERNAL + + // lazily created cache + cache map[int][]*Item + + // the current batch. keys will continue to be collected until timeout is hit, + // then everything will be sent to the fetch method and out to the listeners + batch *itemSliceLoaderBatch + + // mutex to prevent races + mu sync.Mutex +} + +type itemSliceLoaderBatch struct { + keys []int + data [][]*Item + error []error + closing bool + done chan struct{} +} + +// Load a Item by key, batching and caching will be applied automatically +func (l *ItemSliceLoader) Load(key int) ([]*Item, error) { + return l.LoadThunk(key)() +} + +// LoadThunk returns a function that when called will block waiting for a Item. +// This method should be used if you want one goroutine to make requests to many +// different data loaders without blocking until the thunk is called. +func (l *ItemSliceLoader) LoadThunk(key int) func() ([]*Item, error) { + l.mu.Lock() + if it, ok := l.cache[key]; ok { + l.mu.Unlock() + return func() ([]*Item, error) { + return it, nil + } + } + if l.batch == nil { + l.batch = &itemSliceLoaderBatch{done: make(chan struct{})} + } + batch := l.batch + pos := batch.keyIndex(l, key) + l.mu.Unlock() + + return func() ([]*Item, error) { + <-batch.done + + var data []*Item + if pos < len(batch.data) { + data = batch.data[pos] + } + + var err error + // its convenient to be able to return a single error for everything + if len(batch.error) == 1 { + err = batch.error[0] + } else if batch.error != nil { + err = batch.error[pos] + } + + if err == nil { + l.mu.Lock() + l.unsafeSet(key, data) + l.mu.Unlock() + } + + return data, err + } +} + +// LoadAll fetches many keys at once. It will be broken into appropriate sized +// sub batches depending on how the loader is configured +func (l *ItemSliceLoader) LoadAll(keys []int) ([][]*Item, []error) { + results := make([]func() ([]*Item, error), len(keys)) + + for i, key := range keys { + results[i] = l.LoadThunk(key) + } + + items := make([][]*Item, len(keys)) + errors := make([]error, len(keys)) + for i, thunk := range results { + items[i], errors[i] = thunk() + } + return items, errors +} + +// LoadAllThunk returns a function that when called will block waiting for a Items. +// This method should be used if you want one goroutine to make requests to many +// different data loaders without blocking until the thunk is called. +func (l *ItemSliceLoader) LoadAllThunk(keys []int) func() ([][]*Item, []error) { + results := make([]func() ([]*Item, error), len(keys)) + for i, key := range keys { + results[i] = l.LoadThunk(key) + } + return func() ([][]*Item, []error) { + items := make([][]*Item, len(keys)) + errors := make([]error, len(keys)) + for i, thunk := range results { + items[i], errors[i] = thunk() + } + return items, errors + } +} + +// Prime the cache with the provided key and value. If the key already exists, no change is made +// and false is returned. +// (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).) +func (l *ItemSliceLoader) Prime(key int, value []*Item) bool { + l.mu.Lock() + var found bool + if _, found = l.cache[key]; !found { + // make a copy when writing to the cache, its easy to pass a pointer in from a loop var + // and end up with the whole cache pointing to the same value. + cpy := make([]*Item, len(value)) + copy(cpy, value) + l.unsafeSet(key, cpy) + } + l.mu.Unlock() + return !found +} + +// Clear the value at key from the cache, if it exists +func (l *ItemSliceLoader) Clear(key int) { + l.mu.Lock() + delete(l.cache, key) + l.mu.Unlock() +} + +func (l *ItemSliceLoader) unsafeSet(key int, value []*Item) { + if l.cache == nil { + l.cache = map[int][]*Item{} + } + l.cache[key] = value +} + +// keyIndex will return the location of the key in the batch, if its not found +// it will add the key to the batch +func (b *itemSliceLoaderBatch) keyIndex(l *ItemSliceLoader, key int) int { + for i, existingKey := range b.keys { + if key == existingKey { + return i + } + } + + pos := len(b.keys) + b.keys = append(b.keys, key) + if pos == 0 { + go b.startTimer(l) + } + + if l.maxBatch != 0 && pos >= l.maxBatch-1 { + if !b.closing { + b.closing = true + l.batch = nil + go b.end(l) + } + } + + return pos +} + +func (b *itemSliceLoaderBatch) startTimer(l *ItemSliceLoader) { + time.Sleep(l.wait) + l.mu.Lock() + + // we must have hit a batch limit and are already finalizing this batch + if b.closing { + l.mu.Unlock() + return + } + + l.batch = nil + l.mu.Unlock() + + b.end(l) +} + +func (b *itemSliceLoaderBatch) end(l *ItemSliceLoader) { + b.data, b.error = l.fetch(b.keys) + close(b.done) +} diff --git a/_examples/dataloader/models_gen.go b/_examples/dataloader/models_gen.go new file mode 100644 index 0000000..0b677b9 --- /dev/null +++ b/_examples/dataloader/models_gen.go @@ -0,0 +1,16 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package dataloader + +type Address struct { + ID int `json:"id"` + Street string `json:"street"` + Country string `json:"country"` +} + +type Item struct { + Name string `json:"name"` +} + +type Query struct { +} diff --git a/_examples/dataloader/ordersliceloader_gen.go b/_examples/dataloader/ordersliceloader_gen.go new file mode 100644 index 0000000..ad1e1ba --- /dev/null +++ b/_examples/dataloader/ordersliceloader_gen.go @@ -0,0 +1,223 @@ +// Code generated by github.com/vektah/dataloaden, DO NOT EDIT. + +package dataloader + +import ( + "sync" + "time" +) + +// OrderSliceLoaderConfig captures the config to create a new OrderSliceLoader +type OrderSliceLoaderConfig struct { + // Fetch is a method that provides the data for the loader + Fetch func(keys []int) ([][]*Order, []error) + + // Wait is how long wait before sending a batch + Wait time.Duration + + // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit + MaxBatch int +} + +// NewOrderSliceLoader creates a new OrderSliceLoader given a fetch, wait, and maxBatch +func NewOrderSliceLoader(config OrderSliceLoaderConfig) *OrderSliceLoader { + return &OrderSliceLoader{ + fetch: config.Fetch, + wait: config.Wait, + maxBatch: config.MaxBatch, + } +} + +// OrderSliceLoader batches and caches requests +type OrderSliceLoader struct { + // this method provides the data for the loader + fetch func(keys []int) ([][]*Order, []error) + + // how long to done before sending a batch + wait time.Duration + + // this will limit the maximum number of keys to send in one batch, 0 = no limit + maxBatch int + + // INTERNAL + + // lazily created cache + cache map[int][]*Order + + // the current batch. keys will continue to be collected until timeout is hit, + // then everything will be sent to the fetch method and out to the listeners + batch *orderSliceLoaderBatch + + // mutex to prevent races + mu sync.Mutex +} + +type orderSliceLoaderBatch struct { + keys []int + data [][]*Order + error []error + closing bool + done chan struct{} +} + +// Load a Order by key, batching and caching will be applied automatically +func (l *OrderSliceLoader) Load(key int) ([]*Order, error) { + return l.LoadThunk(key)() +} + +// LoadThunk returns a function that when called will block waiting for a Order. +// This method should be used if you want one goroutine to make requests to many +// different data loaders without blocking until the thunk is called. +func (l *OrderSliceLoader) LoadThunk(key int) func() ([]*Order, error) { + l.mu.Lock() + if it, ok := l.cache[key]; ok { + l.mu.Unlock() + return func() ([]*Order, error) { + return it, nil + } + } + if l.batch == nil { + l.batch = &orderSliceLoaderBatch{done: make(chan struct{})} + } + batch := l.batch + pos := batch.keyIndex(l, key) + l.mu.Unlock() + + return func() ([]*Order, error) { + <-batch.done + + var data []*Order + if pos < len(batch.data) { + data = batch.data[pos] + } + + var err error + // its convenient to be able to return a single error for everything + if len(batch.error) == 1 { + err = batch.error[0] + } else if batch.error != nil { + err = batch.error[pos] + } + + if err == nil { + l.mu.Lock() + l.unsafeSet(key, data) + l.mu.Unlock() + } + + return data, err + } +} + +// LoadAll fetches many keys at once. It will be broken into appropriate sized +// sub batches depending on how the loader is configured +func (l *OrderSliceLoader) LoadAll(keys []int) ([][]*Order, []error) { + results := make([]func() ([]*Order, error), len(keys)) + + for i, key := range keys { + results[i] = l.LoadThunk(key) + } + + orders := make([][]*Order, len(keys)) + errors := make([]error, len(keys)) + for i, thunk := range results { + orders[i], errors[i] = thunk() + } + return orders, errors +} + +// LoadAllThunk returns a function that when called will block waiting for a Orders. +// This method should be used if you want one goroutine to make requests to many +// different data loaders without blocking until the thunk is called. +func (l *OrderSliceLoader) LoadAllThunk(keys []int) func() ([][]*Order, []error) { + results := make([]func() ([]*Order, error), len(keys)) + for i, key := range keys { + results[i] = l.LoadThunk(key) + } + return func() ([][]*Order, []error) { + orders := make([][]*Order, len(keys)) + errors := make([]error, len(keys)) + for i, thunk := range results { + orders[i], errors[i] = thunk() + } + return orders, errors + } +} + +// Prime the cache with the provided key and value. If the key already exists, no change is made +// and false is returned. +// (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).) +func (l *OrderSliceLoader) Prime(key int, value []*Order) bool { + l.mu.Lock() + var found bool + if _, found = l.cache[key]; !found { + // make a copy when writing to the cache, its easy to pass a pointer in from a loop var + // and end up with the whole cache pointing to the same value. + cpy := make([]*Order, len(value)) + copy(cpy, value) + l.unsafeSet(key, cpy) + } + l.mu.Unlock() + return !found +} + +// Clear the value at key from the cache, if it exists +func (l *OrderSliceLoader) Clear(key int) { + l.mu.Lock() + delete(l.cache, key) + l.mu.Unlock() +} + +func (l *OrderSliceLoader) unsafeSet(key int, value []*Order) { + if l.cache == nil { + l.cache = map[int][]*Order{} + } + l.cache[key] = value +} + +// keyIndex will return the location of the key in the batch, if its not found +// it will add the key to the batch +func (b *orderSliceLoaderBatch) keyIndex(l *OrderSliceLoader, key int) int { + for i, existingKey := range b.keys { + if key == existingKey { + return i + } + } + + pos := len(b.keys) + b.keys = append(b.keys, key) + if pos == 0 { + go b.startTimer(l) + } + + if l.maxBatch != 0 && pos >= l.maxBatch-1 { + if !b.closing { + b.closing = true + l.batch = nil + go b.end(l) + } + } + + return pos +} + +func (b *orderSliceLoaderBatch) startTimer(l *OrderSliceLoader) { + time.Sleep(l.wait) + l.mu.Lock() + + // we must have hit a batch limit and are already finalizing this batch + if b.closing { + l.mu.Unlock() + return + } + + l.batch = nil + l.mu.Unlock() + + b.end(l) +} + +func (b *orderSliceLoaderBatch) end(l *OrderSliceLoader) { + b.data, b.error = l.fetch(b.keys) + close(b.done) +} diff --git a/_examples/dataloader/readme.md b/_examples/dataloader/readme.md new file mode 100644 index 0000000..bd0edb4 --- /dev/null +++ b/_examples/dataloader/readme.md @@ -0,0 +1,7 @@ +### dataloader + +This example uses [dataloaden](https://github.com/vektah/dataloaden) to avoiding n+1 queries. + + +There is also [nicksrandall/dataloader](https://github.com/nicksrandall/dataloader) if you wanted to avoid +doing more codegeneration. diff --git a/_examples/dataloader/resolvers.go b/_examples/dataloader/resolvers.go new file mode 100644 index 0000000..759f88c --- /dev/null +++ b/_examples/dataloader/resolvers.go @@ -0,0 +1,90 @@ +//go:generate go run ../../testdata/gqlgen.go + +package dataloader + +import ( + "context" + "fmt" + "math/rand" + "time" +) + +type Customer struct { + ID int `json:"id"` + Name string `json:"name"` + AddressID int +} + +type Order struct { + ID int `json:"id"` + Date time.Time `json:"date"` + Amount float64 `json:"amount"` +} + +type Resolver struct{} + +func (r *Resolver) Customer() CustomerResolver { + return &customerResolver{r} +} + +func (r *Resolver) Order() OrderResolver { + return &orderResolver{r} +} + +func (r *Resolver) Query() QueryResolver { + return &queryResolver{r} +} + +type customerResolver struct{ *Resolver } + +func (r *customerResolver) Address(ctx context.Context, obj *Customer) (*Address, error) { + return ctxLoaders(ctx).addressByID.Load(obj.AddressID) +} + +func (r *customerResolver) Orders(ctx context.Context, obj *Customer) ([]*Order, error) { + return ctxLoaders(ctx).ordersByCustomer.Load(obj.ID) +} + +type orderResolver struct{ *Resolver } + +func (r *orderResolver) Items(ctx context.Context, obj *Order) ([]*Item, error) { + return ctxLoaders(ctx).itemsByOrder.Load(obj.ID) +} + +type queryResolver struct{ *Resolver } + +func (r *queryResolver) Customers(ctx context.Context) ([]*Customer, error) { + fmt.Println("SELECT * FROM customer") + + time.Sleep(5 * time.Millisecond) + + return []*Customer{ + {ID: 1, Name: "Bob", AddressID: 1}, + {ID: 2, Name: "Alice", AddressID: 3}, + {ID: 3, Name: "Eve", AddressID: 4}, + }, nil +} + +// this method is here to test code generation of nested arrays +// nolint: gosec +func (r *queryResolver) Torture1d(ctx context.Context, customerIds []int) ([]*Customer, error) { + result := make([]*Customer, len(customerIds)) + for i, id := range customerIds { + result[i] = &Customer{ID: id, Name: fmt.Sprintf("%d", i), AddressID: rand.Int() % 10} + } + return result, nil +} + +// this method is here to test code generation of nested arrays +// nolint: gosec +func (r *queryResolver) Torture2d(ctx context.Context, customerIds [][]int) ([][]*Customer, error) { + result := make([][]*Customer, len(customerIds)) + for i := range customerIds { + inner := make([]*Customer, len(customerIds[i])) + for j := range customerIds[i] { + inner[j] = &Customer{ID: customerIds[i][j], Name: fmt.Sprintf("%d %d", i, j), AddressID: rand.Int() % 10} + } + result[i] = inner + } + return result, nil +} diff --git a/_examples/dataloader/schema.graphql b/_examples/dataloader/schema.graphql new file mode 100644 index 0000000..a0b579a --- /dev/null +++ b/_examples/dataloader/schema.graphql @@ -0,0 +1,32 @@ +type Query { + customers: [Customer!] + + # these methods are here to test code generation of nested arrays + torture1d(customerIds: [Int!]): [Customer!] + torture2d(customerIds: [[Int!]]): [[Customer!]] +} + +type Customer { + id: Int! + name: String! + address: Address + orders: [Order!] +} + +type Address { + id: Int! + street: String! + country: String! +} + +type Order { + id: Int! + date: Time! + amount: Float! + items: [Item!] +} + +type Item { + name: String! +} +scalar Time diff --git a/_examples/dataloader/server/server.go b/_examples/dataloader/server/server.go new file mode 100644 index 0000000..146089d --- /dev/null +++ b/_examples/dataloader/server/server.go @@ -0,0 +1,22 @@ +package main + +import ( + "log" + "net/http" + + "github.com/niko0xdev/gqlgen/_examples/dataloader" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/playground" +) + +func main() { + router := http.NewServeMux() + + router.Handle("/", playground.Handler("Dataloader", "/query")) + router.Handle("/query", handler.NewDefaultServer( + dataloader.NewExecutableSchema(dataloader.Config{Resolvers: &dataloader.Resolver{}}), + )) + + log.Println("connect to http://localhost:8082/ for graphql playground") + log.Fatal(http.ListenAndServe(":8082", dataloader.LoaderMiddleware(router))) +} diff --git a/_examples/embedding/parent.graphqls b/_examples/embedding/parent.graphqls new file mode 100644 index 0000000..70ee33e --- /dev/null +++ b/_examples/embedding/parent.graphqls @@ -0,0 +1,3 @@ +extend type Query { + parentdir: String! +} diff --git a/_examples/embedding/subdir/cfgdir/generate_in_gendir.yml b/_examples/embedding/subdir/cfgdir/generate_in_gendir.yml new file mode 100644 index 0000000..a2639b0 --- /dev/null +++ b/_examples/embedding/subdir/cfgdir/generate_in_gendir.yml @@ -0,0 +1,16 @@ +schema: + - schemadir/*.graphqls + - ../*.graphqls + - '*.graphqls' +exec: + dir: gendir + filename: gendir/generated.go + package: gendir + +federation: + filename: gendir/federation_gen.go + package: gendir + +model: + filename: gendir/model.go + package: gendir \ No newline at end of file diff --git a/_examples/embedding/subdir/cfgdir/generate_in_subdir.yml b/_examples/embedding/subdir/cfgdir/generate_in_subdir.yml new file mode 100644 index 0000000..11422bc --- /dev/null +++ b/_examples/embedding/subdir/cfgdir/generate_in_subdir.yml @@ -0,0 +1,16 @@ +schema: + - schemadir/*.graphqls + - ../*.graphqls + - '*.graphqls' +exec: + layout: follow-schema + dir: . + package: subdir + +federation: + filename: federation_gen.go + package: subdir + +model: + filename: model.go + package: subdir \ No newline at end of file diff --git a/_examples/embedding/subdir/directives.generated.go b/_examples/embedding/subdir/directives.generated.go new file mode 100644 index 0000000..7a31108 --- /dev/null +++ b/_examples/embedding/subdir/directives.generated.go @@ -0,0 +1,57 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package subdir + +import ( + "context" + + "github.com/niko0xdev/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) unmarshalN_FieldSet2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalN_FieldSet2string(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, "the requested element is null which the schema does not allow") + } + } + return res +} + +// endregion ***************************** type.gotpl ***************************** diff --git a/_examples/embedding/subdir/embedding_test.go b/_examples/embedding/subdir/embedding_test.go new file mode 100644 index 0000000..a231c8d --- /dev/null +++ b/_examples/embedding/subdir/embedding_test.go @@ -0,0 +1,49 @@ +package subdir + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/_examples/embedding/subdir/gendir" + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +func TestEmbeddingWorks(t *testing.T) { + c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: &Resolver{}}))) + var resp struct { + InSchemadir string + Parentdir string + Subdir string + } + c.MustPost(`{ + inSchemadir + parentdir + subdir + } + `, &resp) + + require.Equal(t, "example", resp.InSchemadir) + require.Equal(t, "example", resp.Parentdir) + require.Equal(t, "example", resp.Subdir) +} + +func TestEmbeddingWorksInGendir(t *testing.T) { + c := client.New(handler.NewDefaultServer(gendir.NewExecutableSchema(gendir.Config{Resolvers: &GendirResolver{}}))) + var resp struct { + InSchemadir string + Parentdir string + Subdir string + } + c.MustPost(`{ + inSchemadir + parentdir + subdir + } + `, &resp) + + require.Equal(t, "example", resp.InSchemadir) + require.Equal(t, "example", resp.Parentdir) + require.Equal(t, "example", resp.Subdir) +} diff --git a/_examples/embedding/subdir/entity.generated.go b/_examples/embedding/subdir/entity.generated.go new file mode 100644 index 0000000..6382985 --- /dev/null +++ b/_examples/embedding/subdir/entity.generated.go @@ -0,0 +1,127 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package subdir + +import ( + "context" + "errors" + "strconv" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/plugin/federation/fedruntime" + "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) __Service_sdl(ctx context.Context, field graphql.CollectedField, obj *fedruntime.Service) (ret graphql.Marshaler) { + fc, err := ec.fieldContext__Service_sdl(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SDL, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalOString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext__Service_sdl(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "_Service", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("_Service") + case "sdl": + out.Values[i] = ec.__Service_sdl(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) marshalN_Service2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx context.Context, sel ast.SelectionSet, v fedruntime.Service) graphql.Marshaler { + return ec.__Service(ctx, sel, &v) +} + +// endregion ***************************** type.gotpl ***************************** diff --git a/_examples/embedding/subdir/federation_gen.go b/_examples/embedding/subdir/federation_gen.go new file mode 100644 index 0000000..da96e85 --- /dev/null +++ b/_examples/embedding/subdir/federation_gen.go @@ -0,0 +1,35 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package subdir + +import ( + "context" + "errors" + "strings" + + "github.com/niko0xdev/gqlgen/plugin/federation/fedruntime" +) + +var ( + ErrUnknownType = errors.New("unknown type") + ErrTypeNotFound = errors.New("type not found") +) + +func (ec *executionContext) __resolve__service(ctx context.Context) (fedruntime.Service, error) { + if ec.DisableIntrospection { + return fedruntime.Service{}, errors.New("federated introspection disabled") + } + + var sdl []string + + for _, src := range sources { + if src.BuiltIn { + continue + } + sdl = append(sdl, src.Input) + } + + return fedruntime.Service{ + SDL: strings.Join(sdl, "\n"), + }, nil +} diff --git a/_examples/embedding/subdir/gendir/federation_gen.go b/_examples/embedding/subdir/gendir/federation_gen.go new file mode 100644 index 0000000..507ff37 --- /dev/null +++ b/_examples/embedding/subdir/gendir/federation_gen.go @@ -0,0 +1,35 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package gendir + +import ( + "context" + "errors" + "strings" + + "github.com/niko0xdev/gqlgen/plugin/federation/fedruntime" +) + +var ( + ErrUnknownType = errors.New("unknown type") + ErrTypeNotFound = errors.New("type not found") +) + +func (ec *executionContext) __resolve__service(ctx context.Context) (fedruntime.Service, error) { + if ec.DisableIntrospection { + return fedruntime.Service{}, errors.New("federated introspection disabled") + } + + var sdl []string + + for _, src := range sources { + if src.BuiltIn { + continue + } + sdl = append(sdl, src.Input) + } + + return fedruntime.Service{ + SDL: strings.Join(sdl, "\n"), + }, nil +} diff --git a/_examples/embedding/subdir/gendir/generated.go b/_examples/embedding/subdir/gendir/generated.go new file mode 100644 index 0000000..f2ea5c0 --- /dev/null +++ b/_examples/embedding/subdir/gendir/generated.go @@ -0,0 +1,3486 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package gendir + +import ( + "bytes" + "context" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + "github.com/niko0xdev/gqlgen/plugin/federation/fedruntime" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Query() QueryResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + Query struct { + InSchemadir func(childComplexity int) int + Parentdir func(childComplexity int) int + Subdir func(childComplexity int) int + __resolve__service func(childComplexity int) int + } + + _Service struct { + SDL func(childComplexity int) int + } +} + +type QueryResolver interface { + InSchemadir(ctx context.Context) (string, error) + Parentdir(ctx context.Context) (string, error) + Subdir(ctx context.Context) (string, error) +} + +type executableSchema struct { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = ec + switch typeName + "." + field { + + case "Query.inSchemadir": + if e.complexity.Query.InSchemadir == nil { + break + } + + return e.complexity.Query.InSchemadir(childComplexity), true + + case "Query.parentdir": + if e.complexity.Query.Parentdir == nil { + break + } + + return e.complexity.Query.Parentdir(childComplexity), true + + case "Query.subdir": + if e.complexity.Query.Subdir == nil { + break + } + + return e.complexity.Query.Subdir(childComplexity), true + + case "Query._service": + if e.complexity.Query.__resolve__service == nil { + break + } + + return e.complexity.Query.__resolve__service(childComplexity), true + + case "_Service.sdl": + if e.complexity._Service.SDL == nil { + break + } + + return e.complexity._Service.SDL(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap() + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } +} + +type executionContext struct { + *graphql.OperationContext + *executableSchema + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + +var sources = []*ast.Source{ + {Name: "../schemadir/root.graphqls", Input: `type Query { + inSchemadir: String! +} +`, BuiltIn: false}, + {Name: "../../parent.graphqls", Input: `extend type Query { + parentdir: String! +} +`, BuiltIn: false}, + {Name: "../subdir.graphqls", Input: `extend type Query { + subdir: String! +} +`, BuiltIn: false}, + {Name: "../federation/directives.graphql", Input: ` + directive @key(fields: _FieldSet!) repeatable on OBJECT | INTERFACE + directive @requires(fields: _FieldSet!) on FIELD_DEFINITION + directive @provides(fields: _FieldSet!) on FIELD_DEFINITION + directive @extends on OBJECT | INTERFACE + directive @external on FIELD_DEFINITION + scalar _Any + scalar _FieldSet +`, BuiltIn: true}, + {Name: "../federation/entity.graphql", Input: ` +type _Service { + sdl: String +} + +extend type Query { + _service: _Service! +} +`, BuiltIn: true}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// 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___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) _Query_inSchemadir(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_inSchemadir(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().InSchemadir(rctx) + }) + 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) fieldContext_Query_inSchemadir(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_parentdir(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_parentdir(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Parentdir(rctx) + }) + 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) fieldContext_Query_parentdir(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_subdir(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_subdir(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Subdir(rctx) + }) + 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) fieldContext_Query_subdir(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query__service(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query__service(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.__resolve__service(ctx) + }) + 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.(fedruntime.Service) + fc.Result = res + return ec.marshalN_Service2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query__service(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "sdl": + return ec.fieldContext__Service_sdl(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type _Service", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) __Service_sdl(ctx context.Context, field graphql.CollectedField, obj *fedruntime.Service) (ret graphql.Marshaler) { + fc, err := ec.fieldContext__Service_sdl(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SDL, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalOString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext__Service_sdl(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "_Service", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), 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.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), 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.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), 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.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +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) + deferred := make(map[string]*graphql.FieldSet) + 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 "inSchemadir": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_inSchemadir(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "parentdir": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_parentdir(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "subdir": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_subdir(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "_service": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query__service(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("_Service") + case "sdl": + out.Values[i] = ec.__Service_sdl(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN_FieldSet2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalN_FieldSet2string(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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalN_Service2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx context.Context, sel ast.SelectionSet, v fedruntime.Service) graphql.Marshaler { + return ec.__Service(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + 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) 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 + } + 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) marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/_examples/embedding/subdir/gendir/model.go b/_examples/embedding/subdir/gendir/model.go new file mode 100644 index 0000000..08e5fae --- /dev/null +++ b/_examples/embedding/subdir/gendir/model.go @@ -0,0 +1,6 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package gendir + +type Query struct { +} diff --git a/_examples/embedding/subdir/model.go b/_examples/embedding/subdir/model.go new file mode 100644 index 0000000..4fb4f94 --- /dev/null +++ b/_examples/embedding/subdir/model.go @@ -0,0 +1,6 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package subdir + +type Query struct { +} diff --git a/_examples/embedding/subdir/prelude.generated.go b/_examples/embedding/subdir/prelude.generated.go new file mode 100644 index 0000000..fab1e09 --- /dev/null +++ b/_examples/embedding/subdir/prelude.generated.go @@ -0,0 +1,2730 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package subdir + +import ( + "context" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (ec *executionContext) dir_defer_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["if"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("if")) + arg0, err = ec.unmarshalOBoolean2ᚖbool(ctx, tmp) + if err != nil { + return nil, err + } + } + args["if"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["label"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("label")) + arg1, err = ec.unmarshalOString2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["label"] = arg1 + return args, nil +} + +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) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), 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.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), 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.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), 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.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + 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) 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 + } + 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) marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/_examples/embedding/subdir/resolvers.go b/_examples/embedding/subdir/resolvers.go new file mode 100644 index 0000000..fa5aa32 --- /dev/null +++ b/_examples/embedding/subdir/resolvers.go @@ -0,0 +1,31 @@ +//go:generate go run ../../../testdata/gqlgen.go -config cfgdir/generate_in_subdir.yml +//go:generate go run ../../../testdata/gqlgen.go -config cfgdir/generate_in_gendir.yml + +package subdir + +import ( + "context" + + "github.com/niko0xdev/gqlgen/_examples/embedding/subdir/gendir" +) + +type Resolver struct{ *Resolver } + +func (q *Resolver) Query() QueryResolver { + return q +} +func (q *Resolver) InSchemadir(ctx context.Context) (string, error) { + return "example", nil +} +func (q *Resolver) Parentdir(ctx context.Context) (string, error) { + return "example", nil +} +func (q *Resolver) Subdir(ctx context.Context) (string, error) { + return "example", nil +} + +type GendirResolver struct{ *Resolver } + +func (q *GendirResolver) Query() gendir.QueryResolver { + return &Resolver{} +} diff --git a/_examples/embedding/subdir/root.generated.go b/_examples/embedding/subdir/root.generated.go new file mode 100644 index 0000000..fe2d5f6 --- /dev/null +++ b/_examples/embedding/subdir/root.generated.go @@ -0,0 +1,516 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package subdir + +import ( + "context" + "errors" + "fmt" + "strconv" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + "github.com/niko0xdev/gqlgen/plugin/federation/fedruntime" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +type QueryResolver interface { + InSchemadir(ctx context.Context) (string, error) + Parentdir(ctx context.Context) (string, error) + Subdir(ctx context.Context) (string, 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 +} + +// endregion ***************************** args.gotpl ***************************** + +// region ************************** directives.gotpl ************************** + +// endregion ************************** directives.gotpl ************************** + +// region **************************** field.gotpl ***************************** + +func (ec *executionContext) _Query_inSchemadir(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_inSchemadir(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().InSchemadir(rctx) + }) + 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) fieldContext_Query_inSchemadir(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_parentdir(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_parentdir(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Parentdir(rctx) + }) + 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) fieldContext_Query_parentdir(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_subdir(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_subdir(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Subdir(rctx) + }) + 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) fieldContext_Query_subdir(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query__service(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query__service(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.__resolve__service(ctx) + }) + 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.(fedruntime.Service) + fc.Result = res + return ec.marshalN_Service2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query__service(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "sdl": + return ec.fieldContext__Service_sdl(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type _Service", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +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) + deferred := make(map[string]*graphql.FieldSet) + 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 "inSchemadir": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_inSchemadir(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "parentdir": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_parentdir(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "subdir": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_subdir(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "_service": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query__service(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +// endregion ***************************** type.gotpl ***************************** diff --git a/_examples/embedding/subdir/root_.generated.go b/_examples/embedding/subdir/root_.generated.go new file mode 100644 index 0000000..aa68c4e --- /dev/null +++ b/_examples/embedding/subdir/root_.generated.go @@ -0,0 +1,235 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package subdir + +import ( + "bytes" + "context" + "embed" + "errors" + "fmt" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/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{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Query() QueryResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + Query struct { + InSchemadir func(childComplexity int) int + Parentdir func(childComplexity int) int + Subdir func(childComplexity int) int + __resolve__service func(childComplexity int) int + } + + _Service struct { + SDL func(childComplexity int) int + } +} + +type executableSchema struct { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = ec + switch typeName + "." + field { + + case "Query.inSchemadir": + if e.complexity.Query.InSchemadir == nil { + break + } + + return e.complexity.Query.InSchemadir(childComplexity), true + + case "Query.parentdir": + if e.complexity.Query.Parentdir == nil { + break + } + + return e.complexity.Query.Parentdir(childComplexity), true + + case "Query.subdir": + if e.complexity.Query.Subdir == nil { + break + } + + return e.complexity.Query.Subdir(childComplexity), true + + case "Query._service": + if e.complexity.Query.__resolve__service == nil { + break + } + + return e.complexity.Query.__resolve__service(childComplexity), true + + case "_Service.sdl": + if e.complexity._Service.SDL == nil { + break + } + + return e.complexity._Service.SDL(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap() + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } +} + +type executionContext struct { + *graphql.OperationContext + *executableSchema + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + +//go:embed "schemadir/root.graphqls" "subdir.graphqls" +var sourcesFS embed.FS + +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) +} + +var sources = []*ast.Source{ + {Name: "schemadir/root.graphqls", Input: sourceData("schemadir/root.graphqls"), BuiltIn: false}, + {Name: "../parent.graphqls", Input: `extend type Query { + parentdir: String! +} +`, BuiltIn: false}, + {Name: "subdir.graphqls", Input: sourceData("subdir.graphqls"), BuiltIn: false}, + {Name: "federation/directives.graphql", Input: ` + directive @key(fields: _FieldSet!) repeatable on OBJECT | INTERFACE + directive @requires(fields: _FieldSet!) on FIELD_DEFINITION + directive @provides(fields: _FieldSet!) on FIELD_DEFINITION + directive @extends on OBJECT | INTERFACE + directive @external on FIELD_DEFINITION + scalar _Any + scalar _FieldSet +`, BuiltIn: true}, + {Name: "federation/entity.graphql", Input: ` +type _Service { + sdl: String +} + +extend type Query { + _service: _Service! +} +`, BuiltIn: true}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) diff --git a/_examples/embedding/subdir/schemadir/root.graphqls b/_examples/embedding/subdir/schemadir/root.graphqls new file mode 100644 index 0000000..e332315 --- /dev/null +++ b/_examples/embedding/subdir/schemadir/root.graphqls @@ -0,0 +1,3 @@ +type Query { + inSchemadir: String! +} diff --git a/_examples/embedding/subdir/subdir.graphqls b/_examples/embedding/subdir/subdir.graphqls new file mode 100644 index 0000000..2f50d38 --- /dev/null +++ b/_examples/embedding/subdir/subdir.graphqls @@ -0,0 +1,3 @@ +extend type Query { + subdir: String! +} diff --git a/_examples/federation/accounts/gqlgen.yml b/_examples/federation/accounts/gqlgen.yml new file mode 100644 index 0000000..16866a2 --- /dev/null +++ b/_examples/federation/accounts/gqlgen.yml @@ -0,0 +1,68 @@ +# Where are all the schema files located? globs are supported eg src/**/*.graphqls +schema: + - graph/*.graphqls + +# Where should the generated server code go? +exec: + filename: graph/generated.go + package: graph + +federation: + filename: graph/federation.go + package: graph + +# Where should any generated models go? +model: + filename: graph/model/models_gen.go + package: model + +# Where should the resolver implementations go? +resolver: + layout: follow-schema + dir: graph + package: graph + +# Optional: turn on use `gqlgen:"fieldName"` tags in your models +# struct_tag: json + +# Optional: turn on to use []Thing instead of []*Thing +# omit_slice_element_pointers: false + +# Optional: turn off to make struct-type struct fields not use pointers +# e.g. type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing } +# struct_fields_always_pointers: true + +# Optional: turn off to make resolvers return values instead of pointers for structs +# resolvers_always_return_pointers: true + +# Optional: turn on to return pointers instead of values in unmarshalInput +# return_pointers_in_unmarshalinput: false + +# Optional: wrap nullable input fields with Omittable +# nullable_input_omittable: true + +# Optional: set to speed up generation time by not performing a final validation pass. +# skip_validation: 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: + - "github.com/niko0xdev/gqlgen/_examples/federation/accounts/graph/model" + +# This section declares type mapping between the GraphQL and go type systems +# +# The first line in each type will be used as defaults for resolver arguments and +# modelgen, the others will be allowed when binding to fields. Configure them to +# your liking +models: + ID: + model: + - github.com/niko0xdev/gqlgen/graphql.ID + - github.com/niko0xdev/gqlgen/graphql.Int + - github.com/niko0xdev/gqlgen/graphql.Int64 + - github.com/niko0xdev/gqlgen/graphql.Int32 + Int: + model: + - github.com/niko0xdev/gqlgen/graphql.Int + - github.com/niko0xdev/gqlgen/graphql.Int64 + - github.com/niko0xdev/gqlgen/graphql.Int32 diff --git a/_examples/federation/accounts/graph/entity.resolvers.go b/_examples/federation/accounts/graph/entity.resolvers.go new file mode 100644 index 0000000..6d2995e --- /dev/null +++ b/_examples/federation/accounts/graph/entity.resolvers.go @@ -0,0 +1,37 @@ +package graph + +// 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. +// Code generated by github.com/niko0xdev/gqlgen version v0.17.42-dev + +import ( + "context" + + "github.com/niko0xdev/gqlgen/_examples/federation/accounts/graph/model" +) + +// FindEmailHostByID is the resolver for the findEmailHostByID field. +func (r *entityResolver) FindEmailHostByID(ctx context.Context, id string) (*model.EmailHost, error) { + return &model.EmailHost{ + ID: id, + Name: "Email Host " + id, + }, nil +} + +// FindUserByID is the resolver for the findUserByID field. +func (r *entityResolver) FindUserByID(ctx context.Context, id string) (*model.User, error) { + name := "User " + id + if id == "1234" { + name = "Me" + } + + return &model.User{ + ID: id, + Username: name, + }, nil +} + +// Entity returns EntityResolver implementation. +func (r *Resolver) Entity() EntityResolver { return &entityResolver{r} } + +type entityResolver struct{ *Resolver } diff --git a/_examples/federation/accounts/graph/federation.go b/_examples/federation/accounts/graph/federation.go new file mode 100644 index 0000000..f1b7357 --- /dev/null +++ b/_examples/federation/accounts/graph/federation.go @@ -0,0 +1,224 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package graph + +import ( + "context" + "errors" + "fmt" + "strings" + "sync" + + "github.com/niko0xdev/gqlgen/plugin/federation/fedruntime" +) + +var ( + ErrUnknownType = errors.New("unknown type") + ErrTypeNotFound = errors.New("type not found") +) + +func (ec *executionContext) __resolve__service(ctx context.Context) (fedruntime.Service, error) { + if ec.DisableIntrospection { + return fedruntime.Service{}, errors.New("federated introspection disabled") + } + + var sdl []string + + for _, src := range sources { + if src.BuiltIn { + continue + } + sdl = append(sdl, src.Input) + } + + return fedruntime.Service{ + SDL: strings.Join(sdl, "\n"), + }, nil +} + +func (ec *executionContext) __resolve_entities(ctx context.Context, representations []map[string]interface{}) []fedruntime.Entity { + list := make([]fedruntime.Entity, len(representations)) + + repsMap := map[string]struct { + i []int + r []map[string]interface{} + }{} + + // We group entities by typename so that we can parallelize their resolution. + // This is particularly helpful when there are entity groups in multi mode. + buildRepresentationGroups := func(reps []map[string]interface{}) { + for i, rep := range reps { + typeName, ok := rep["__typename"].(string) + if !ok { + // If there is no __typename, we just skip the representation; + // we just won't be resolving these unknown types. + ec.Error(ctx, errors.New("__typename must be an existing string")) + continue + } + + _r := repsMap[typeName] + _r.i = append(_r.i, i) + _r.r = append(_r.r, rep) + repsMap[typeName] = _r + } + } + + isMulti := func(typeName string) bool { + switch typeName { + default: + return false + } + } + + resolveEntity := func(ctx context.Context, typeName string, rep map[string]interface{}, idx []int, i int) (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) + } + }() + + switch typeName { + case "EmailHost": + resolverName, err := entityResolverNameForEmailHost(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "EmailHost": %w`, err) + } + switch resolverName { + + case "findEmailHostByID": + id0, err := ec.unmarshalNString2string(ctx, rep["id"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findEmailHostByID(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindEmailHostByID(ctx, id0) + if err != nil { + return fmt.Errorf(`resolving Entity "EmailHost": %w`, err) + } + + list[idx[i]] = entity + return nil + } + case "User": + resolverName, err := entityResolverNameForUser(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "User": %w`, err) + } + switch resolverName { + + case "findUserByID": + id0, err := ec.unmarshalNID2string(ctx, rep["id"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findUserByID(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindUserByID(ctx, id0) + if err != nil { + return fmt.Errorf(`resolving Entity "User": %w`, err) + } + + list[idx[i]] = entity + return nil + } + + } + return fmt.Errorf("%w: %s", ErrUnknownType, typeName) + } + + resolveManyEntities := func(ctx context.Context, typeName string, reps []map[string]interface{}, idx []int) (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) + } + }() + + switch typeName { + + default: + return errors.New("unknown type: " + typeName) + } + } + + resolveEntityGroup := func(typeName string, reps []map[string]interface{}, idx []int) { + if isMulti(typeName) { + err := resolveManyEntities(ctx, typeName, reps, idx) + if err != nil { + ec.Error(ctx, err) + } + } else { + // if there are multiple entities to resolve, parallelize (similar to + // graphql.FieldSet.Dispatch) + var e sync.WaitGroup + e.Add(len(reps)) + for i, rep := range reps { + i, rep := i, rep + go func(i int, rep map[string]interface{}) { + err := resolveEntity(ctx, typeName, rep, idx, i) + if err != nil { + ec.Error(ctx, err) + } + e.Done() + }(i, rep) + } + e.Wait() + } + } + buildRepresentationGroups(representations) + + switch len(repsMap) { + case 0: + return list + case 1: + for typeName, reps := range repsMap { + resolveEntityGroup(typeName, reps.r, reps.i) + } + return list + default: + var g sync.WaitGroup + g.Add(len(repsMap)) + for typeName, reps := range repsMap { + go func(typeName string, reps []map[string]interface{}, idx []int) { + resolveEntityGroup(typeName, reps, idx) + g.Done() + }(typeName, reps.r, reps.i) + } + g.Wait() + return list + } +} + +func entityResolverNameForEmailHost(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["id"]; !ok { + break + } + return "findEmailHostByID", nil + } + return "", fmt.Errorf("%w for EmailHost", ErrTypeNotFound) +} + +func entityResolverNameForUser(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["id"]; !ok { + break + } + return "findUserByID", nil + } + return "", fmt.Errorf("%w for User", ErrTypeNotFound) +} diff --git a/_examples/federation/accounts/graph/generated.go b/_examples/federation/accounts/graph/generated.go new file mode 100644 index 0000000..e1df777 --- /dev/null +++ b/_examples/federation/accounts/graph/generated.go @@ -0,0 +1,4327 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package graph + +import ( + "bytes" + "context" + "embed" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/_examples/federation/accounts/graph/model" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + "github.com/niko0xdev/gqlgen/plugin/federation/fedruntime" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Entity() EntityResolver + Query() QueryResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + EmailHost struct { + ID func(childComplexity int) int + Name func(childComplexity int) int + } + + Entity struct { + FindEmailHostByID func(childComplexity int, id string) int + FindUserByID func(childComplexity int, id string) int + } + + Query struct { + Me func(childComplexity int) int + __resolve__service func(childComplexity int) int + __resolve_entities func(childComplexity int, representations []map[string]interface{}) int + } + + User struct { + Email func(childComplexity int) int + Host func(childComplexity int) int + ID func(childComplexity int) int + Username func(childComplexity int) int + } + + _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 { + Me(ctx context.Context) (*model.User, error) +} + +type executableSchema struct { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = 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 + } + + args, err := ec.field_Entity_findUserByID_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindUserByID(childComplexity, args["id"].(string)), true + + case "Query.me": + if e.complexity.Query.Me == nil { + break + } + + return e.complexity.Query.Me(childComplexity), true + + case "Query._service": + if e.complexity.Query.__resolve__service == nil { + break + } + + return e.complexity.Query.__resolve__service(childComplexity), true + + case "Query._entities": + if e.complexity.Query.__resolve_entities == nil { + break + } + + args, err := ec.field_Query__entities_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + 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 + } + + return e.complexity.User.ID(childComplexity), true + + case "User.username": + if e.complexity.User.Username == nil { + break + } + + return e.complexity.User.Username(childComplexity), true + + case "_Service.sdl": + if e.complexity._Service.SDL == nil { + break + } + + return e.complexity._Service.SDL(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap() + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } +} + +type executionContext struct { + *graphql.OperationContext + *executableSchema + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + +//go:embed "schema.graphqls" +var sourcesFS embed.FS + +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) +} + +var sources = []*ast.Source{ + {Name: "schema.graphqls", Input: sourceData("schema.graphqls"), BuiltIn: false}, + {Name: "../federation/directives.graphql", Input: ` + directive @key(fields: _FieldSet!) repeatable on OBJECT | INTERFACE + directive @requires(fields: _FieldSet!) on FIELD_DEFINITION + directive @provides(fields: _FieldSet!) on FIELD_DEFINITION + directive @extends on OBJECT | INTERFACE + directive @external on FIELD_DEFINITION + scalar _Any + scalar _FieldSet +`, BuiltIn: true}, + {Name: "../federation/entity.graphql", Input: ` +# a union of all types that use the @key directive +union _Entity = EmailHost | User + +# fake type to build resolver interfaces for users to implement +type Entity { + findEmailHostByID(id: String!,): EmailHost! + findUserByID(id: ID!,): User! + +} + +type _Service { + sdl: String +} + +extend type Query { + _entities(representations: [_Any!]!): [_Entity]! + _service: _Service! +} +`, BuiltIn: true}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// endregion ************************** generated!.gotpl ************************** + +// 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{}{} + var arg0 string + if tmp, ok := rawArgs["id"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + arg0, err = ec.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil +} + +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__entities_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["representations"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("representations")) + arg0, err = ec.unmarshalN_Any2ᚕmapᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["representations"] = arg0 + return args, nil +} + +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) _EmailHost_id(ctx context.Context, field graphql.CollectedField, obj *model.EmailHost) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_EmailHost_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_EmailHost_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "EmailHost", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _EmailHost_name(ctx context.Context, field graphql.CollectedField, obj *model.EmailHost) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_EmailHost_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_EmailHost_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "EmailHost", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Entity_findEmailHostByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findEmailHostByID(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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ᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋaccountsᚋgraphᚋmodelᚐEmailHost(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findEmailHostByID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_EmailHost_id(ctx, field) + case "name": + return ec.fieldContext_EmailHost_name(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type EmailHost", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findEmailHostByID_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Entity_findUserByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findUserByID(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindUserByID(rctx, fc.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.User) + fc.Result = res + return ec.marshalNUser2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋaccountsᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findUserByID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "host": + return ec.fieldContext_User_host(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "username": + return ec.fieldContext_User_username(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findUserByID_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_me(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_me(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Me(rctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.User) + fc.Result = res + return ec.marshalOUser2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋaccountsᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_me(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "host": + return ec.fieldContext_User_host(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "username": + return ec.fieldContext_User_username(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query__entities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query__entities(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.Args["representations"].([]map[string]interface{})), 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.([]fedruntime.Entity) + fc.Result = res + return ec.marshalN_Entity2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query__entities(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type _Entity does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query__entities_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query__service(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query__service(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.__resolve__service(ctx) + }) + 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.(fedruntime.Service) + fc.Result = res + return ec.marshalN_Service2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query__service(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "sdl": + return ec.fieldContext__Service_sdl(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type _Service", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_host(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_host(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋaccountsᚋgraphᚋmodelᚐEmailHost(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_host(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_EmailHost_id(ctx, field) + case "name": + return ec.fieldContext_EmailHost_name(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type EmailHost", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _User_email(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_email(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_User_email(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_username(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_username(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Username, 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) fieldContext_User_username(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) __Service_sdl(ctx context.Context, field graphql.CollectedField, obj *fedruntime.Service) (ret graphql.Marshaler) { + fc, err := ec.fieldContext__Service_sdl(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SDL, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalOString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext__Service_sdl(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "_Service", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), 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.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), 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.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), 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.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, obj fedruntime.Entity) graphql.Marshaler { + 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: + if obj == nil { + return graphql.Null + } + return ec._User(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("EmailHost") + case "id": + out.Values[i] = ec._EmailHost_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec._EmailHost_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "findUserByID": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Entity_findUserByID(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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 + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_me(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "_entities": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query__entities(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "_service": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query__service(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("User") + case "id": + out.Values[i] = ec._User_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "host": + out.Values[i] = ec._User_host(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "email": + out.Values[i] = ec._User_email(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "username": + out.Values[i] = ec._User_username(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("_Service") + case "sdl": + out.Values[i] = ec.__Service_sdl(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNEmailHost2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋ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ᚋniko0xdevᚋgqlgenᚋ_examplesᚋ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, "the requested element is null which the schema does not allow") + } + 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) +} + +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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNUser2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋaccountsᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v model.User) graphql.Marshaler { + return ec._User(ctx, sel, &v) +} + +func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋaccountsᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._User(ctx, sel, v) +} + +func (ec *executionContext) unmarshalN_Any2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { + res, err := graphql.UnmarshalMap(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalN_Any2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + res := graphql.MarshalMap(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN_Any2ᚕmapᚄ(ctx context.Context, v interface{}) ([]map[string]interface{}, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]map[string]interface{}, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalN_Any2map(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalN_Any2ᚕmapᚄ(ctx context.Context, sel ast.SelectionSet, v []map[string]interface{}) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalN_Any2map(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalN_Entity2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v []fedruntime.Entity) 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.marshalO_Entity2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) unmarshalN_FieldSet2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalN_FieldSet2string(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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalN_Service2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx context.Context, sel ast.SelectionSet, v fedruntime.Service) graphql.Marshaler { + return ec.__Service(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + 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) 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 + } + 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) marshalOUser2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋaccountsᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._User(ctx, sel, v) +} + +func (ec *executionContext) marshalO_Entity2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v fedruntime.Entity) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.__Entity(ctx, sel, v) +} + +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/_examples/federation/accounts/graph/model/model.go b/_examples/federation/accounts/graph/model/model.go new file mode 100644 index 0000000..8b53790 --- /dev/null +++ b/_examples/federation/accounts/graph/model/model.go @@ -0,0 +1 @@ +package model diff --git a/_examples/federation/accounts/graph/model/models_gen.go b/_examples/federation/accounts/graph/model/models_gen.go new file mode 100644 index 0000000..861f0d6 --- /dev/null +++ b/_examples/federation/accounts/graph/model/models_gen.go @@ -0,0 +1,22 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package model + +type EmailHost struct { + ID string `json:"id"` + Name string `json:"name"` +} + +func (EmailHost) IsEntity() {} + +type Query struct { +} + +type User struct { + ID string `json:"id"` + Host *EmailHost `json:"host"` + Email string `json:"email"` + Username string `json:"username"` +} + +func (User) IsEntity() {} diff --git a/_examples/federation/accounts/graph/resolver.go b/_examples/federation/accounts/graph/resolver.go new file mode 100644 index 0000000..278fb7d --- /dev/null +++ b/_examples/federation/accounts/graph/resolver.go @@ -0,0 +1,6 @@ +// This file will not be regenerated automatically. +// +// It serves as dependency injection for your app, add any dependencies you require here. +package graph + +type Resolver struct{} diff --git a/_examples/federation/accounts/graph/schema.graphqls b/_examples/federation/accounts/graph/schema.graphqls new file mode 100644 index 0000000..01c7c2e --- /dev/null +++ b/_examples/federation/accounts/graph/schema.graphqls @@ -0,0 +1,15 @@ +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/_examples/federation/accounts/graph/schema.resolvers.go b/_examples/federation/accounts/graph/schema.resolvers.go new file mode 100644 index 0000000..5387244 --- /dev/null +++ b/_examples/federation/accounts/graph/schema.resolvers.go @@ -0,0 +1,29 @@ +package graph + +// 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. +// Code generated by github.com/niko0xdev/gqlgen version v0.17.42-dev + +import ( + "context" + + "github.com/niko0xdev/gqlgen/_examples/federation/accounts/graph/model" +) + +// Me is the resolver for the me field. +func (r *queryResolver) Me(ctx context.Context) (*model.User, error) { + return &model.User{ + ID: "1234", + Host: &model.EmailHost{ + ID: "4567", + Name: "Email Host 4567", + }, + Email: "me@example.com", + Username: "Me", + }, nil +} + +// Query returns QueryResolver implementation. +func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } + +type queryResolver struct{ *Resolver } diff --git a/_examples/federation/accounts/server.go b/_examples/federation/accounts/server.go new file mode 100644 index 0000000..934049a --- /dev/null +++ b/_examples/federation/accounts/server.go @@ -0,0 +1,31 @@ +//go:generate go run ../../../testdata/gqlgen.go +package main + +import ( + "log" + "net/http" + "os" + + "github.com/niko0xdev/gqlgen/_examples/federation/accounts/graph" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/handler/debug" + "github.com/niko0xdev/gqlgen/graphql/playground" +) + +const defaultPort = "4001" + +func main() { + port := os.Getenv("PORT") + if port == "" { + port = defaultPort + } + + srv := handler.NewDefaultServer(graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}})) + srv.Use(&debug.Tracer{}) + + http.Handle("/", playground.Handler("GraphQL playground", "/query")) + http.Handle("/query", srv) + + log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) + log.Fatal(http.ListenAndServe(":"+port, nil)) +} diff --git a/_examples/federation/gateway/index.js b/_examples/federation/gateway/index.js new file mode 100644 index 0000000..5eb8ad3 --- /dev/null +++ b/_examples/federation/gateway/index.js @@ -0,0 +1,20 @@ +const { ApolloServer } = require('apollo-server'); +const { ApolloGateway } = require("@apollo/gateway"); + +const gateway = new ApolloGateway({ + serviceList: [ + { name: 'accounts', url: 'http://localhost:4001/query' }, + { name: 'products', url: 'http://localhost:4002/query' }, + { name: 'reviews', url: 'http://localhost:4003/query' } + ], +}); + +const server = new ApolloServer({ + gateway, + + subscriptions: false, +}); + +server.listen().then(({ url }) => { + console.log(`🚀 Server ready at ${url}`); +}); diff --git a/_examples/federation/integration-test.js b/_examples/federation/integration-test.js new file mode 100644 index 0000000..399177b --- /dev/null +++ b/_examples/federation/integration-test.js @@ -0,0 +1,60 @@ +const {InMemoryCache} = require("apollo-cache-inmemory"); +const {HttpLink} = require("apollo-link-http"); +const {ApolloClient} = require("apollo-client"); +const fetch = require("node-fetch"); +const gql = require('graphql-tag'); + +var uri = process.env.SERVER_URL || 'http://localhost:4000/'; + +const client = new ApolloClient({ + link: new HttpLink({uri, fetch}), + cache: new InMemoryCache(), +}); + +describe('Json', () => { + it('can join across services', async () => { + let res = await client.query({ + query: gql`query { + me { + username + reviews { + body + product { + name + upc + } + } + } + }`, + }); + + expect(res.data).toEqual({ + "me": { + "__typename": "User", + "username": "Me", + "reviews": [ + { + "__typename": "Review", + "body": "A highly effective form of birth control.", + "product": { + "__typename": "Product", + "name": "Trilby", + "upc": "top-1" + } + }, + { + "__typename": "Review", + "body": "Fedoras are one of the most fashionable hats around and can look great with a variety of outfits.", + "product": { + "__typename": "Product", + "name": "Fedora", + "upc": "top-2" + } + } + ] + } + }); + expect(res.errors).toBe(undefined); + }); +}); + diff --git a/_examples/federation/jest.config.js b/_examples/federation/jest.config.js new file mode 100644 index 0000000..d7e4e6e --- /dev/null +++ b/_examples/federation/jest.config.js @@ -0,0 +1,10 @@ +module.exports = { + testEnvironment: "node", + testMatch: ["/**/*-test.js"], + testPathIgnorePatterns: ["/node_modules/"], + moduleFileExtensions: ["js"], + modulePaths: ["/node_modules"], + // transform: { + // '^.+\\.jsx?$': 'babel-jest', + // }, +}; diff --git a/_examples/federation/package.json b/_examples/federation/package.json new file mode 100644 index 0000000..aa2093e --- /dev/null +++ b/_examples/federation/package.json @@ -0,0 +1,23 @@ +{ + "name": "gateway", + "version": "1.0.0", + "description": "", + "main": "gateway/index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "@apollo/gateway": "^0.42.0", + "apollo-server": "^3.3.0", + "graphql": "^15.6.1" + }, + "devDependencies": { + "apollo-cache-inmemory": "^1.6.5", + "apollo-client": "^2.6.8", + "apollo-link-http": "^1.5.16", + "jest": "^25.1.0", + "node-fetch": "^2.6.0" + } +} diff --git a/_examples/federation/products/gqlgen.yml b/_examples/federation/products/gqlgen.yml new file mode 100644 index 0000000..f8c87bc --- /dev/null +++ b/_examples/federation/products/gqlgen.yml @@ -0,0 +1,68 @@ +# Where are all the schema files located? globs are supported eg src/**/*.graphqls +schema: + - graph/*.graphqls + +# Where should the generated server code go? +exec: + filename: graph/generated.go + package: graph + +federation: + filename: graph/federation.go + package: graph + +# Where should any generated models go? +model: + filename: graph/model/models_gen.go + package: model + +# Where should the resolver implementations go? +resolver: + layout: follow-schema + dir: graph + package: graph + +# Optional: turn on use `gqlgen:"fieldName"` tags in your models +# struct_tag: json + +# Optional: turn on to use []Thing instead of []*Thing +# omit_slice_element_pointers: false + +# Optional: turn off to make struct-type struct fields not use pointers +# e.g. type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing } +# struct_fields_always_pointers: true + +# Optional: turn off to make resolvers return values instead of pointers for structs +# resolvers_always_return_pointers: true + +# Optional: turn on to return pointers instead of values in unmarshalInput +# return_pointers_in_unmarshalinput: false + +# Optional: wrap nullable input fields with Omittable +# nullable_input_omittable: true + +# Optional: set to speed up generation time by not performing a final validation pass. +# skip_validation: 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: + - "github.com/niko0xdev/gqlgen/_examples/federation/products/graph/model" + +# This section declares type mapping between the GraphQL and go type systems +# +# The first line in each type will be used as defaults for resolver arguments and +# modelgen, the others will be allowed when binding to fields. Configure them to +# your liking +models: + ID: + model: + - github.com/niko0xdev/gqlgen/graphql.ID + - github.com/niko0xdev/gqlgen/graphql.Int + - github.com/niko0xdev/gqlgen/graphql.Int64 + - github.com/niko0xdev/gqlgen/graphql.Int32 + Int: + model: + - github.com/niko0xdev/gqlgen/graphql.Int + - github.com/niko0xdev/gqlgen/graphql.Int64 + - github.com/niko0xdev/gqlgen/graphql.Int32 diff --git a/_examples/federation/products/graph/entity.resolvers.go b/_examples/federation/products/graph/entity.resolvers.go new file mode 100644 index 0000000..d530334 --- /dev/null +++ b/_examples/federation/products/graph/entity.resolvers.go @@ -0,0 +1,44 @@ +package graph + +// 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. +// Code generated by github.com/niko0xdev/gqlgen version v0.17.42-dev + +import ( + "context" + + "github.com/niko0xdev/gqlgen/_examples/federation/products/graph/model" +) + +// FindManufacturerByID is the resolver for the findManufacturerByID field. +func (r *entityResolver) FindManufacturerByID(ctx context.Context, id string) (*model.Manufacturer, error) { + return &model.Manufacturer{ + ID: id, + Name: "Millinery " + id, + }, nil +} + +// FindProductByManufacturerIDAndID is the resolver for the findProductByManufacturerIDAndID field. +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 +} + +// FindProductByUpc is the resolver for the findProductByUpc field. +func (r *entityResolver) FindProductByUpc(ctx context.Context, upc string) (*model.Product, error) { + for _, hat := range hats { + if hat.Upc == upc { + return hat, nil + } + } + return nil, nil +} + +// Entity returns EntityResolver implementation. +func (r *Resolver) Entity() EntityResolver { return &entityResolver{r} } + +type entityResolver struct{ *Resolver } diff --git a/_examples/federation/products/graph/federation.go b/_examples/federation/products/graph/federation.go new file mode 100644 index 0000000..e606c70 --- /dev/null +++ b/_examples/federation/products/graph/federation.go @@ -0,0 +1,263 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package graph + +import ( + "context" + "errors" + "fmt" + "strings" + "sync" + + "github.com/niko0xdev/gqlgen/plugin/federation/fedruntime" +) + +var ( + ErrUnknownType = errors.New("unknown type") + ErrTypeNotFound = errors.New("type not found") +) + +func (ec *executionContext) __resolve__service(ctx context.Context) (fedruntime.Service, error) { + if ec.DisableIntrospection { + return fedruntime.Service{}, errors.New("federated introspection disabled") + } + + var sdl []string + + for _, src := range sources { + if src.BuiltIn { + continue + } + sdl = append(sdl, src.Input) + } + + return fedruntime.Service{ + SDL: strings.Join(sdl, "\n"), + }, nil +} + +func (ec *executionContext) __resolve_entities(ctx context.Context, representations []map[string]interface{}) []fedruntime.Entity { + list := make([]fedruntime.Entity, len(representations)) + + repsMap := map[string]struct { + i []int + r []map[string]interface{} + }{} + + // We group entities by typename so that we can parallelize their resolution. + // This is particularly helpful when there are entity groups in multi mode. + buildRepresentationGroups := func(reps []map[string]interface{}) { + for i, rep := range reps { + typeName, ok := rep["__typename"].(string) + if !ok { + // If there is no __typename, we just skip the representation; + // we just won't be resolving these unknown types. + ec.Error(ctx, errors.New("__typename must be an existing string")) + continue + } + + _r := repsMap[typeName] + _r.i = append(_r.i, i) + _r.r = append(_r.r, rep) + repsMap[typeName] = _r + } + } + + isMulti := func(typeName string) bool { + switch typeName { + default: + return false + } + } + + resolveEntity := func(ctx context.Context, typeName string, rep map[string]interface{}, idx []int, i int) (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) + } + }() + + switch typeName { + case "Manufacturer": + resolverName, err := entityResolverNameForManufacturer(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "Manufacturer": %w`, err) + } + switch resolverName { + + case "findManufacturerByID": + id0, err := ec.unmarshalNString2string(ctx, rep["id"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findManufacturerByID(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindManufacturerByID(ctx, id0) + if err != nil { + return fmt.Errorf(`resolving Entity "Manufacturer": %w`, err) + } + + list[idx[i]] = entity + return nil + } + case "Product": + resolverName, err := entityResolverNameForProduct(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "Product": %w`, err) + } + switch resolverName { + + case "findProductByManufacturerIDAndID": + id0, err := ec.unmarshalNString2string(ctx, rep["manufacturer"].(map[string]interface{})["id"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findProductByManufacturerIDAndID(): %w`, err) + } + id1, err := ec.unmarshalNString2string(ctx, rep["id"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 1 for findProductByManufacturerIDAndID(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindProductByManufacturerIDAndID(ctx, id0, id1) + if err != nil { + return fmt.Errorf(`resolving Entity "Product": %w`, err) + } + + list[idx[i]] = entity + return nil + case "findProductByUpc": + id0, err := ec.unmarshalNString2string(ctx, rep["upc"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findProductByUpc(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindProductByUpc(ctx, id0) + if err != nil { + return fmt.Errorf(`resolving Entity "Product": %w`, err) + } + + list[idx[i]] = entity + return nil + } + + } + return fmt.Errorf("%w: %s", ErrUnknownType, typeName) + } + + resolveManyEntities := func(ctx context.Context, typeName string, reps []map[string]interface{}, idx []int) (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) + } + }() + + switch typeName { + + default: + return errors.New("unknown type: " + typeName) + } + } + + resolveEntityGroup := func(typeName string, reps []map[string]interface{}, idx []int) { + if isMulti(typeName) { + err := resolveManyEntities(ctx, typeName, reps, idx) + if err != nil { + ec.Error(ctx, err) + } + } else { + // if there are multiple entities to resolve, parallelize (similar to + // graphql.FieldSet.Dispatch) + var e sync.WaitGroup + e.Add(len(reps)) + for i, rep := range reps { + i, rep := i, rep + go func(i int, rep map[string]interface{}) { + err := resolveEntity(ctx, typeName, rep, idx, i) + if err != nil { + ec.Error(ctx, err) + } + e.Done() + }(i, rep) + } + e.Wait() + } + } + buildRepresentationGroups(representations) + + switch len(repsMap) { + case 0: + return list + case 1: + for typeName, reps := range repsMap { + resolveEntityGroup(typeName, reps.r, reps.i) + } + return list + default: + var g sync.WaitGroup + g.Add(len(repsMap)) + for typeName, reps := range repsMap { + go func(typeName string, reps []map[string]interface{}, idx []int) { + resolveEntityGroup(typeName, reps, idx) + g.Done() + }(typeName, reps.r, reps.i) + } + g.Wait() + return list + } +} + +func entityResolverNameForManufacturer(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["id"]; !ok { + break + } + return "findManufacturerByID", nil + } + return "", fmt.Errorf("%w for Manufacturer", ErrTypeNotFound) +} + +func entityResolverNameForProduct(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if val, ok = m["manufacturer"]; !ok { + break + } + if m, ok = val.(map[string]interface{}); !ok { + break + } + if _, ok = m["id"]; !ok { + break + } + m = rep + if _, ok = m["id"]; !ok { + break + } + return "findProductByManufacturerIDAndID", nil + } + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["upc"]; !ok { + break + } + return "findProductByUpc", nil + } + return "", fmt.Errorf("%w for Product", ErrTypeNotFound) +} diff --git a/_examples/federation/products/graph/generated.go b/_examples/federation/products/graph/generated.go new file mode 100644 index 0000000..73afcad --- /dev/null +++ b/_examples/federation/products/graph/generated.go @@ -0,0 +1,4604 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package graph + +import ( + "bytes" + "context" + "embed" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/_examples/federation/products/graph/model" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + "github.com/niko0xdev/gqlgen/plugin/federation/fedruntime" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Entity() EntityResolver + Query() QueryResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + Entity struct { + FindManufacturerByID func(childComplexity int, id string) int + FindProductByManufacturerIDAndID func(childComplexity int, manufacturerID string, id string) int + FindProductByUpc func(childComplexity int, upc string) int + } + + Manufacturer struct { + ID func(childComplexity int) int + Name func(childComplexity int) int + } + + Product struct { + 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 { + TopProducts func(childComplexity int, first *int) int + __resolve__service func(childComplexity int) int + __resolve_entities func(childComplexity int, representations []map[string]interface{}) int + } + + _Service struct { + SDL func(childComplexity int) int + } +} + +type EntityResolver interface { + FindManufacturerByID(ctx context.Context, id string) (*model.Manufacturer, error) + FindProductByManufacturerIDAndID(ctx context.Context, manufacturerID string, id string) (*model.Product, error) + FindProductByUpc(ctx context.Context, upc string) (*model.Product, error) +} +type QueryResolver interface { + TopProducts(ctx context.Context, first *int) ([]*model.Product, error) +} + +type executableSchema struct { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = ec + switch typeName + "." + field { + + 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_findProductByManufacturerIDAndID_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindProductByManufacturerIDAndID(childComplexity, args["manufacturerID"].(string), args["id"].(string)), true + + case "Entity.findProductByUpc": + if e.complexity.Entity.FindProductByUpc == nil { + break + } + + args, err := ec.field_Entity_findProductByUpc_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindProductByUpc(childComplexity, args["upc"].(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 { + break + } + + return e.complexity.Product.Name(childComplexity), true + + case "Product.price": + if e.complexity.Product.Price == nil { + break + } + + return e.complexity.Product.Price(childComplexity), true + + case "Product.upc": + if e.complexity.Product.Upc == nil { + break + } + + return e.complexity.Product.Upc(childComplexity), true + + case "Query.topProducts": + if e.complexity.Query.TopProducts == nil { + break + } + + args, err := ec.field_Query_topProducts_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.TopProducts(childComplexity, args["first"].(*int)), true + + case "Query._service": + if e.complexity.Query.__resolve__service == nil { + break + } + + return e.complexity.Query.__resolve__service(childComplexity), true + + case "Query._entities": + if e.complexity.Query.__resolve_entities == nil { + break + } + + args, err := ec.field_Query__entities_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.__resolve_entities(childComplexity, args["representations"].([]map[string]interface{})), true + + case "_Service.sdl": + if e.complexity._Service.SDL == nil { + break + } + + return e.complexity._Service.SDL(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap() + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } +} + +type executionContext struct { + *graphql.OperationContext + *executableSchema + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + +//go:embed "schema.graphqls" +var sourcesFS embed.FS + +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) +} + +var sources = []*ast.Source{ + {Name: "schema.graphqls", Input: sourceData("schema.graphqls"), BuiltIn: false}, + {Name: "../federation/directives.graphql", Input: ` + directive @key(fields: _FieldSet!) repeatable on OBJECT | INTERFACE + directive @requires(fields: _FieldSet!) on FIELD_DEFINITION + directive @provides(fields: _FieldSet!) on FIELD_DEFINITION + directive @extends on OBJECT | INTERFACE + directive @external on FIELD_DEFINITION + scalar _Any + scalar _FieldSet +`, BuiltIn: true}, + {Name: "../federation/entity.graphql", Input: ` +# a union of all types that use the @key directive +union _Entity = Manufacturer | Product + +# fake type to build resolver interfaces for users to implement +type Entity { + findManufacturerByID(id: String!,): Manufacturer! + findProductByManufacturerIDAndID(manufacturerID: String!,id: String!,): Product! + findProductByUpc(upc: String!,): Product! + +} + +type _Service { + sdl: String +} + +extend type Query { + _entities(representations: [_Any!]!): [_Entity]! + _service: _Service! +} +`, BuiltIn: true}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +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["manufacturerID"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("manufacturerID")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + 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 +} + +func (ec *executionContext) field_Entity_findProductByUpc_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")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["upc"] = arg0 + return args, nil +} + +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__entities_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["representations"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("representations")) + arg0, err = ec.unmarshalN_Any2ᚕmapᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["representations"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_topProducts_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["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg0, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg0 + return args, nil +} + +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) _Entity_findManufacturerByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findManufacturerByID(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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ᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋproductsᚋgraphᚋmodelᚐManufacturer(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findManufacturerByID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Manufacturer_id(ctx, field) + case "name": + return ec.fieldContext_Manufacturer_name(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Manufacturer", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findManufacturerByID_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Entity_findProductByManufacturerIDAndID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findProductByManufacturerIDAndID(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindProductByManufacturerIDAndID(rctx, fc.Args["manufacturerID"].(string), fc.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.Product) + fc.Result = res + return ec.marshalNProduct2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋproductsᚋgraphᚋmodelᚐProduct(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findProductByManufacturerIDAndID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Product_id(ctx, field) + case "manufacturer": + return ec.fieldContext_Product_manufacturer(ctx, field) + case "upc": + return ec.fieldContext_Product_upc(ctx, field) + case "name": + return ec.fieldContext_Product_name(ctx, field) + case "price": + return ec.fieldContext_Product_price(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Product", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findProductByManufacturerIDAndID_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Entity_findProductByUpc(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findProductByUpc(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.Args["upc"].(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.Product) + fc.Result = res + return ec.marshalNProduct2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋproductsᚋgraphᚋmodelᚐProduct(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findProductByUpc(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Product_id(ctx, field) + case "manufacturer": + return ec.fieldContext_Product_manufacturer(ctx, field) + case "upc": + return ec.fieldContext_Product_upc(ctx, field) + case "name": + return ec.fieldContext_Product_name(ctx, field) + case "price": + return ec.fieldContext_Product_price(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Product", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findProductByUpc_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Manufacturer_id(ctx context.Context, field graphql.CollectedField, obj *model.Manufacturer) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Manufacturer_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Manufacturer_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Manufacturer", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Manufacturer_name(ctx context.Context, field graphql.CollectedField, obj *model.Manufacturer) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Manufacturer_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Manufacturer_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Manufacturer", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Product_id(ctx context.Context, field graphql.CollectedField, obj *model.Product) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Product_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Product_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Product", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Product_manufacturer(ctx context.Context, field graphql.CollectedField, obj *model.Product) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Product_manufacturer(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋproductsᚋgraphᚋmodelᚐManufacturer(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Product_manufacturer(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Product", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Manufacturer_id(ctx, field) + case "name": + return ec.fieldContext_Manufacturer_name(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Manufacturer", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Product_upc(ctx context.Context, field graphql.CollectedField, obj *model.Product) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Product_upc(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Upc, 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) fieldContext_Product_upc(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Product", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Product_name(ctx context.Context, field graphql.CollectedField, obj *model.Product) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Product_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Product_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Product", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Product_price(ctx context.Context, field graphql.CollectedField, obj *model.Product) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Product_price(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Price, 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.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Product_price(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Product", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_topProducts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_topProducts(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().TopProducts(rctx, fc.Args["first"].(*int)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*model.Product) + fc.Result = res + return ec.marshalOProduct2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋproductsᚋgraphᚋmodelᚐProduct(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_topProducts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Product_id(ctx, field) + case "manufacturer": + return ec.fieldContext_Product_manufacturer(ctx, field) + case "upc": + return ec.fieldContext_Product_upc(ctx, field) + case "name": + return ec.fieldContext_Product_name(ctx, field) + case "price": + return ec.fieldContext_Product_price(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Product", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_topProducts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query__entities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query__entities(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.Args["representations"].([]map[string]interface{})), 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.([]fedruntime.Entity) + fc.Result = res + return ec.marshalN_Entity2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query__entities(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type _Entity does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query__entities_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query__service(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query__service(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.__resolve__service(ctx) + }) + 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.(fedruntime.Service) + fc.Result = res + return ec.marshalN_Service2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query__service(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "sdl": + return ec.fieldContext__Service_sdl(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type _Service", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) __Service_sdl(ctx context.Context, field graphql.CollectedField, obj *fedruntime.Service) (ret graphql.Marshaler) { + fc, err := ec.fieldContext__Service_sdl(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SDL, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalOString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext__Service_sdl(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "_Service", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), 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.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), 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.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), 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.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, obj fedruntime.Entity) graphql.Marshaler { + 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: + if obj == nil { + return graphql.Null + } + return ec._Product(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +// endregion ************************** interface.gotpl *************************** + +// 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", + }) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + 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 "findManufacturerByID": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Entity_findManufacturerByID(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "findProductByManufacturerIDAndID": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "findProductByUpc": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Entity_findProductByUpc(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Manufacturer") + case "id": + out.Values[i] = ec._Manufacturer_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec._Manufacturer_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Product") + case "id": + out.Values[i] = ec._Product_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "manufacturer": + out.Values[i] = ec._Product_manufacturer(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "upc": + out.Values[i] = ec._Product_upc(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec._Product_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "price": + out.Values[i] = ec._Product_price(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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 + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_topProducts(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "_entities": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query__entities(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "_service": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query__service(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("_Service") + case "sdl": + out.Values[i] = ec.__Service_sdl(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNManufacturer2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋ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ᚋniko0xdevᚋgqlgenᚋ_examplesᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Manufacturer(ctx, sel, v) +} + +func (ec *executionContext) marshalNProduct2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋproductsᚋgraphᚋmodelᚐProduct(ctx context.Context, sel ast.SelectionSet, v model.Product) graphql.Marshaler { + return ec._Product(ctx, sel, &v) +} + +func (ec *executionContext) marshalNProduct2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋproductsᚋgraphᚋmodelᚐProduct(ctx context.Context, sel ast.SelectionSet, v *model.Product) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Product(ctx, sel, v) +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN_Any2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { + res, err := graphql.UnmarshalMap(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalN_Any2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + res := graphql.MarshalMap(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN_Any2ᚕmapᚄ(ctx context.Context, v interface{}) ([]map[string]interface{}, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]map[string]interface{}, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalN_Any2map(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalN_Any2ᚕmapᚄ(ctx context.Context, sel ast.SelectionSet, v []map[string]interface{}) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalN_Any2map(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalN_Entity2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v []fedruntime.Entity) 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.marshalO_Entity2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) unmarshalN_FieldSet2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalN_FieldSet2string(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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalN_Service2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx context.Context, sel ast.SelectionSet, v fedruntime.Service) graphql.Marshaler { + return ec.__Service(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + 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) 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) marshalOProduct2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋproductsᚋgraphᚋmodelᚐProduct(ctx context.Context, sel ast.SelectionSet, v []*model.Product) 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.marshalOProduct2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋproductsᚋgraphᚋmodelᚐProduct(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) marshalOProduct2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋproductsᚋgraphᚋmodelᚐProduct(ctx context.Context, sel ast.SelectionSet, v *model.Product) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Product(ctx, sel, v) +} + +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 + } + 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) marshalO_Entity2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v fedruntime.Entity) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.__Entity(ctx, sel, v) +} + +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/_examples/federation/products/graph/model/model.go b/_examples/federation/products/graph/model/model.go new file mode 100644 index 0000000..8b53790 --- /dev/null +++ b/_examples/federation/products/graph/model/model.go @@ -0,0 +1 @@ +package model diff --git a/_examples/federation/products/graph/model/models_gen.go b/_examples/federation/products/graph/model/models_gen.go new file mode 100644 index 0000000..f41effd --- /dev/null +++ b/_examples/federation/products/graph/model/models_gen.go @@ -0,0 +1,23 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package model + +type Manufacturer struct { + ID string `json:"id"` + Name string `json:"name"` +} + +func (Manufacturer) IsEntity() {} + +type Product struct { + ID string `json:"id"` + Manufacturer *Manufacturer `json:"manufacturer"` + Upc string `json:"upc"` + Name string `json:"name"` + Price int `json:"price"` +} + +func (Product) IsEntity() {} + +type Query struct { +} diff --git a/_examples/federation/products/graph/products.go b/_examples/federation/products/graph/products.go new file mode 100644 index 0000000..88093ec --- /dev/null +++ b/_examples/federation/products/graph/products.go @@ -0,0 +1,36 @@ +package graph + +import "github.com/niko0xdev/gqlgen/_examples/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/_examples/federation/products/graph/resolver.go b/_examples/federation/products/graph/resolver.go new file mode 100644 index 0000000..278fb7d --- /dev/null +++ b/_examples/federation/products/graph/resolver.go @@ -0,0 +1,6 @@ +// This file will not be regenerated automatically. +// +// It serves as dependency injection for your app, add any dependencies you require here. +package graph + +type Resolver struct{} diff --git a/_examples/federation/products/graph/schema.graphqls b/_examples/federation/products/graph/schema.graphqls new file mode 100644 index 0000000..8c1f0e7 --- /dev/null +++ b/_examples/federation/products/graph/schema.graphqls @@ -0,0 +1,16 @@ +extend type Query { + topProducts(first: Int = 5): [Product] +} + +type Manufacturer @key(fields: "id") { + id: String! + name: String! +} + +type Product @key(fields: "manufacturer { id } id") @key(fields: "upc") { + id: String! + manufacturer: Manufacturer! + upc: String! + name: String! + price: Int! +} diff --git a/_examples/federation/products/graph/schema.resolvers.go b/_examples/federation/products/graph/schema.resolvers.go new file mode 100644 index 0000000..ee5a20d --- /dev/null +++ b/_examples/federation/products/graph/schema.resolvers.go @@ -0,0 +1,21 @@ +package graph + +// 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. +// Code generated by github.com/niko0xdev/gqlgen version v0.17.42-dev + +import ( + "context" + + "github.com/niko0xdev/gqlgen/_examples/federation/products/graph/model" +) + +// TopProducts is the resolver for the topProducts field. +func (r *queryResolver) TopProducts(ctx context.Context, first *int) ([]*model.Product, error) { + return hats, nil +} + +// Query returns QueryResolver implementation. +func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } + +type queryResolver struct{ *Resolver } diff --git a/_examples/federation/products/server.go b/_examples/federation/products/server.go new file mode 100644 index 0000000..ccaedf8 --- /dev/null +++ b/_examples/federation/products/server.go @@ -0,0 +1,31 @@ +//go:generate go run ../../../testdata/gqlgen.go +package main + +import ( + "log" + "net/http" + "os" + + "github.com/niko0xdev/gqlgen/_examples/federation/products/graph" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/handler/debug" + "github.com/niko0xdev/gqlgen/graphql/playground" +) + +const defaultPort = "4002" + +func main() { + port := os.Getenv("PORT") + if port == "" { + port = defaultPort + } + + srv := handler.NewDefaultServer(graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}})) + srv.Use(&debug.Tracer{}) + + http.Handle("/", playground.Handler("GraphQL playground", "/query")) + http.Handle("/query", srv) + + log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) + log.Fatal(http.ListenAndServe(":"+port, nil)) +} diff --git a/_examples/federation/readme.md b/_examples/federation/readme.md new file mode 100644 index 0000000..745a91e --- /dev/null +++ b/_examples/federation/readme.md @@ -0,0 +1,3 @@ +### Federation + +[Read the docs](https://gqlgen.com/recipes/federation/) diff --git a/_examples/federation/reviews/gqlgen.yml b/_examples/federation/reviews/gqlgen.yml new file mode 100644 index 0000000..1136a81 --- /dev/null +++ b/_examples/federation/reviews/gqlgen.yml @@ -0,0 +1,68 @@ +# Where are all the schema files located? globs are supported eg src/**/*.graphqls +schema: + - graph/*.graphqls + +# Where should the generated server code go? +exec: + filename: graph/generated.go + package: graph + +federation: + filename: graph/federation.go + package: graph + +# Where should any generated models go? +model: + filename: graph/model/models_gen.go + package: model + +# Where should the resolver implementations go? +resolver: + layout: follow-schema + dir: graph + package: graph + +# Optional: turn on use `gqlgen:"fieldName"` tags in your models +# struct_tag: json + +# Optional: turn on to use []Thing instead of []*Thing +# omit_slice_element_pointers: false + +# Optional: turn off to make struct-type struct fields not use pointers +# e.g. type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing } +# struct_fields_always_pointers: true + +# Optional: turn off to make resolvers return values instead of pointers for structs +# resolvers_always_return_pointers: true + +# Optional: turn on to return pointers instead of values in unmarshalInput +# return_pointers_in_unmarshalinput: false + +# Optional: wrap nullable input fields with Omittable +# nullable_input_omittable: true + +# Optional: set to speed up generation time by not performing a final validation pass. +# skip_validation: 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: + - "github.com/niko0xdev/gqlgen/_examples/federation/reviews/graph/model" + +# This section declares type mapping between the GraphQL and go type systems +# +# The first line in each type will be used as defaults for resolver arguments and +# modelgen, the others will be allowed when binding to fields. Configure them to +# your liking +models: + ID: + model: + - github.com/niko0xdev/gqlgen/graphql.ID + - github.com/niko0xdev/gqlgen/graphql.Int + - github.com/niko0xdev/gqlgen/graphql.Int64 + - github.com/niko0xdev/gqlgen/graphql.Int32 + Int: + model: + - github.com/niko0xdev/gqlgen/graphql.Int + - github.com/niko0xdev/gqlgen/graphql.Int64 + - github.com/niko0xdev/gqlgen/graphql.Int32 diff --git a/_examples/federation/reviews/graph/entity.resolvers.go b/_examples/federation/reviews/graph/entity.resolvers.go new file mode 100644 index 0000000..3e84c71 --- /dev/null +++ b/_examples/federation/reviews/graph/entity.resolvers.go @@ -0,0 +1,42 @@ +package graph + +// 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. +// Code generated by github.com/niko0xdev/gqlgen version v0.17.42-dev + +import ( + "context" + + "github.com/niko0xdev/gqlgen/_examples/federation/reviews/graph/model" +) + +// FindProductByManufacturerIDAndID is the resolver for the findProductByManufacturerIDAndID field. +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{ + ID: id, + Manufacturer: &model.Manufacturer{ + ID: manufacturerID, + }, + Reviews: productReviews, + }, nil +} + +// FindUserByID is the resolver for the findUserByID field. +func (r *entityResolver) FindUserByID(ctx context.Context, id string) (*model.User, error) { + return &model.User{ + ID: id, + Host: &model.EmailHost{}, + }, nil +} + +// Entity returns EntityResolver implementation. +func (r *Resolver) Entity() EntityResolver { return &entityResolver{r} } + +type entityResolver struct{ *Resolver } diff --git a/_examples/federation/reviews/graph/federation.go b/_examples/federation/reviews/graph/federation.go new file mode 100644 index 0000000..114b44b --- /dev/null +++ b/_examples/federation/reviews/graph/federation.go @@ -0,0 +1,246 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package graph + +import ( + "context" + "errors" + "fmt" + "strings" + "sync" + + "github.com/niko0xdev/gqlgen/plugin/federation/fedruntime" +) + +var ( + ErrUnknownType = errors.New("unknown type") + ErrTypeNotFound = errors.New("type not found") +) + +func (ec *executionContext) __resolve__service(ctx context.Context) (fedruntime.Service, error) { + if ec.DisableIntrospection { + return fedruntime.Service{}, errors.New("federated introspection disabled") + } + + var sdl []string + + for _, src := range sources { + if src.BuiltIn { + continue + } + sdl = append(sdl, src.Input) + } + + return fedruntime.Service{ + SDL: strings.Join(sdl, "\n"), + }, nil +} + +func (ec *executionContext) __resolve_entities(ctx context.Context, representations []map[string]interface{}) []fedruntime.Entity { + list := make([]fedruntime.Entity, len(representations)) + + repsMap := map[string]struct { + i []int + r []map[string]interface{} + }{} + + // We group entities by typename so that we can parallelize their resolution. + // This is particularly helpful when there are entity groups in multi mode. + buildRepresentationGroups := func(reps []map[string]interface{}) { + for i, rep := range reps { + typeName, ok := rep["__typename"].(string) + if !ok { + // If there is no __typename, we just skip the representation; + // we just won't be resolving these unknown types. + ec.Error(ctx, errors.New("__typename must be an existing string")) + continue + } + + _r := repsMap[typeName] + _r.i = append(_r.i, i) + _r.r = append(_r.r, rep) + repsMap[typeName] = _r + } + } + + isMulti := func(typeName string) bool { + switch typeName { + default: + return false + } + } + + resolveEntity := func(ctx context.Context, typeName string, rep map[string]interface{}, idx []int, i int) (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) + } + }() + + switch typeName { + case "Product": + resolverName, err := entityResolverNameForProduct(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "Product": %w`, err) + } + switch resolverName { + + case "findProductByManufacturerIDAndID": + id0, err := ec.unmarshalNString2string(ctx, rep["manufacturer"].(map[string]interface{})["id"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findProductByManufacturerIDAndID(): %w`, err) + } + id1, err := ec.unmarshalNString2string(ctx, rep["id"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 1 for findProductByManufacturerIDAndID(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindProductByManufacturerIDAndID(ctx, id0, id1) + if err != nil { + return fmt.Errorf(`resolving Entity "Product": %w`, err) + } + + list[idx[i]] = entity + return nil + } + case "User": + resolverName, err := entityResolverNameForUser(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "User": %w`, err) + } + switch resolverName { + + case "findUserByID": + id0, err := ec.unmarshalNID2string(ctx, rep["id"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findUserByID(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindUserByID(ctx, id0) + if err != nil { + return fmt.Errorf(`resolving Entity "User": %w`, err) + } + + entity.Host.ID, err = ec.unmarshalNString2string(ctx, rep["host"].(map[string]interface{})["id"]) + if err != nil { + return err + } + entity.Email, err = ec.unmarshalNString2string(ctx, rep["email"]) + if err != nil { + return err + } + list[idx[i]] = entity + return nil + } + + } + return fmt.Errorf("%w: %s", ErrUnknownType, typeName) + } + + resolveManyEntities := func(ctx context.Context, typeName string, reps []map[string]interface{}, idx []int) (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) + } + }() + + switch typeName { + + default: + return errors.New("unknown type: " + typeName) + } + } + + resolveEntityGroup := func(typeName string, reps []map[string]interface{}, idx []int) { + if isMulti(typeName) { + err := resolveManyEntities(ctx, typeName, reps, idx) + if err != nil { + ec.Error(ctx, err) + } + } else { + // if there are multiple entities to resolve, parallelize (similar to + // graphql.FieldSet.Dispatch) + var e sync.WaitGroup + e.Add(len(reps)) + for i, rep := range reps { + i, rep := i, rep + go func(i int, rep map[string]interface{}) { + err := resolveEntity(ctx, typeName, rep, idx, i) + if err != nil { + ec.Error(ctx, err) + } + e.Done() + }(i, rep) + } + e.Wait() + } + } + buildRepresentationGroups(representations) + + switch len(repsMap) { + case 0: + return list + case 1: + for typeName, reps := range repsMap { + resolveEntityGroup(typeName, reps.r, reps.i) + } + return list + default: + var g sync.WaitGroup + g.Add(len(repsMap)) + for typeName, reps := range repsMap { + go func(typeName string, reps []map[string]interface{}, idx []int) { + resolveEntityGroup(typeName, reps, idx) + g.Done() + }(typeName, reps.r, reps.i) + } + g.Wait() + return list + } +} + +func entityResolverNameForProduct(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if val, ok = m["manufacturer"]; !ok { + break + } + if m, ok = val.(map[string]interface{}); !ok { + break + } + if _, ok = m["id"]; !ok { + break + } + m = rep + if _, ok = m["id"]; !ok { + break + } + return "findProductByManufacturerIDAndID", nil + } + return "", fmt.Errorf("%w for Product", ErrTypeNotFound) +} + +func entityResolverNameForUser(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["id"]; !ok { + break + } + return "findUserByID", nil + } + return "", fmt.Errorf("%w for User", ErrTypeNotFound) +} diff --git a/_examples/federation/reviews/graph/generated.go b/_examples/federation/reviews/graph/generated.go new file mode 100644 index 0000000..dcf426e --- /dev/null +++ b/_examples/federation/reviews/graph/generated.go @@ -0,0 +1,4843 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package graph + +import ( + "bytes" + "context" + "embed" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/_examples/federation/reviews/graph/model" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + "github.com/niko0xdev/gqlgen/plugin/federation/fedruntime" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Entity() EntityResolver + User() UserResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + EmailHost struct { + ID func(childComplexity int) int + } + + Entity struct { + 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 { + ID func(childComplexity int) int + Manufacturer func(childComplexity int) int + Reviews func(childComplexity int) int + } + + Query struct { + __resolve__service func(childComplexity int) int + __resolve_entities func(childComplexity int, representations []map[string]interface{}) int + } + + Review struct { + Author func(childComplexity int) int + Body func(childComplexity int) int + Product func(childComplexity int) int + } + + User struct { + Email func(childComplexity int) int + Host func(childComplexity int) int + ID func(childComplexity int) int + Reviews func(childComplexity int) int + } + + _Service struct { + SDL func(childComplexity int) int + } +} + +type EntityResolver interface { + FindProductByManufacturerIDAndID(ctx context.Context, manufacturerID string, id string) (*model.Product, error) + FindUserByID(ctx context.Context, id string) (*model.User, error) +} +type UserResolver interface { + Reviews(ctx context.Context, obj *model.User) ([]*model.Review, error) +} + +type executableSchema struct { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = ec + switch typeName + "." + field { + + 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_findProductByManufacturerIDAndID_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindProductByManufacturerIDAndID(childComplexity, args["manufacturerID"].(string), args["id"].(string)), true + + case "Entity.findUserByID": + if e.complexity.Entity.FindUserByID == nil { + break + } + + args, err := ec.field_Entity_findUserByID_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindUserByID(childComplexity, args["id"].(string)), true + + case "Manufacturer.id": + if e.complexity.Manufacturer.ID == nil { + break + } + + return e.complexity.Manufacturer.ID(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.reviews": + if e.complexity.Product.Reviews == nil { + break + } + + return e.complexity.Product.Reviews(childComplexity), true + + case "Query._service": + if e.complexity.Query.__resolve__service == nil { + break + } + + return e.complexity.Query.__resolve__service(childComplexity), true + + case "Query._entities": + if e.complexity.Query.__resolve_entities == nil { + break + } + + args, err := ec.field_Query__entities_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.__resolve_entities(childComplexity, args["representations"].([]map[string]interface{})), true + + case "Review.author": + if e.complexity.Review.Author == nil { + break + } + + return e.complexity.Review.Author(childComplexity), true + + case "Review.body": + if e.complexity.Review.Body == nil { + break + } + + return e.complexity.Review.Body(childComplexity), true + + case "Review.product": + if e.complexity.Review.Product == nil { + break + } + + 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 + } + + return e.complexity.User.ID(childComplexity), true + + case "User.reviews": + if e.complexity.User.Reviews == nil { + break + } + + return e.complexity.User.Reviews(childComplexity), true + + case "_Service.sdl": + if e.complexity._Service.SDL == nil { + break + } + + return e.complexity._Service.SDL(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap() + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } +} + +type executionContext struct { + *graphql.OperationContext + *executableSchema + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + +//go:embed "schema.graphqls" +var sourcesFS embed.FS + +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) +} + +var sources = []*ast.Source{ + {Name: "schema.graphqls", Input: sourceData("schema.graphqls"), BuiltIn: false}, + {Name: "../federation/directives.graphql", Input: ` + directive @key(fields: _FieldSet!) repeatable on OBJECT | INTERFACE + directive @requires(fields: _FieldSet!) on FIELD_DEFINITION + directive @provides(fields: _FieldSet!) on FIELD_DEFINITION + directive @extends on OBJECT | INTERFACE + directive @external on FIELD_DEFINITION + scalar _Any + scalar _FieldSet +`, BuiltIn: true}, + {Name: "../federation/entity.graphql", Input: ` +# a union of all types that use the @key directive +union _Entity = EmailHost | Manufacturer | Product | User + +# fake type to build resolver interfaces for users to implement +type Entity { + findProductByManufacturerIDAndID(manufacturerID: String!,id: String!,): Product! + findUserByID(id: ID!,): User! + +} + +type _Service { + sdl: String +} + +extend type Query { + _entities(representations: [_Any!]!): [_Entity]! + _service: _Service! +} +`, BuiltIn: true}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +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["manufacturerID"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("manufacturerID")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + 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 +} + +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{}{} + var arg0 string + if tmp, ok := rawArgs["id"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + arg0, err = ec.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil +} + +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__entities_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["representations"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("representations")) + arg0, err = ec.unmarshalN_Any2ᚕmapᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["representations"] = arg0 + return args, nil +} + +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) _EmailHost_id(ctx context.Context, field graphql.CollectedField, obj *model.EmailHost) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_EmailHost_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_EmailHost_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "EmailHost", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Entity_findProductByManufacturerIDAndID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findProductByManufacturerIDAndID(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindProductByManufacturerIDAndID(rctx, fc.Args["manufacturerID"].(string), fc.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.Product) + fc.Result = res + return ec.marshalNProduct2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐProduct(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findProductByManufacturerIDAndID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Product_id(ctx, field) + case "manufacturer": + return ec.fieldContext_Product_manufacturer(ctx, field) + case "reviews": + return ec.fieldContext_Product_reviews(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Product", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findProductByManufacturerIDAndID_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Entity_findUserByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findUserByID(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindUserByID(rctx, fc.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.User) + fc.Result = res + return ec.marshalNUser2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findUserByID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "host": + return ec.fieldContext_User_host(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "reviews": + return ec.fieldContext_User_reviews(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findUserByID_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Manufacturer_id(ctx context.Context, field graphql.CollectedField, obj *model.Manufacturer) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Manufacturer_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Manufacturer_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Manufacturer", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Product_id(ctx context.Context, field graphql.CollectedField, obj *model.Product) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Product_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Product_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Product", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Product_manufacturer(ctx context.Context, field graphql.CollectedField, obj *model.Product) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Product_manufacturer(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐManufacturer(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Product_manufacturer(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Product", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Manufacturer_id(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Manufacturer", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Product_reviews(ctx context.Context, field graphql.CollectedField, obj *model.Product) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Product_reviews(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Reviews, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*model.Review) + fc.Result = res + return ec.marshalOReview2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐReview(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Product_reviews(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Product", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "body": + return ec.fieldContext_Review_body(ctx, field) + case "author": + return ec.fieldContext_Review_author(ctx, field) + case "product": + return ec.fieldContext_Review_product(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Review", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query__entities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query__entities(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.Args["representations"].([]map[string]interface{})), 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.([]fedruntime.Entity) + fc.Result = res + return ec.marshalN_Entity2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query__entities(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type _Entity does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query__entities_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query__service(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query__service(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.__resolve__service(ctx) + }) + 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.(fedruntime.Service) + fc.Result = res + return ec.marshalN_Service2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query__service(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "sdl": + return ec.fieldContext__Service_sdl(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type _Service", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Review_body(ctx context.Context, field graphql.CollectedField, obj *model.Review) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Review_body(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Body, 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) fieldContext_Review_body(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Review", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Review_author(ctx context.Context, field graphql.CollectedField, obj *model.Review) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Review_author(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Author, 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.User) + fc.Result = res + return ec.marshalNUser2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Review_author(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Review", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "host": + return ec.fieldContext_User_host(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "reviews": + return ec.fieldContext_User_reviews(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Review_product(ctx context.Context, field graphql.CollectedField, obj *model.Review) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Review_product(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Product, 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.Product) + fc.Result = res + return ec.marshalNProduct2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐProduct(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Review_product(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Review", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Product_id(ctx, field) + case "manufacturer": + return ec.fieldContext_Product_manufacturer(ctx, field) + case "reviews": + return ec.fieldContext_Product_reviews(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Product", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_host(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_host(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐEmailHost(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_host(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_EmailHost_id(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type EmailHost", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _User_email(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_email(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_User_email(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_reviews(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_reviews(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.User().Reviews(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*model.Review) + fc.Result = res + return ec.marshalOReview2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐReview(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_reviews(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "body": + return ec.fieldContext_Review_body(ctx, field) + case "author": + return ec.fieldContext_Review_author(ctx, field) + case "product": + return ec.fieldContext_Review_product(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Review", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) __Service_sdl(ctx context.Context, field graphql.CollectedField, obj *fedruntime.Service) (ret graphql.Marshaler) { + fc, err := ec.fieldContext__Service_sdl(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SDL, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalOString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext__Service_sdl(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "_Service", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), 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.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), 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.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), 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.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, obj fedruntime.Entity) graphql.Marshaler { + 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: + if obj == nil { + return graphql.Null + } + return ec._Product(ctx, sel, obj) + case model.User: + return ec._User(ctx, sel, &obj) + case *model.User: + if obj == nil { + return graphql.Null + } + return ec._User(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("EmailHost") + case "id": + out.Values[i] = ec._EmailHost_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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 "findProductByManufacturerIDAndID": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "findUserByID": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Entity_findUserByID(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Manufacturer") + case "id": + out.Values[i] = ec._Manufacturer_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Product") + case "id": + out.Values[i] = ec._Product_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "manufacturer": + out.Values[i] = ec._Product_manufacturer(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "reviews": + out.Values[i] = ec._Product_reviews(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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 + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query__entities(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "_service": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query__service(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Review") + case "body": + out.Values[i] = ec._Review_body(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "author": + out.Values[i] = ec._Review_author(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "product": + out.Values[i] = ec._Review_product(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("User") + case "id": + out.Values[i] = ec._User_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "host": + out.Values[i] = ec._User_host(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "email": + out.Values[i] = ec._User_email(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "reviews": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._User_reviews(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("_Service") + case "sdl": + out.Values[i] = ec.__Service_sdl(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNEmailHost2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋ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, "the requested element is null which the schema does not allow") + } + 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) +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNManufacturer2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Manufacturer(ctx, sel, v) +} + +func (ec *executionContext) marshalNProduct2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐProduct(ctx context.Context, sel ast.SelectionSet, v model.Product) graphql.Marshaler { + return ec._Product(ctx, sel, &v) +} + +func (ec *executionContext) marshalNProduct2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐProduct(ctx context.Context, sel ast.SelectionSet, v *model.Product) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Product(ctx, sel, v) +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNUser2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v model.User) graphql.Marshaler { + return ec._User(ctx, sel, &v) +} + +func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._User(ctx, sel, v) +} + +func (ec *executionContext) unmarshalN_Any2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { + res, err := graphql.UnmarshalMap(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalN_Any2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + res := graphql.MarshalMap(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN_Any2ᚕmapᚄ(ctx context.Context, v interface{}) ([]map[string]interface{}, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]map[string]interface{}, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalN_Any2map(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalN_Any2ᚕmapᚄ(ctx context.Context, sel ast.SelectionSet, v []map[string]interface{}) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalN_Any2map(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalN_Entity2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v []fedruntime.Entity) 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.marshalO_Entity2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) unmarshalN_FieldSet2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalN_FieldSet2string(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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalN_Service2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx context.Context, sel ast.SelectionSet, v fedruntime.Service) graphql.Marshaler { + return ec.__Service(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + 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) marshalOReview2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐReview(ctx context.Context, sel ast.SelectionSet, v []*model.Review) 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.marshalOReview2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐReview(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) marshalOReview2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐReview(ctx context.Context, sel ast.SelectionSet, v *model.Review) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Review(ctx, sel, v) +} + +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 + } + 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) marshalO_Entity2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v fedruntime.Entity) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.__Entity(ctx, sel, v) +} + +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/_examples/federation/reviews/graph/model/models.go b/_examples/federation/reviews/graph/model/models.go new file mode 100644 index 0000000..af4eb24 --- /dev/null +++ b/_examples/federation/reviews/graph/model/models.go @@ -0,0 +1,24 @@ +package model + +type Product struct { + ID string `json:"id"` + Manufacturer *Manufacturer `json:"manufacturer"` + Reviews []*Review `json:"reviews"` +} + +func (Product) IsEntity() {} + +type Review struct { + Body string + Author *User + Product *Product +} + +type User struct { + ID string `json:"id"` + Host *EmailHost `json:"host"` + Email string `json:"email"` + // Reviews []*Review `json:"reviews"` +} + +func (User) IsEntity() {} diff --git a/_examples/federation/reviews/graph/model/models_gen.go b/_examples/federation/reviews/graph/model/models_gen.go new file mode 100644 index 0000000..4d0b617 --- /dev/null +++ b/_examples/federation/reviews/graph/model/models_gen.go @@ -0,0 +1,18 @@ +// Code generated by github.com/niko0xdev/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() {} + +type Query struct { +} diff --git a/_examples/federation/reviews/graph/resolver.go b/_examples/federation/reviews/graph/resolver.go new file mode 100644 index 0000000..278fb7d --- /dev/null +++ b/_examples/federation/reviews/graph/resolver.go @@ -0,0 +1,6 @@ +// This file will not be regenerated automatically. +// +// It serves as dependency injection for your app, add any dependencies you require here. +package graph + +type Resolver struct{} diff --git a/_examples/federation/reviews/graph/reviews.go b/_examples/federation/reviews/graph/reviews.go new file mode 100644 index 0000000..c4d7af9 --- /dev/null +++ b/_examples/federation/reviews/graph/reviews.go @@ -0,0 +1,21 @@ +package graph + +import "github.com/niko0xdev/gqlgen/_examples/federation/reviews/graph/model" + +var reviews = []*model.Review{ + { + Body: "A highly effective form of birth control.", + 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{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{ID: "333", Manufacturer: &model.Manufacturer{ID: "2345"}}, + Author: &model.User{ID: "7777"}, + }, +} diff --git a/_examples/federation/reviews/graph/schema.graphqls b/_examples/federation/reviews/graph/schema.graphqls new file mode 100644 index 0000000..fde4071 --- /dev/null +++ b/_examples/federation/reviews/graph/schema.graphqls @@ -0,0 +1,26 @@ +type Review { + body: String! + author: User! @provides(fields: "username") + product: Product! +} + +extend type EmailHost @key(fields: "id") { + id: String! @external +} + +extend type User @key(fields: "id") { + id: ID! @external + 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: " manufacturer{ id} id") { + id: String! @external + manufacturer: Manufacturer! @external + reviews: [Review] +} diff --git a/_examples/federation/reviews/graph/schema.resolvers.go b/_examples/federation/reviews/graph/schema.resolvers.go new file mode 100644 index 0000000..0d425d6 --- /dev/null +++ b/_examples/federation/reviews/graph/schema.resolvers.go @@ -0,0 +1,27 @@ +package graph + +// 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. +// Code generated by github.com/niko0xdev/gqlgen version v0.17.42-dev + +import ( + "context" + + "github.com/niko0xdev/gqlgen/_examples/federation/reviews/graph/model" +) + +// Reviews is the resolver for the reviews field. +func (r *userResolver) Reviews(ctx context.Context, obj *model.User) ([]*model.Review, error) { + var productReviews []*model.Review + for _, review := range reviews { + if review.Author.ID == obj.ID { + productReviews = append(productReviews, review) + } + } + return productReviews, nil +} + +// User returns UserResolver implementation. +func (r *Resolver) User() UserResolver { return &userResolver{r} } + +type userResolver struct{ *Resolver } diff --git a/_examples/federation/reviews/server.go b/_examples/federation/reviews/server.go new file mode 100644 index 0000000..96b0988 --- /dev/null +++ b/_examples/federation/reviews/server.go @@ -0,0 +1,31 @@ +//go:generate go run ../../../testdata/gqlgen.go +package main + +import ( + "log" + "net/http" + "os" + + "github.com/niko0xdev/gqlgen/_examples/federation/reviews/graph" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/handler/debug" + "github.com/niko0xdev/gqlgen/graphql/playground" +) + +const defaultPort = "4003" + +func main() { + port := os.Getenv("PORT") + if port == "" { + port = defaultPort + } + + srv := handler.NewDefaultServer(graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}})) + srv.Use(&debug.Tracer{}) + + http.Handle("/", playground.Handler("GraphQL playground", "/query")) + http.Handle("/query", srv) + + log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) + log.Fatal(http.ListenAndServe(":"+port, nil)) +} diff --git a/_examples/federation/start.sh b/_examples/federation/start.sh new file mode 100755 index 0000000..fe1aa76 --- /dev/null +++ b/_examples/federation/start.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +function cleanup { + kill "$ACCOUNTS_PID" + kill "$PRODUCTS_PID" + kill "$REVIEWS_PID" +} +trap cleanup EXIT + +go build -o /tmp/srv-accounts ./accounts +go build -o /tmp/srv-products ./products +go build -o /tmp/srv-reviews ./reviews + +/tmp/srv-accounts & +ACCOUNTS_PID=$! + +/tmp/srv-products & +PRODUCTS_PID=$! + +/tmp/srv-reviews & +REVIEWS_PID=$! + +sleep 1 + +node gateway/index.js diff --git a/_examples/fileupload/.gqlgen.yml b/_examples/fileupload/.gqlgen.yml new file mode 100644 index 0000000..b71c035 --- /dev/null +++ b/_examples/fileupload/.gqlgen.yml @@ -0,0 +1,2 @@ +model: + filename: model/generated.go diff --git a/_examples/fileupload/fileupload_test.go b/_examples/fileupload/fileupload_test.go new file mode 100644 index 0000000..0072cb0 --- /dev/null +++ b/_examples/fileupload/fileupload_test.go @@ -0,0 +1,293 @@ +//go:generate go run ../../testdata/gqlgen.go -stub stubs.go +package fileupload + +import ( + "context" + "io" + "net/http/httptest" + "os" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/_examples/fileupload/model" + gqlclient "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" +) + +func TestFileUpload(t *testing.T) { + resolver := &Stub{} + srv := httptest.NewServer(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolver}))) + defer srv.Close() + gql := gqlclient.New(srv.Config.Handler, gqlclient.Path("/graphql")) + + aTxtFile, _ := os.CreateTemp(os.TempDir(), "a.txt") + defer os.Remove(aTxtFile.Name()) + aTxtFile.WriteString(`test`) + + a1TxtFile, _ := os.CreateTemp(os.TempDir(), "a.txt") + b1TxtFile, _ := os.CreateTemp(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.MutationResolver.SingleUpload = func(ctx context.Context, file graphql.Upload) (*model.File, error) { + require.NotNil(t, file) + require.NotNil(t, file.File) + content, err := io.ReadAll(file.File) + require.Nil(t, err) + require.Equal(t, string(content), "test") + + return &model.File{ + ID: 1, + Name: file.Filename, + Content: string(content), + ContentType: file.ContentType, + }, nil + } + + mutation := `mutation ($file: Upload!) { + singleUpload(file: $file) { + id + name + content + contentType + } + }` + var result struct { + SingleUpload *model.File + } + + 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.MutationResolver.SingleUploadWithPayload = func(ctx context.Context, req model.UploadFile) (*model.File, error) { + require.Equal(t, req.ID, 1) + require.NotNil(t, req.File) + require.NotNil(t, req.File.File) + content, err := io.ReadAll(req.File.File) + require.Nil(t, err) + require.Equal(t, string(content), "test") + + return &model.File{ + ID: 1, + Name: req.File.Filename, + Content: string(content), + ContentType: req.File.ContentType, + }, nil + } + + mutation := `mutation ($req: UploadFile!) { + singleUploadWithPayload(req: $req) { + id + name + content + contentType + } + }` + var result struct { + SingleUploadWithPayload *model.File + } + + 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.MutationResolver.MultipleUpload = func(ctx context.Context, files []*graphql.Upload) ([]*model.File, error) { + require.Len(t, files, 2) + var contents []string + var resp []*model.File + for i := range files { + require.NotNil(t, files[i].File) + content, err := io.ReadAll(files[i].File) + require.Nil(t, err) + contents = append(contents, string(content)) + resp = append(resp, &model.File{ + ID: i + 1, + Name: files[i].Filename, + Content: string(content), + ContentType: files[i].ContentType, + }) + } + require.ElementsMatch(t, []string{"test1", "test2"}, contents) + return resp, nil + } + + mutation := `mutation($files: [Upload!]!) { + multipleUpload(files: $files) { + id + name + content + contentType + } + }` + var result struct { + MultipleUpload []*model.File + } + + 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.MutationResolver.MultipleUploadWithPayload = func(ctx context.Context, req []*model.UploadFile) ([]*model.File, error) { + require.Len(t, req, 2) + var ids []int + var contents []string + var resp []*model.File + for i := range req { + require.NotNil(t, req[i].File) + require.NotNil(t, req[i].File.File) + content, err := io.ReadAll(req[i].File.File) + require.Nil(t, err) + ids = append(ids, req[i].ID) + contents = append(contents, string(content)) + resp = append(resp, &model.File{ + ID: i + 1, + Name: req[i].File.Filename, + Content: string(content), + ContentType: req[i].File.ContentType, + }) + } + require.ElementsMatch(t, []int{1, 2}, ids) + require.ElementsMatch(t, []string{"test1", "test2"}, contents) + return resp, nil + } + + 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": 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) { + resolver := &Stub{} + resolver.MutationResolver.MultipleUploadWithPayload = func(ctx context.Context, req []*model.UploadFile) ([]*model.File, error) { + require.Len(t, req, 2) + var ids []int + var contents []string + var resp []*model.File + for i := range req { + require.NotNil(t, req[i].File) + require.NotNil(t, req[i].File.File) + ids = append(ids, req[i].ID) + + var got []byte + buf := make([]byte, 2) + for { + n, err := req[i].File.File.Read(buf) + got = append(got, buf[:n]...) + if err != nil { + if err == io.EOF { + break + } + require.Fail(t, "unexpected error while reading", err.Error()) + } + } + contents = append(contents, string(got)) + resp = append(resp, &model.File{ + ID: i + 1, + Name: req[i].File.Filename, + Content: string(got), + ContentType: req[i].File.ContentType, + }) + } + require.ElementsMatch(t, []int{1, 2}, ids) + require.ElementsMatch(t, []string{"test1", "test1"}, contents) + return resp, nil + } + + test := func(uploadMaxMemory int64) { + hndlr := handler.New(NewExecutableSchema(Config{Resolvers: resolver})) + hndlr.AddTransport(transport.MultipartForm{MaxMemory: uploadMaxMemory}) + + srv := httptest.NewServer(hndlr) + defer srv.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) { + test(5000) + }) + + t.Run("payload bigger than UploadMaxMemory, persisted to disk", func(t *testing.T) { + test(2) + }) + }) +} diff --git a/_examples/fileupload/generated.go b/_examples/fileupload/generated.go new file mode 100644 index 0000000..202b781 --- /dev/null +++ b/_examples/fileupload/generated.go @@ -0,0 +1,4060 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package fileupload + +import ( + "bytes" + "context" + "embed" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/_examples/fileupload/model" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Mutation() MutationResolver + Query() QueryResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + File struct { + Content func(childComplexity int) int + ContentType func(childComplexity int) int + ID func(childComplexity int) int + Name func(childComplexity int) int + } + + Mutation struct { + MultipleUpload func(childComplexity int, files []*graphql.Upload) int + MultipleUploadWithPayload func(childComplexity int, req []*model.UploadFile) int + SingleUpload func(childComplexity int, file graphql.Upload) int + SingleUploadWithPayload func(childComplexity int, req model.UploadFile) int + } + + Query struct { + Empty func(childComplexity int) int + } +} + +type MutationResolver interface { + SingleUpload(ctx context.Context, file graphql.Upload) (*model.File, error) + SingleUploadWithPayload(ctx context.Context, req model.UploadFile) (*model.File, error) + MultipleUpload(ctx context.Context, files []*graphql.Upload) ([]*model.File, error) + MultipleUploadWithPayload(ctx context.Context, req []*model.UploadFile) ([]*model.File, error) +} +type QueryResolver interface { + Empty(ctx context.Context) (string, error) +} + +type executableSchema struct { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = ec + switch typeName + "." + field { + + case "File.content": + if e.complexity.File.Content == nil { + break + } + + return e.complexity.File.Content(childComplexity), true + + case "File.contentType": + if e.complexity.File.ContentType == nil { + break + } + + return e.complexity.File.ContentType(childComplexity), true + + case "File.id": + if e.complexity.File.ID == nil { + break + } + + return e.complexity.File.ID(childComplexity), true + + case "File.name": + if e.complexity.File.Name == nil { + break + } + + return e.complexity.File.Name(childComplexity), true + + case "Mutation.multipleUpload": + if e.complexity.Mutation.MultipleUpload == nil { + break + } + + args, err := ec.field_Mutation_multipleUpload_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.MultipleUpload(childComplexity, args["files"].([]*graphql.Upload)), true + + case "Mutation.multipleUploadWithPayload": + if e.complexity.Mutation.MultipleUploadWithPayload == nil { + break + } + + args, err := ec.field_Mutation_multipleUploadWithPayload_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.MultipleUploadWithPayload(childComplexity, args["req"].([]*model.UploadFile)), true + + case "Mutation.singleUpload": + if e.complexity.Mutation.SingleUpload == nil { + break + } + + args, err := ec.field_Mutation_singleUpload_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.SingleUpload(childComplexity, args["file"].(graphql.Upload)), true + + case "Mutation.singleUploadWithPayload": + if e.complexity.Mutation.SingleUploadWithPayload == nil { + break + } + + args, err := ec.field_Mutation_singleUploadWithPayload_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.SingleUploadWithPayload(childComplexity, args["req"].(model.UploadFile)), true + + case "Query.empty": + if e.complexity.Query.Empty == nil { + break + } + + return e.complexity.Query.Empty(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap( + ec.unmarshalInputUploadFile, + ) + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + case ast.Mutation: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data := ec._Mutation(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + 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 + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + +//go:embed "schema.graphql" +var sourcesFS embed.FS + +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) +} + +var sources = []*ast.Source{ + {Name: "schema.graphql", Input: sourceData("schema.graphql"), BuiltIn: false}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (ec *executionContext) field_Mutation_multipleUploadWithPayload_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 []*model.UploadFile + if tmp, ok := rawArgs["req"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("req")) + arg0, err = ec.unmarshalNUploadFile2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐUploadFileᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["req"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_multipleUpload_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 []*graphql.Upload + if tmp, ok := rawArgs["files"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("files")) + arg0, err = ec.unmarshalNUpload2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚐUploadᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["files"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_singleUploadWithPayload_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.UploadFile + if tmp, ok := rawArgs["req"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("req")) + arg0, err = ec.unmarshalNUploadFile2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐUploadFile(ctx, tmp) + if err != nil { + return nil, err + } + } + args["req"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_singleUpload_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 graphql.Upload + if tmp, ok := rawArgs["file"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("file")) + arg0, err = ec.unmarshalNUpload2githubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚐUpload(ctx, tmp) + if err != nil { + return nil, err + } + } + args["file"] = arg0 + return args, nil +} + +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___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) _File_id(ctx context.Context, field graphql.CollectedField, obj *model.File) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_File_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_File_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "File", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _File_name(ctx context.Context, field graphql.CollectedField, obj *model.File) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_File_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_File_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "File", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _File_content(ctx context.Context, field graphql.CollectedField, obj *model.File) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_File_content(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Content, 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) fieldContext_File_content(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "File", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _File_contentType(ctx context.Context, field graphql.CollectedField, obj *model.File) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_File_contentType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ContentType, 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) fieldContext_File_contentType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "File", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Mutation_singleUpload(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_singleUpload(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().SingleUpload(rctx, fc.Args["file"].(graphql.Upload)) + }) + 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.File) + fc.Result = res + return ec.marshalNFile2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐFile(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_singleUpload(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_File_id(ctx, field) + case "name": + return ec.fieldContext_File_name(ctx, field) + case "content": + return ec.fieldContext_File_content(ctx, field) + case "contentType": + return ec.fieldContext_File_contentType(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type File", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_singleUpload_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_singleUploadWithPayload(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_singleUploadWithPayload(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().SingleUploadWithPayload(rctx, fc.Args["req"].(model.UploadFile)) + }) + 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.File) + fc.Result = res + return ec.marshalNFile2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐFile(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_singleUploadWithPayload(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_File_id(ctx, field) + case "name": + return ec.fieldContext_File_name(ctx, field) + case "content": + return ec.fieldContext_File_content(ctx, field) + case "contentType": + return ec.fieldContext_File_contentType(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type File", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_singleUploadWithPayload_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_multipleUpload(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_multipleUpload(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().MultipleUpload(rctx, fc.Args["files"].([]*graphql.Upload)) + }) + 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.File) + fc.Result = res + return ec.marshalNFile2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐFileᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_multipleUpload(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_File_id(ctx, field) + case "name": + return ec.fieldContext_File_name(ctx, field) + case "content": + return ec.fieldContext_File_content(ctx, field) + case "contentType": + return ec.fieldContext_File_contentType(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type File", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_multipleUpload_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_multipleUploadWithPayload(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_multipleUploadWithPayload(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().MultipleUploadWithPayload(rctx, fc.Args["req"].([]*model.UploadFile)) + }) + 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.File) + fc.Result = res + return ec.marshalNFile2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐFileᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_multipleUploadWithPayload(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_File_id(ctx, field) + case "name": + return ec.fieldContext_File_name(ctx, field) + case "content": + return ec.fieldContext_File_content(ctx, field) + case "contentType": + return ec.fieldContext_File_contentType(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type File", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_multipleUploadWithPayload_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_empty(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_empty(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Empty(rctx) + }) + 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) fieldContext_Query_empty(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), 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.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), 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.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), 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.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputUploadFile(ctx context.Context, obj interface{}) (model.UploadFile, error) { + var it model.UploadFile + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"id", "file"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalNInt2int(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "file": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("file")) + data, err := ec.unmarshalNUpload2githubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚐUpload(ctx, v) + if err != nil { + return it, err + } + it.File = data + } + } + + return it, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("File") + case "id": + out.Values[i] = ec._File_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec._File_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "content": + out.Values[i] = ec._File_content(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "contentType": + out.Values[i] = ec._File_contentType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_singleUpload(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "singleUploadWithPayload": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_singleUploadWithPayload(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "multipleUpload": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_multipleUpload(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "multipleUploadWithPayload": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_multipleUploadWithPayload(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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 + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_empty(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNFile2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐFile(ctx context.Context, sel ast.SelectionSet, v model.File) graphql.Marshaler { + return ec._File(ctx, sel, &v) +} + +func (ec *executionContext) marshalNFile2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐFileᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.File) 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.marshalNFile2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐFile(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) marshalNFile2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐFile(ctx context.Context, sel ast.SelectionSet, v *model.File) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._File(ctx, sel, v) +} + +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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNUpload2githubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, v interface{}) (graphql.Upload, error) { + res, err := graphql.UnmarshalUpload(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNUpload2githubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, sel ast.SelectionSet, v graphql.Upload) graphql.Marshaler { + res := graphql.MarshalUpload(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNUpload2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚐUploadᚄ(ctx context.Context, v interface{}) ([]*graphql.Upload, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*graphql.Upload, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNUpload2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚐUpload(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalNUpload2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚐUploadᚄ(ctx context.Context, sel ast.SelectionSet, v []*graphql.Upload) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNUpload2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚐUpload(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) unmarshalNUpload2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, v interface{}) (*graphql.Upload, error) { + res, err := graphql.UnmarshalUpload(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNUpload2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, sel ast.SelectionSet, v *graphql.Upload) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + res := graphql.MarshalUpload(*v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNUploadFile2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐUploadFile(ctx context.Context, v interface{}) (model.UploadFile, error) { + res, err := ec.unmarshalInputUploadFile(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNUploadFile2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐUploadFileᚄ(ctx context.Context, v interface{}) ([]*model.UploadFile, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*model.UploadFile, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNUploadFile2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐUploadFile(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalNUploadFile2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐUploadFile(ctx context.Context, v interface{}) (*model.UploadFile, error) { + res, err := ec.unmarshalInputUploadFile(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + 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) 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) marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/_examples/fileupload/model/generated.go b/_examples/fileupload/model/generated.go new file mode 100644 index 0000000..b35a8d7 --- /dev/null +++ b/_examples/fileupload/model/generated.go @@ -0,0 +1,29 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package model + +import ( + "github.com/niko0xdev/gqlgen/graphql" +) + +// The `File` type, represents the response of uploading a file. +type File struct { + ID int `json:"id"` + Name string `json:"name"` + Content string `json:"content"` + ContentType string `json:"contentType"` +} + +// The `Mutation` type, represents all updates we can make to our data. +type Mutation struct { +} + +// The `Query` type, represents all of the entry points into our object graph. +type Query struct { +} + +// The `UploadFile` type, represents the request for uploading a file with certain payload. +type UploadFile struct { + ID int `json:"id"` + File graphql.Upload `json:"file"` +} diff --git a/_examples/fileupload/readme.md b/_examples/fileupload/readme.md new file mode 100644 index 0000000..03a22e6 --- /dev/null +++ b/_examples/fileupload/readme.md @@ -0,0 +1,229 @@ +### fileupload example + +This server demonstrates how to handle file upload + +to run this server +```bash +go run ./server/server.go +``` + +and open http://localhost:8087 in your browser + + +### Single file + +#### Operations + +``` +{ + query: ` + mutation($file: Upload!) { + singleUpload(file: $file) { + id + } + } + `, + variables: { + file: File // a.txt + } +} +``` + +#### cURL request + +```shell +curl localhost:8087/query \ + -F operations='{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) { id, name, content } }", "variables": { "file": null } }' \ + -F map='{ "0": ["variables.file"] }' \ + -F 0=@./_examples/fileupload./testfiles/a.txt +``` + +#### Request payload + +``` +--------------------------e6b2b29561e71173 +Content-Disposition: form-data; name="operations" + +{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) { id, name, content } }", "variables": { "file": null } } +--------------------------e6b2b29561e71173 +Content-Disposition: form-data; name="map" + +{ "0": ["variables.file"] } +--------------------------e6b2b29561e71173 +Content-Disposition: form-data; name="0"; filename="a.txt" +Content-Type: text/plain + +Alpha file content. +--------------------------e6b2b29561e71173-- +``` + +### Single file with payload + +#### Operations + +``` +{ + query: ` + mutation($file: Upload!) { + singleUpload(file: $file) { + id + } + } + `, + variables: { + file: File // a.txt + } +} +``` + +#### cURL request + +```shell +curl localhost:8087/query \ + -F operations='{ "query": "mutation ($req: UploadFile!) { singleUploadWithPayload(req: $req) { id, name, content } }", "variables": { "req": {"file": null, "id": 1 } } }' \ + -F map='{ "0": ["variables.req.file"] }' \ + -F 0=@./_examples/fileupload/testfiles/a.txt +``` + +#### Request payload + +``` +--------------------------38752760889d14aa +Content-Disposition: form-data; name="operations" + +{ "query": "mutation ($req: UploadFile!) { singleUploadWithPayload(req: $req) { id, name, content } }", "variables": { "req": {"file": null, "id": 1 } } } +--------------------------38752760889d14aa +Content-Disposition: form-data; name="map" + +{ "0": ["variables.req.file"] } +--------------------------38752760889d14aa +Content-Disposition: form-data; name="0"; filename="a.txt" +Content-Type: text/plain + +Alpha file content. +--------------------------38752760889d14aa-- +``` + + +### File list + +#### Operations + +``` +{ + query: ` + mutation($files: [Upload!]!) { + multipleUpload(files: $files) { + id + } + } + `, + variables: { + files: [ + File, // b.txt + File // c.txt + ] + } +} +``` + +#### cURL request + +``` +curl localhost:8087/query \ + -F operations='{ "query": "mutation($files: [Upload!]!) { multipleUpload(files: $files) { id, name, content } }", "variables": { "files": [null, null] } }' \ + -F map='{ "0": ["variables.files.0"], "1": ["variables.files.1"] }' \ + -F 0=@./_examples/fileupload/testfiles/b.txt \ + -F 1=@./_examples/fileupload/testfiles/c.txt +``` + +#### Request payload + +``` +--------------------------d7aca2a93c3655e0 +Content-Disposition: form-data; name="operations" + +{ "query": "mutation($files: [Upload!]!) { multipleUpload(files: $files) { id, name, content } }", "variables": { "files": [null, null] } } +--------------------------d7aca2a93c3655e0 +Content-Disposition: form-data; name="map" + +{ "0": ["variables.files.0"], "1": ["variables.files.1"] } +--------------------------d7aca2a93c3655e0 +Content-Disposition: form-data; name="0"; filename="b.txt" +Content-Type: text/plain + +Bravo file content. +--------------------------d7aca2a93c3655e0 +Content-Disposition: form-data; name="1"; filename="c.txt" +Content-Type: text/plain + +Charlie file content. +--------------------------d7aca2a93c3655e0-- +``` + + + +### File list with payload + +#### Operations + +``` +{ + query: ` + mutation($req: [UploadFile!]!) + multipleUploadWithPayload(req: $req) { + id, + name, + content + } + } + `, + variables: { + req: [ + { + id: 1, + File, // b.txt + }, + { + id: 2, + File, // c.txt + } + ] + } +} +``` + +#### cURL request + +``` +curl localhost:8087/query \ + -F operations='{ "query": "mutation($req: [UploadFile!]!) { multipleUploadWithPayload(req: $req) { id, name, content } }", "variables": { "req": [ { "id": 1, "file": null }, { "id": 2, "file": null } ] } }' \ + -F map='{ "0": ["variables.req.0.file"], "1": ["variables.req.1.file"] }' \ + -F 0=@./_examples/fileupload/testfiles/b.txt \ + -F 1=@./_examples/fileupload/testfiles/c.txt +``` + +#### Request payload + +``` +--------------------------65aab09fb49ee66f +Content-Disposition: form-data; name="operations" + +{ "query": "mutation($req: [UploadFile!]!) { multipleUploadWithPayload(req: $req) { id, name, content } }", "variables": { "req": [ { "id": 1, "file": null }, { "id": 2, "file": null } ] } } +--------------------------65aab09fb49ee66f +Content-Disposition: form-data; name="map" + +{ "0": ["variables.req.0.file"], "1": ["variables.req.1.file"] } +--------------------------65aab09fb49ee66f +Content-Disposition: form-data; name="0"; filename="b.txt" +Content-Type: text/plain + +Bravo file content. +--------------------------65aab09fb49ee66f +Content-Disposition: form-data; name="1"; filename="c.txt" +Content-Type: text/plain + +Charlie file content. +--------------------------65aab09fb49ee66f-- +``` + diff --git a/_examples/fileupload/schema.graphql b/_examples/fileupload/schema.graphql new file mode 100644 index 0000000..f4ded39 --- /dev/null +++ b/_examples/fileupload/schema.graphql @@ -0,0 +1,30 @@ +"The `Upload` scalar type represents a multipart file upload." +scalar Upload + +"The `File` type, represents the response of uploading a file." +type File { + id: Int! + name: String! + content: String! + contentType: String! +} + +"The `UploadFile` type, represents the request for uploading a file with certain payload." +input UploadFile { + id: Int! + file: Upload! +} + +"The `Query` type, represents all of the entry points into our object graph." +type Query { + empty: String! +} + +"The `Mutation` type, represents all updates we can make to our data." +type Mutation { + singleUpload(file: Upload!): File! + singleUploadWithPayload(req: UploadFile!): File! + multipleUpload(files: [Upload!]!): [File!]! + multipleUploadWithPayload(req: [UploadFile!]!): [File!]! +} + diff --git a/_examples/fileupload/server/server.go b/_examples/fileupload/server/server.go new file mode 100644 index 0000000..6dde5fe --- /dev/null +++ b/_examples/fileupload/server/server.go @@ -0,0 +1,100 @@ +package main + +import ( + "context" + "errors" + "io" + "log" + "net/http" + + "github.com/niko0xdev/gqlgen/_examples/fileupload" + "github.com/niko0xdev/gqlgen/_examples/fileupload/model" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/handler/extension" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" + "github.com/niko0xdev/gqlgen/graphql/playground" +) + +func main() { + http.Handle("/", playground.Handler("File Upload Demo", "/query")) + resolver := getResolver() + + var mb int64 = 1 << 20 + + srv := handler.NewDefaultServer(fileupload.NewExecutableSchema(fileupload.Config{Resolvers: resolver})) + srv.AddTransport(transport.POST{}) + srv.AddTransport(transport.MultipartForm{ + MaxMemory: 32 * mb, + MaxUploadSize: 50 * mb, + }) + srv.Use(extension.Introspection{}) + + http.Handle("/query", srv) + log.Print("connect to http://localhost:8087/ for GraphQL playground") + log.Fatal(http.ListenAndServe(":8087", nil)) +} + +func getResolver() *fileupload.Stub { + resolver := &fileupload.Stub{} + + resolver.MutationResolver.SingleUpload = func(ctx context.Context, file graphql.Upload) (*model.File, error) { + content, err := io.ReadAll(file.File) + if err != nil { + return nil, err + } + return &model.File{ + ID: 1, + Name: file.Filename, + Content: string(content), + }, nil + } + resolver.MutationResolver.SingleUploadWithPayload = func(ctx context.Context, req model.UploadFile) (*model.File, error) { + content, err := io.ReadAll(req.File.File) + if err != nil { + return nil, err + } + return &model.File{ + ID: 1, + Name: req.File.Filename, + Content: string(content), + }, nil + } + resolver.MutationResolver.MultipleUpload = func(ctx context.Context, files []*graphql.Upload) ([]*model.File, error) { + if len(files) == 0 { + return nil, errors.New("empty list") + } + var resp []*model.File + for i := range files { + content, err := io.ReadAll(files[i].File) + if err != nil { + return []*model.File{}, err + } + resp = append(resp, &model.File{ + ID: i + 1, + Name: files[i].Filename, + Content: string(content), + }) + } + return resp, nil + } + resolver.MutationResolver.MultipleUploadWithPayload = func(ctx context.Context, req []*model.UploadFile) ([]*model.File, error) { + if len(req) == 0 { + return nil, errors.New("empty list") + } + var resp []*model.File + for i := range req { + content, err := io.ReadAll(req[i].File.File) + if err != nil { + return []*model.File{}, err + } + resp = append(resp, &model.File{ + ID: i + 1, + Name: req[i].File.Filename, + Content: string(content), + }) + } + return resp, nil + } + return resolver +} diff --git a/_examples/fileupload/stubs.go b/_examples/fileupload/stubs.go new file mode 100644 index 0000000..24e4314 --- /dev/null +++ b/_examples/fileupload/stubs.go @@ -0,0 +1,50 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package fileupload + +import ( + "context" + + "github.com/niko0xdev/gqlgen/_examples/fileupload/model" + "github.com/niko0xdev/gqlgen/graphql" +) + +type Stub struct { + MutationResolver struct { + SingleUpload func(ctx context.Context, file graphql.Upload) (*model.File, error) + SingleUploadWithPayload func(ctx context.Context, req model.UploadFile) (*model.File, error) + MultipleUpload func(ctx context.Context, files []*graphql.Upload) ([]*model.File, error) + MultipleUploadWithPayload func(ctx context.Context, req []*model.UploadFile) ([]*model.File, error) + } + QueryResolver struct { + Empty func(ctx context.Context) (string, error) + } +} + +func (r *Stub) Mutation() MutationResolver { + return &stubMutation{r} +} +func (r *Stub) Query() QueryResolver { + return &stubQuery{r} +} + +type stubMutation struct{ *Stub } + +func (r *stubMutation) SingleUpload(ctx context.Context, file graphql.Upload) (*model.File, error) { + return r.MutationResolver.SingleUpload(ctx, file) +} +func (r *stubMutation) SingleUploadWithPayload(ctx context.Context, req model.UploadFile) (*model.File, error) { + return r.MutationResolver.SingleUploadWithPayload(ctx, req) +} +func (r *stubMutation) MultipleUpload(ctx context.Context, files []*graphql.Upload) ([]*model.File, error) { + return r.MutationResolver.MultipleUpload(ctx, files) +} +func (r *stubMutation) MultipleUploadWithPayload(ctx context.Context, req []*model.UploadFile) ([]*model.File, error) { + return r.MutationResolver.MultipleUploadWithPayload(ctx, req) +} + +type stubQuery struct{ *Stub } + +func (r *stubQuery) Empty(ctx context.Context) (string, error) { + return r.QueryResolver.Empty(ctx) +} diff --git a/_examples/fileupload/testfiles/a.txt b/_examples/fileupload/testfiles/a.txt new file mode 100644 index 0000000..96ff019 --- /dev/null +++ b/_examples/fileupload/testfiles/a.txt @@ -0,0 +1 @@ +Alpha file content diff --git a/_examples/fileupload/testfiles/b.txt b/_examples/fileupload/testfiles/b.txt new file mode 100644 index 0000000..32b94fd --- /dev/null +++ b/_examples/fileupload/testfiles/b.txt @@ -0,0 +1 @@ +Bravo file content diff --git a/_examples/fileupload/testfiles/c.txt b/_examples/fileupload/testfiles/c.txt new file mode 100644 index 0000000..cfec6a4 --- /dev/null +++ b/_examples/fileupload/testfiles/c.txt @@ -0,0 +1 @@ +Charlie file content diff --git a/_examples/go.mod b/_examples/go.mod new file mode 100644 index 0000000..8da7aa7 --- /dev/null +++ b/_examples/go.mod @@ -0,0 +1,36 @@ +module github.com/niko0xdev/gqlgen/_examples + +go 1.18 + +replace github.com/niko0xdev/gqlgen => ../ + +require ( + github.com/niko0xdev/gqlgen v0.17.36 + github.com/google/uuid v1.3.0 + github.com/gorilla/websocket v1.5.0 + github.com/mitchellh/mapstructure v1.5.0 + github.com/rs/cors v1.9.0 + github.com/stretchr/testify v1.8.2 + github.com/vektah/dataloaden v0.3.0 + github.com/vektah/gqlparser/v2 v2.5.10 +) + +require ( + github.com/agnivade/levenshtein v1.1.1 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/hashicorp/golang-lru/v2 v2.0.3 // indirect + github.com/logrusorgru/aurora/v3 v3.0.0 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/sosodev/duration v1.1.0 // indirect + golang.org/x/mod v0.10.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/tools v0.9.3 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) + +require ( + github.com/pkg/errors v0.9.1 // indirect + golang.org/x/text v0.13.0 +) diff --git a/_examples/go.sum b/_examples/go.sum new file mode 100644 index 0000000..8b1873f --- /dev/null +++ b/_examples/go.sum @@ -0,0 +1,73 @@ +github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM= +github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8= +github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo= +github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= +github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c= +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/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/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/hashicorp/golang-lru/v2 v2.0.3 h1:kmRrRLlInXvng0SmLxmQpQkpbYAvcXm7NPDrgxJa9mE= +github.com/hashicorp/golang-lru/v2 v2.0.3/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= +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/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +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.9.0 h1:l9HGsTsHJcvW14Nk7J9KFz8bzeAWXn3CG6bgt7LsrAE= +github.com/rs/cors v1.9.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= +github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= +github.com/sosodev/duration v1.1.0 h1:kQcaiGbJaIsRqgQy7VGlZrVw1giWO+lDoX3MCPnpVO4= +github.com/sosodev/duration v1.1.0/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +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.5.10 h1:6zSM4azXC9u4Nxy5YmdmGu4uKamfwsdKTwp5zsEealU= +github.com/vektah/gqlparser/v2 v2.5.10/go.mod h1:1rCcfwB2ekJofmluGWXMSEnPMZgbxzwj6FaZ/4OT8Cc= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= +golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.9.3 h1:Gn1I8+64MsuTb/HpH+LmQtNas23LhUVr3rYZ0eKuaMM= +golang.org/x/tools v0.9.3/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/_examples/lint.txt b/_examples/lint.txt new file mode 100644 index 0000000..00583d0 --- /dev/null +++ b/_examples/lint.txt @@ -0,0 +1,103 @@ +chat/chat_test.go:28:19: Error return value is not checked (errcheck) +chat/resolvers.go:65:1: paramTypeCombine: func(ctx context.Context, text string, username string, roomName string) (*Message, error) could be replaced with func(ctx context.Context, text, username, roomName string) (*Message, error) (gocritic) +chat/resolvers.go:65:33: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +chat/resolvers.go:77:15: Error return value is not checked (errcheck) +chat/resolvers.go:96:30: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +chat/resolvers.go:133:22: G404: Use of weak random number generator (math/rand instead of crypto/rand) (gosec) +chat/server/server.go:49:12: G114: Use of net/http serve function that has no support for setting timeouts (gosec) +chat/server/server.go:59:2: importShadow: shadow of imported package 'url' (gocritic) +chat/server/server.go:71:13: G114: Use of net/http serve function that has no support for setting timeouts (gosec) +config/server/server.go:17:12: G114: Use of net/http serve function that has no support for setting timeouts (gosec) +dataloader/dataloaders.go:27:1: whyNoLint: include an explanation for nolint directive (gocritic) +dataloader/dataloaders.go:27:1: directive `// nolint: gosec` should be written without leading space as `//nolint: gosec` (nolintlint) +dataloader/dataloaders.go:40:9: var-naming: var keySql should be keySQL (revive) +dataloader/dataloaders.go:40:9: ST1003: var keySql should be keySQL (stylecheck) +dataloader/dataloaders.go:62:9: ST1003: var keySql should be keySQL (stylecheck) +dataloader/dataloaders.go:62:9: var-naming: var keySql should be keySQL (revive) +dataloader/dataloaders.go:92:9: var-naming: var keySql should be keySQL (revive) +dataloader/dataloaders.go:92:9: ST1003: var keySql should be keySQL (stylecheck) +dataloader/resolvers.go:56:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +dataloader/resolvers.go:68:1: whyNoLint: include an explanation for nolint directive (gocritic) +dataloader/resolvers.go:69:1: directive `// nolint: gosec` should be written without leading space as `//nolint: gosec` (nolintlint) +dataloader/resolvers.go:70:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +dataloader/resolvers.go:78:1: whyNoLint: include an explanation for nolint directive (gocritic) +dataloader/resolvers.go:79:1: directive `// nolint: gosec` should be written without leading space as `//nolint: gosec` (nolintlint) +dataloader/resolvers.go:80:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +dataloader/server/server.go:21:12: G114: Use of net/http serve function that has no support for setting timeouts (gosec) +embedding/subdir/resolvers.go:16: File is not `gofumpt`-ed (gofumpt) +embedding/subdir/resolvers.go:17:32: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +embedding/subdir/resolvers.go:19: File is not `gofumpt`-ed (gofumpt) +embedding/subdir/resolvers.go:20:30: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +embedding/subdir/resolvers.go:22: File is not `gofumpt`-ed (gofumpt) +embedding/subdir/resolvers.go:23:27: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +federation/accounts/server.go:30:12: G114: Use of net/http serve function that has no support for setting timeouts (gosec) +federation/products/server.go:30:12: G114: Use of net/http serve function that has no support for setting timeouts (gosec) +federation/reviews/server.go:30:12: G114: Use of net/http serve function that has no support for setting timeouts (gosec) +fileupload/fileupload_test.go:25:12: Error return value of `os.CreateTemp` is not checked (errcheck) +fileupload/fileupload_test.go:27:22: Error return value of `aTxtFile.WriteString` is not checked (errcheck) +fileupload/fileupload_test.go:29:13: Error return value of `os.CreateTemp` is not checked (errcheck) +fileupload/fileupload_test.go:30:13: Error return value of `os.CreateTemp` is not checked (errcheck) +fileupload/fileupload_test.go:33:23: Error return value of `a1TxtFile.WriteString` is not checked (errcheck) +fileupload/fileupload_test.go:34:23: Error return value of `b1TxtFile.WriteString` is not checked (errcheck) +fileupload/fileupload_test.go:230:10: comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint) +fileupload/server/server.go:37:12: G114: Use of net/http serve function that has no support for setting timeouts (gosec) +go.mod:5:1: local replacement are not allowed: github.com/niko0xdev/gqlgen (gomoddirectives) +scalars/model/model.go:19:10: Error return value of `w.Write` is not checked (errcheck) +scalars/model/model.go:21:10: Error return value of `w.Write` is not checked (errcheck) +scalars/model/model.go:28:8: equalFold: consider replacing with strings.EqualFold(v, "true") (gocritic) +scalars/model/model.go:50:52: Comment should end in a period (godot) +scalars/model/model.go:78:57: Comment should end in a period (godot) +scalars/model/model.go:87:17: Error return value of `io.WriteString` is not checked (errcheck) +scalars/model/model.go:92:72: Comment should end in a period (godot) +scalars/model/model.go:100:72: Comment should end in a period (godot) +scalars/model/model.go:103:17: Error return value of `io.WriteString` is not checked (errcheck) +scalars/model/model.go:107:36: Comment should end in a period (godot) +scalars/model/model.go:123:106: Comment should end in a period (godot) +scalars/resolvers.go:26:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +scalars/resolvers.go:26:57: unused-parameter: parameter 'tier' seems to be unused, consider removing or renaming it as _ (revive) +scalars/resolvers.go:26:74: unused-parameter: parameter 'darkMode' seems to be unused, consider removing or renaming it as _ (revive) +scalars/resolvers.go:30:30: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +scalars/resolvers.go:40:32: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +scalars/resolvers.go:71:42: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +scalars/resolvers.go:71:63: unused-parameter: parameter 'obj' seems to be unused, consider removing or renaming it as _ (revive) +scalars/resolvers.go:75:39: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +scalars/resolvers.go:75:60: unused-parameter: parameter 'obj' seems to be unused, consider removing or renaming it as _ (revive) +scalars/server/server.go:16:12: G114: Use of net/http serve function that has no support for setting timeouts (gosec) +selection/server/server.go:15:12: G114: Use of net/http serve function that has no support for setting timeouts (gosec) +starwars/benchmarks_test.go:18:27: "POST" can be replaced by http.MethodPost (usestdlibvars) +starwars/resolvers.go:149:41: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +starwars/resolvers.go:158:30: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +starwars/resolvers.go:165:33: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +starwars/resolvers.go:179:32: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +starwars/resolvers.go:199:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +starwars/resolvers.go:209:31: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +starwars/resolvers.go:213:2: return both the `nil` error and invalid value: use a sentinel error instead (nilnil) +starwars/resolvers.go:216:31: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +starwars/resolvers.go:220:2: return both the `nil` error and invalid value: use a sentinel error instead (nilnil) +starwars/resolvers.go:223:34: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +starwars/resolvers.go:227:2: return both the `nil` error and invalid value: use a sentinel error instead (nilnil) +starwars/resolvers.go:232:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +starwars/server/server.go:29:12: G114: Use of net/http serve function that has no support for setting timeouts (gosec) +starwars/starwars_test.go:30:21: json(snake): got '__typename' want 'typename' (tagliatelle) +todo/server/server.go:26:12: G114: Use of net/http serve function that has no support for setting timeouts (gosec) +todo/todo.go:22:6: var-naming: func getUserId should be getUserID (revive) +todo/todo.go:22:6: ST1003: func getUserId should be getUserID (stylecheck) +todo/todo.go:45:4: return both the `nil` error and invalid value: use a sentinel error instead (nilnil) +todo/todo.go:80:30: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +todo/todo.go:95:34: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +todo/todo.go:102:31: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +todo/todo.go:108:39: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +todo/todo.go:126:39: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +todo/todo.go:137:3: return both the `nil` error and invalid value: use a sentinel error instead (nilnil) +todo/todo_test.go:39:21: json(snake): got '__typename' want 'typename' (tagliatelle) +todo/todo_test.go:208:21: json(snake): got '__typename' want 'typename' (tagliatelle) +todo/todo_test.go:223:21: json(snake): got '__typename' want 'typename' (tagliatelle) +type-system-extension/directive.go:1:1: ST1003: should not use underscores in package names (stylecheck) +type-system-extension/directive.go:1:9: var-naming: don't use an underscore in package name (revive) +type-system-extension/resolver.go:3:1: ST1003: should not use underscores in package names (stylecheck) +type-system-extension/resolver.go:3:9: var-naming: don't use an underscore in package name (revive) +type-system-extension/resolver.go:49:31: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +type-system-extension/resolver.go:53:30: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +type-system-extension/resolver.go:59:2: return both the `nil` error and invalid value: use a sentinel error instead (nilnil) +type-system-extension/resolver.go:64:39: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) +type-system-extension/server/server.go:40:12: G114: Use of net/http serve function that has no support for setting timeouts (gosec) diff --git a/_examples/readme.md b/_examples/readme.md new file mode 100644 index 0000000..6f92518 --- /dev/null +++ b/_examples/readme.md @@ -0,0 +1,5 @@ +### examples + + - todo: A simple todo checklist. A good place to get the basics down + - starwars: A starwars movie database. It has examples of advanced graphql features + - dataloader: How to avoid n+1 database query problems diff --git a/_examples/scalars/.gqlgen.yml b/_examples/scalars/.gqlgen.yml new file mode 100644 index 0000000..c11d9b7 --- /dev/null +++ b/_examples/scalars/.gqlgen.yml @@ -0,0 +1,20 @@ +model: + filename: model/generated.go + +models: + User: + model: github.com/niko0xdev/gqlgen/_examples/scalars/model.User + Timestamp: + model: github.com/niko0xdev/gqlgen/_examples/scalars/model.Timestamp + SearchArgs: + model: github.com/niko0xdev/gqlgen/_examples/scalars/model.SearchArgs + Point: + model: github.com/niko0xdev/gqlgen/_examples/scalars/model.Point + ID: + model: github.com/niko0xdev/gqlgen/_examples/scalars/model.ID + Tier: + model: github.com/niko0xdev/gqlgen/_examples/scalars/model.Tier + Banned: + model: github.com/niko0xdev/gqlgen/_examples/scalars/model.Banned + DarkMode: + model: github.com/niko0xdev/gqlgen/_examples/scalars/model.Preferences diff --git a/_examples/scalars/external/model.go b/_examples/scalars/external/model.go new file mode 100644 index 0000000..88875d9 --- /dev/null +++ b/_examples/scalars/external/model.go @@ -0,0 +1,3 @@ +package external + +type ObjectID int diff --git a/_examples/scalars/generated.go b/_examples/scalars/generated.go new file mode 100644 index 0000000..944a95b --- /dev/null +++ b/_examples/scalars/generated.go @@ -0,0 +1,4576 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package scalars + +import ( + "bytes" + "context" + "embed" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + "time" + + "github.com/niko0xdev/gqlgen/_examples/scalars/external" + "github.com/niko0xdev/gqlgen/_examples/scalars/model" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Query() QueryResolver + User() UserResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + Address struct { + ID func(childComplexity int) int + Location func(childComplexity int) int + } + + Query struct { + Search func(childComplexity int, input *model.SearchArgs) int + User func(childComplexity int, id external.ObjectID) int + UserByTier func(childComplexity int, tier model.Tier, darkMode *model.Prefs) int + } + + User struct { + Address func(childComplexity int) int + Created func(childComplexity int) int + CustomResolver func(childComplexity int) int + ID func(childComplexity int) int + IsBanned func(childComplexity int) int + Modified func(childComplexity int) int + Name func(childComplexity int) int + PrimitiveResolver func(childComplexity int) int + PtrPrefs func(childComplexity int) int + Tier func(childComplexity int) int + ValPrefs func(childComplexity int) int + } +} + +type QueryResolver interface { + User(ctx context.Context, id external.ObjectID) (*model.User, error) + Search(ctx context.Context, input *model.SearchArgs) ([]*model.User, error) + UserByTier(ctx context.Context, tier model.Tier, darkMode *model.Prefs) ([]*model.User, error) +} +type UserResolver interface { + PrimitiveResolver(ctx context.Context, obj *model.User) (string, error) + CustomResolver(ctx context.Context, obj *model.User) (*model.Point, error) +} + +type executableSchema struct { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = ec + switch typeName + "." + field { + + case "Address.id": + if e.complexity.Address.ID == nil { + break + } + + return e.complexity.Address.ID(childComplexity), true + + case "Address.location": + if e.complexity.Address.Location == nil { + break + } + + return e.complexity.Address.Location(childComplexity), true + + case "Query.search": + if e.complexity.Query.Search == nil { + break + } + + args, err := ec.field_Query_search_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Search(childComplexity, args["input"].(*model.SearchArgs)), 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"].(external.ObjectID)), true + + case "Query.userByTier": + if e.complexity.Query.UserByTier == nil { + break + } + + args, err := ec.field_Query_userByTier_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.UserByTier(childComplexity, args["tier"].(model.Tier), args["darkMode"].(*model.Prefs)), true + + case "User.address": + if e.complexity.User.Address == nil { + break + } + + return e.complexity.User.Address(childComplexity), true + + case "User.created": + if e.complexity.User.Created == nil { + break + } + + return e.complexity.User.Created(childComplexity), true + + case "User.customResolver": + if e.complexity.User.CustomResolver == nil { + break + } + + return e.complexity.User.CustomResolver(childComplexity), true + + case "User.id": + if e.complexity.User.ID == nil { + break + } + + return e.complexity.User.ID(childComplexity), true + + case "User.isBanned": + if e.complexity.User.IsBanned == nil { + break + } + + return e.complexity.User.IsBanned(childComplexity), true + + case "User.modified": + if e.complexity.User.Modified == nil { + break + } + + return e.complexity.User.Modified(childComplexity), true + + case "User.name": + if e.complexity.User.Name == nil { + break + } + + return e.complexity.User.Name(childComplexity), true + + case "User.primitiveResolver": + if e.complexity.User.PrimitiveResolver == nil { + break + } + + return e.complexity.User.PrimitiveResolver(childComplexity), true + + case "User.ptrPrefs": + if e.complexity.User.PtrPrefs == nil { + break + } + + return e.complexity.User.PtrPrefs(childComplexity), true + + case "User.tier": + if e.complexity.User.Tier == nil { + break + } + + return e.complexity.User.Tier(childComplexity), true + + case "User.valPrefs": + if e.complexity.User.ValPrefs == nil { + break + } + + return e.complexity.User.ValPrefs(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap( + ec.unmarshalInputSearchArgs, + ) + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } +} + +type executionContext struct { + *graphql.OperationContext + *executableSchema + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + +//go:embed "schema.graphql" +var sourcesFS embed.FS + +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) +} + +var sources = []*ast.Source{ + {Name: "schema.graphql", Input: sourceData("schema.graphql"), BuiltIn: false}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// 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_search_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 *model.SearchArgs + if tmp, ok := rawArgs["input"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) + arg0, err = ec.unmarshalOSearchArgs2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐSearchArgs(ctx, tmp) + if err != nil { + return nil, err + } + } + args["input"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_userByTier_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.Tier + if tmp, ok := rawArgs["tier"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tier")) + arg0, err = ec.unmarshalNTier2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐTier(ctx, tmp) + if err != nil { + return nil, err + } + } + args["tier"] = arg0 + var arg1 *model.Prefs + if tmp, ok := rawArgs["darkMode"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("darkMode")) + arg1, err = ec.unmarshalNDarkMode2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPrefs(ctx, tmp) + if err != nil { + return nil, err + } + } + args["darkMode"] = arg1 + 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 external.ObjectID + if tmp, ok := rawArgs["id"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + arg0, err = ec.unmarshalNID2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋexternalᚐObjectID(ctx, tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil +} + +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) _Address_id(ctx context.Context, field graphql.CollectedField, obj *model.Address) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Address_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.(external.ObjectID) + fc.Result = res + return ec.marshalNID2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋexternalᚐObjectID(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Address_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Address", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Address_location(ctx context.Context, field graphql.CollectedField, obj *model.Address) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Address_location(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Location, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.Point) + fc.Result = res + return ec.marshalOPoint2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPoint(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Address_location(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Address", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Point does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_user(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().User(rctx, fc.Args["id"].(external.ObjectID)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.User) + fc.Result = res + return ec.marshalOUser2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "created": + return ec.fieldContext_User_created(ctx, field) + case "modified": + return ec.fieldContext_User_modified(ctx, field) + case "valPrefs": + return ec.fieldContext_User_valPrefs(ctx, field) + case "ptrPrefs": + return ec.fieldContext_User_ptrPrefs(ctx, field) + case "isBanned": + return ec.fieldContext_User_isBanned(ctx, field) + case "primitiveResolver": + return ec.fieldContext_User_primitiveResolver(ctx, field) + case "customResolver": + return ec.fieldContext_User_customResolver(ctx, field) + case "address": + return ec.fieldContext_User_address(ctx, field) + case "tier": + return ec.fieldContext_User_tier(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_user_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_search(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Search(rctx, fc.Args["input"].(*model.SearchArgs)) + }) + 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.User) + fc.Result = res + return ec.marshalNUser2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐUserᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_search(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "created": + return ec.fieldContext_User_created(ctx, field) + case "modified": + return ec.fieldContext_User_modified(ctx, field) + case "valPrefs": + return ec.fieldContext_User_valPrefs(ctx, field) + case "ptrPrefs": + return ec.fieldContext_User_ptrPrefs(ctx, field) + case "isBanned": + return ec.fieldContext_User_isBanned(ctx, field) + case "primitiveResolver": + return ec.fieldContext_User_primitiveResolver(ctx, field) + case "customResolver": + return ec.fieldContext_User_customResolver(ctx, field) + case "address": + return ec.fieldContext_User_address(ctx, field) + case "tier": + return ec.fieldContext_User_tier(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_search_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_userByTier(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_userByTier(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().UserByTier(rctx, fc.Args["tier"].(model.Tier), fc.Args["darkMode"].(*model.Prefs)) + }) + 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.User) + fc.Result = res + return ec.marshalNUser2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐUserᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_userByTier(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "created": + return ec.fieldContext_User_created(ctx, field) + case "modified": + return ec.fieldContext_User_modified(ctx, field) + case "valPrefs": + return ec.fieldContext_User_valPrefs(ctx, field) + case "ptrPrefs": + return ec.fieldContext_User_ptrPrefs(ctx, field) + case "isBanned": + return ec.fieldContext_User_isBanned(ctx, field) + case "primitiveResolver": + return ec.fieldContext_User_primitiveResolver(ctx, field) + case "customResolver": + return ec.fieldContext_User_customResolver(ctx, field) + case "address": + return ec.fieldContext_User_address(ctx, field) + case "tier": + return ec.fieldContext_User_tier(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_userByTier_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.(external.ObjectID) + fc.Result = res + return ec.marshalNID2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋexternalᚐObjectID(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_User_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_created(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_created(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Created, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(time.Time) + fc.Result = res + return ec.marshalOTimestamp2timeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_created(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Timestamp does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_modified(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_modified(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Modified, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*time.Time) + fc.Result = res + return ec.marshalOTimestamp2ᚖtimeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_modified(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Timestamp does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_valPrefs(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_valPrefs(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ValPrefs, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(model.Prefs) + fc.Result = res + return ec.marshalODarkMode2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPrefs(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_valPrefs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type DarkMode does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_ptrPrefs(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_ptrPrefs(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PtrPrefs, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.Prefs) + fc.Result = res + return ec.marshalODarkMode2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPrefs(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_ptrPrefs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type DarkMode does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_isBanned(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_isBanned(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsBanned, 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.Banned) + fc.Result = res + return ec.marshalNBanned2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐBanned(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_isBanned(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Banned does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_primitiveResolver(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_primitiveResolver(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.User().PrimitiveResolver(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) +} + +func (ec *executionContext) fieldContext_User_primitiveResolver(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_customResolver(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_customResolver(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.User().CustomResolver(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.(*model.Point) + fc.Result = res + return ec.marshalNPoint2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPoint(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_customResolver(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Point does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_address(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_address(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Address, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(model.Address) + fc.Result = res + return ec.marshalOAddress2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐAddress(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_address(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Address_id(ctx, field) + case "location": + return ec.fieldContext_Address_location(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Address", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _User_tier(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_tier(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Tier, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(model.Tier) + fc.Result = res + return ec.marshalOTier2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐTier(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_tier(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Tier does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), 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.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), 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.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), 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.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputSearchArgs(ctx context.Context, obj interface{}) (model.SearchArgs, error) { + var it model.SearchArgs + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"location", "createdAfter", "isBanned"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "location": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("location")) + data, err := ec.unmarshalOPoint2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPoint(ctx, v) + if err != nil { + return it, err + } + it.Location = data + case "createdAfter": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAfter")) + data, err := ec.unmarshalOTimestamp2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAfter = data + case "isBanned": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("isBanned")) + data, err := ec.unmarshalOBanned2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐBanned(ctx, v) + if err != nil { + return it, err + } + it.IsBanned = data + } + } + + return it, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Address") + case "id": + out.Values[i] = ec._Address_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "location": + out.Values[i] = ec._Address_location(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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 + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_user(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "search": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_search(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "userByTier": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_userByTier(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("User") + case "id": + out.Values[i] = ec._User_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "name": + out.Values[i] = ec._User_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "created": + out.Values[i] = ec._User_created(ctx, field, obj) + case "modified": + out.Values[i] = ec._User_modified(ctx, field, obj) + case "valPrefs": + out.Values[i] = ec._User_valPrefs(ctx, field, obj) + case "ptrPrefs": + out.Values[i] = ec._User_ptrPrefs(ctx, field, obj) + case "isBanned": + out.Values[i] = ec._User_isBanned(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "primitiveResolver": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._User_primitiveResolver(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "customResolver": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._User_customResolver(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "address": + out.Values[i] = ec._User_address(ctx, field, obj) + case "tier": + out.Values[i] = ec._User_tier(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) unmarshalNBanned2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐBanned(ctx context.Context, v interface{}) (model.Banned, error) { + var res model.Banned + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNBanned2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐBanned(ctx context.Context, sel ast.SelectionSet, v model.Banned) graphql.Marshaler { + return v +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNDarkMode2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPrefs(ctx context.Context, v interface{}) (*model.Prefs, error) { + res, err := model.UnmarshalPreferences(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNDarkMode2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPrefs(ctx context.Context, sel ast.SelectionSet, v *model.Prefs) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + res := model.MarshalPreferences(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNID2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋexternalᚐObjectID(ctx context.Context, v interface{}) (external.ObjectID, error) { + res, err := model.UnmarshalID(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNID2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋexternalᚐObjectID(ctx context.Context, sel ast.SelectionSet, v external.ObjectID) graphql.Marshaler { + res := model.MarshalID(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNPoint2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPoint(ctx context.Context, v interface{}) (model.Point, error) { + var res model.Point + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNPoint2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPoint(ctx context.Context, sel ast.SelectionSet, v model.Point) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalNPoint2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPoint(ctx context.Context, v interface{}) (*model.Point, error) { + var res = new(model.Point) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNPoint2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPoint(ctx context.Context, sel ast.SelectionSet, v *model.Point) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return v +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNTier2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐTier(ctx context.Context, v interface{}) (model.Tier, error) { + var res model.Tier + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNTier2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐTier(ctx context.Context, sel ast.SelectionSet, v model.Tier) graphql.Marshaler { + return v +} + +func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐUserᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.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ᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐ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ᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._User(ctx, sel, v) +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalOAddress2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐAddress(ctx context.Context, sel ast.SelectionSet, v model.Address) graphql.Marshaler { + return ec._Address(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalOBanned2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐBanned(ctx context.Context, v interface{}) (model.Banned, error) { + var res model.Banned + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOBanned2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐBanned(ctx context.Context, sel ast.SelectionSet, v model.Banned) graphql.Marshaler { + return 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 { + 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) unmarshalODarkMode2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPrefs(ctx context.Context, v interface{}) (model.Prefs, error) { + res, err := model.UnmarshalPreferences(v) + return *res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalODarkMode2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPrefs(ctx context.Context, sel ast.SelectionSet, v model.Prefs) graphql.Marshaler { + res := model.MarshalPreferences(&v) + return res +} + +func (ec *executionContext) unmarshalODarkMode2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPrefs(ctx context.Context, v interface{}) (*model.Prefs, error) { + if v == nil { + return nil, nil + } + res, err := model.UnmarshalPreferences(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalODarkMode2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPrefs(ctx context.Context, sel ast.SelectionSet, v *model.Prefs) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := model.MarshalPreferences(v) + return res +} + +func (ec *executionContext) unmarshalOPoint2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPoint(ctx context.Context, v interface{}) (*model.Point, error) { + if v == nil { + return nil, nil + } + var res = new(model.Point) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOPoint2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPoint(ctx context.Context, sel ast.SelectionSet, v *model.Point) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalOSearchArgs2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐSearchArgs(ctx context.Context, v interface{}) (*model.SearchArgs, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputSearchArgs(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +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) unmarshalOTier2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐTier(ctx context.Context, v interface{}) (model.Tier, error) { + var res model.Tier + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOTier2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐTier(ctx context.Context, sel ast.SelectionSet, v model.Tier) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalOTimestamp2timeᚐTime(ctx context.Context, v interface{}) (time.Time, error) { + res, err := model.UnmarshalTimestamp(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOTimestamp2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { + res := model.MarshalTimestamp(v) + return res +} + +func (ec *executionContext) unmarshalOTimestamp2ᚖtimeᚐTime(ctx context.Context, v interface{}) (*time.Time, error) { + if v == nil { + return nil, nil + } + res, err := model.UnmarshalTimestamp(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOTimestamp2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := model.MarshalTimestamp(*v) + return res +} + +func (ec *executionContext) marshalOUser2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._User(ctx, sel, v) +} + +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/_examples/scalars/model/generated.go b/_examples/scalars/model/generated.go new file mode 100644 index 0000000..1bd0ef7 --- /dev/null +++ b/_examples/scalars/model/generated.go @@ -0,0 +1,15 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package model + +import ( + "github.com/niko0xdev/gqlgen/_examples/scalars/external" +) + +type Address struct { + ID external.ObjectID `json:"id"` + Location *Point `json:"location,omitempty"` +} + +type Query struct { +} diff --git a/_examples/scalars/model/model.go b/_examples/scalars/model/model.go new file mode 100644 index 0000000..dec5afb --- /dev/null +++ b/_examples/scalars/model/model.go @@ -0,0 +1,195 @@ +package model + +import ( + "errors" + "fmt" + "io" + "strconv" + "strings" + "time" + + "github.com/niko0xdev/gqlgen/_examples/scalars/external" + "github.com/niko0xdev/gqlgen/graphql" +) + +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) + } +} + +type User struct { + ID external.ObjectID + Name string + Created time.Time // direct binding to builtin types with external Marshal/Unmarshal methods + Modified *time.Time // direct binding to builtin types with external Marshal/Unmarshal methods + ValPrefs Prefs // external un/marshal that act on pointers + PtrPrefs *Prefs + IsBanned Banned + Address Address + Tier Tier +} + +// Point is serialized as a simple array, eg [1, 2] +type Point struct { + X int + Y int +} + +func (p *Point) UnmarshalGQL(v interface{}) error { + pointStr, ok := v.(string) + if !ok { + return fmt.Errorf("points must be strings") + } + + parts := strings.Split(pointStr, ",") + + if len(parts) != 2 { + return fmt.Errorf("points must have 2 parts") + } + + var err error + if p.X, err = strconv.Atoi(parts[0]); err != nil { + return err + } + if p.Y, err = strconv.Atoi(parts[1]); err != nil { + return err + } + return nil +} + +// MarshalGQL implements the graphql.Marshaler interface +func (p Point) MarshalGQL(w io.Writer) { + fmt.Fprintf(w, `"%d,%d"`, p.X, p.Y) +} + +// if the type referenced in .gqlgen.yml is a function that returns a marshaller we can use it to encode and decode +// onto any existing go type. +func MarshalTimestamp(t time.Time) graphql.Marshaler { + return graphql.WriterFunc(func(w io.Writer) { + io.WriteString(w, strconv.FormatInt(t.Unix(), 10)) + }) +} + +// Unmarshal{Typename} is only required if the scalar appears as an input. The raw values have already been decoded +// from json into int/float64/bool/nil/map[string]interface/[]interface +func UnmarshalTimestamp(v interface{}) (time.Time, error) { + if tmpStr, ok := v.(int64); ok { + return time.Unix(tmpStr, 0), nil + } + return time.Time{}, errors.New("time should be a unix timestamp") +} + +// Lets redefine the base ID type to use an id from an external library +func MarshalID(id external.ObjectID) graphql.Marshaler { + return graphql.WriterFunc(func(w io.Writer) { + io.WriteString(w, strconv.Quote(fmt.Sprintf("=%d=", id))) + }) +} + +// And the same for the unmarshaler +func UnmarshalID(v interface{}) (external.ObjectID, error) { + str, ok := v.(string) + if !ok { + return 0, fmt.Errorf("ids must be strings") + } + i, err := strconv.Atoi(str[1 : len(str)-1]) + return external.ObjectID(i), err +} + +type SearchArgs struct { + Location *Point + CreatedAfter *time.Time + IsBanned Banned +} + +// A custom enum that uses integers to represent the values in memory but serialize as string for graphql +type Tier uint + +const ( + TierA Tier = iota + TierB Tier = iota + TierC Tier = iota +) + +func TierForStr(str string) (Tier, error) { + switch str { + case "A": + return TierA, nil + case "B": + return TierB, nil + case "C": + return TierC, nil + default: + return 0, fmt.Errorf("%s is not a valid Tier", str) + } +} + +func (e Tier) IsValid() bool { + switch e { + case TierA, TierB, TierC: + return true + } + return false +} + +func (e Tier) String() string { + switch e { + case TierA: + return "A" + case TierB: + return "B" + case TierC: + return "C" + default: + panic("invalid enum value") + } +} + +func (e *Tier) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + var err error + *e, err = TierForStr(str) + return err +} + +func (e Tier) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +type Prefs struct { + DarkMode bool +} + +func MarshalPreferences(p *Prefs) graphql.Marshaler { + return graphql.MarshalBoolean(p.DarkMode) +} + +func UnmarshalPreferences(v interface{}) (*Prefs, error) { + tmp, err := graphql.UnmarshalBoolean(v) + if err != nil { + return nil, err + } + return &Prefs{DarkMode: tmp}, nil +} diff --git a/_examples/scalars/resolvers.go b/_examples/scalars/resolvers.go new file mode 100644 index 0000000..86f0608 --- /dev/null +++ b/_examples/scalars/resolvers.go @@ -0,0 +1,77 @@ +//go:generate go run ../../testdata/gqlgen.go + +package scalars + +import ( + "context" + "fmt" + "time" + + "github.com/niko0xdev/gqlgen/_examples/scalars/external" + "github.com/niko0xdev/gqlgen/_examples/scalars/model" +) + +type Resolver struct{} + +func (r *Resolver) Query() QueryResolver { + return &queryResolver{r} +} + +func (r *Resolver) User() UserResolver { + return &userResolver{r} +} + +type queryResolver struct{ *Resolver } + +func (r *queryResolver) UserByTier(ctx context.Context, tier model.Tier, darkMode *model.Prefs) ([]*model.User, error) { + panic("implement me") +} + +func (r *queryResolver) User(ctx context.Context, id external.ObjectID) (*model.User, error) { + return &model.User{ + ID: id, + Name: fmt.Sprintf("Test User %d", id), + Created: time.Now(), + Address: model.Address{ID: 1, Location: &model.Point{X: 1, Y: 2}}, + Tier: model.TierC, + }, nil +} + +func (r *queryResolver) Search(ctx context.Context, input *model.SearchArgs) ([]*model.User, error) { + location := model.Point{X: 1, Y: 2} + if input.Location != nil { + location = *input.Location + } + + created := time.Now() + if input.CreatedAfter != nil { + created = *input.CreatedAfter + } + + return []*model.User{ + { + ID: 1, + Name: "Test User 1", + Created: created, + Address: model.Address{ID: 2, Location: &location}, + Tier: model.TierA, + }, + { + ID: 2, + Name: "Test User 2", + Created: created, + Address: model.Address{ID: 1, Location: &location}, + Tier: model.TierC, + }, + }, nil +} + +type userResolver struct{ *Resolver } + +func (r *userResolver) PrimitiveResolver(ctx context.Context, obj *model.User) (string, error) { + return "test", nil +} + +func (r *userResolver) CustomResolver(ctx context.Context, obj *model.User) (*model.Point, error) { + return &model.Point{X: 5, Y: 1}, nil +} diff --git a/_examples/scalars/scalar_test.go b/_examples/scalars/scalar_test.go new file mode 100644 index 0000000..2e6384e --- /dev/null +++ b/_examples/scalars/scalar_test.go @@ -0,0 +1,79 @@ +package scalars + +import ( + "testing" + "time" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/introspection" +) + +type RawUser struct { + ID string + Name string + Created int64 + Address struct{ Location string } + PrimitiveResolver string + CustomResolver string + Tier string +} + +func TestScalars(t *testing.T) { + c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: &Resolver{}}))) + + t.Run("marshaling", func(t *testing.T) { + var resp struct { + User RawUser + Search []RawUser + } + c.MustPost(`{ + user(id:"=1=") { + ...UserData + } + search(input:{location:"6,66", createdAfter:666}) { + ...UserData + } + } + fragment UserData on User { id name created tier address { location } }`, &resp) + + require.Equal(t, "1,2", resp.User.Address.Location) + // There can be a delay between creation and test assertion, so we + // give some leeway to eliminate false positives. + require.WithinDuration(t, time.Now(), time.Unix(resp.User.Created, 0), 5*time.Second) + require.Equal(t, "6,66", resp.Search[0].Address.Location) + require.Equal(t, int64(666), resp.Search[0].Created) + require.Equal(t, "A", resp.Search[0].Tier) + }) + + t.Run("default search location", func(t *testing.T) { + var resp struct{ Search []RawUser } + + err := c.Post(`{ search { address { location } } }`, &resp) + require.NoError(t, err) + require.Equal(t, "37,144", resp.Search[0].Address.Location) + }) + + t.Run("custom error messages", func(t *testing.T) { + var resp struct{ Search []RawUser } + + err := c.Post(`{ search(input:{createdAfter:"2014"}) { id } }`, &resp) + require.EqualError(t, err, `[{"message":"time should be a unix timestamp","path":["search","input","createdAfter"]}]`) + }) + + t.Run("scalar resolver methods", func(t *testing.T) { + var resp struct{ User RawUser } + c.MustPost(`{ user(id: "=1=") { primitiveResolver, customResolver } }`, &resp) + + require.Equal(t, "test", resp.User.PrimitiveResolver) + require.Equal(t, "5,1", resp.User.CustomResolver) + }) + + t.Run("introspection", func(t *testing.T) { + // Make sure we can run the graphiql introspection query without errors + var resp interface{} + c.MustPost(introspection.Query, &resp) + }) +} diff --git a/_examples/scalars/schema.graphql b/_examples/scalars/schema.graphql new file mode 100644 index 0000000..fe5c879 --- /dev/null +++ b/_examples/scalars/schema.graphql @@ -0,0 +1,41 @@ +type Query { + user(id: ID!): User + search(input: SearchArgs = {location: "37,144", isBanned: false}): [User!]! + userByTier(tier: Tier!, darkMode: DarkMode!): [User!]! +} + +type User { + id: ID! + name: String! + created: Timestamp + modified: Timestamp + valPrefs: DarkMode + ptrPrefs: DarkMode + isBanned: Banned! + primitiveResolver: String! + customResolver: Point! + address: Address + tier: Tier +} + +type Address { + id: ID! + location: Point +} + +input SearchArgs { + location: Point + createdAfter: Timestamp + isBanned: Banned # TODO: This can be a Boolean again once multiple backing types are allowed +} + +enum Tier { + A + B + C +} + +scalar Timestamp +scalar Point +scalar Banned +scalar DarkMode diff --git a/_examples/scalars/server/server.go b/_examples/scalars/server/server.go new file mode 100644 index 0000000..41d0a86 --- /dev/null +++ b/_examples/scalars/server/server.go @@ -0,0 +1,17 @@ +package main + +import ( + "log" + "net/http" + + "github.com/niko0xdev/gqlgen/_examples/scalars" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/playground" +) + +func main() { + http.Handle("/", playground.Handler("Starwars", "/query")) + http.Handle("/query", handler.NewDefaultServer(scalars.NewExecutableSchema(scalars.Config{Resolvers: &scalars.Resolver{}}))) + + log.Fatal(http.ListenAndServe(":8084", nil)) +} diff --git a/_examples/selection/.gqlgen.yml b/_examples/selection/.gqlgen.yml new file mode 100644 index 0000000..846418d --- /dev/null +++ b/_examples/selection/.gqlgen.yml @@ -0,0 +1,5 @@ +schema: schema.graphql +model: + filename: models_gen.go +exec: + filename: generated.go diff --git a/_examples/selection/generated.go b/_examples/selection/generated.go new file mode 100644 index 0000000..019ea44 --- /dev/null +++ b/_examples/selection/generated.go @@ -0,0 +1,3757 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package selection + +import ( + "bytes" + "context" + "embed" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + "time" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Query() QueryResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + Like struct { + Collected func(childComplexity int) int + Reaction func(childComplexity int) int + Selection func(childComplexity int) int + Sent func(childComplexity int) int + } + + Post struct { + Collected func(childComplexity int) int + Message func(childComplexity int) int + Selection func(childComplexity int) int + Sent func(childComplexity int) int + } + + Query struct { + Events func(childComplexity int) int + } +} + +type QueryResolver interface { + Events(ctx context.Context) ([]Event, error) +} + +type executableSchema struct { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = ec + switch typeName + "." + field { + + case "Like.collected": + if e.complexity.Like.Collected == nil { + break + } + + return e.complexity.Like.Collected(childComplexity), true + + case "Like.reaction": + if e.complexity.Like.Reaction == nil { + break + } + + return e.complexity.Like.Reaction(childComplexity), true + + case "Like.selection": + if e.complexity.Like.Selection == nil { + break + } + + return e.complexity.Like.Selection(childComplexity), true + + case "Like.sent": + if e.complexity.Like.Sent == nil { + break + } + + return e.complexity.Like.Sent(childComplexity), true + + case "Post.collected": + if e.complexity.Post.Collected == nil { + break + } + + return e.complexity.Post.Collected(childComplexity), true + + case "Post.message": + if e.complexity.Post.Message == nil { + break + } + + return e.complexity.Post.Message(childComplexity), true + + case "Post.selection": + if e.complexity.Post.Selection == nil { + break + } + + return e.complexity.Post.Selection(childComplexity), true + + case "Post.sent": + if e.complexity.Post.Sent == nil { + break + } + + return e.complexity.Post.Sent(childComplexity), true + + case "Query.events": + if e.complexity.Query.Events == nil { + break + } + + return e.complexity.Query.Events(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap() + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } +} + +type executionContext struct { + *graphql.OperationContext + *executableSchema + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + +//go:embed "schema.graphql" +var sourcesFS embed.FS + +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) +} + +var sources = []*ast.Source{ + {Name: "schema.graphql", Input: sourceData("schema.graphql"), BuiltIn: false}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// 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___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) _Like_reaction(ctx context.Context, field graphql.CollectedField, obj *Like) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Like_reaction(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Reaction, 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) fieldContext_Like_reaction(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Like", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Like_sent(ctx context.Context, field graphql.CollectedField, obj *Like) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Like_sent(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Sent, 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.(time.Time) + fc.Result = res + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Like_sent(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Like", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Like_selection(ctx context.Context, field graphql.CollectedField, obj *Like) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Like_selection(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Selection, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]string) + fc.Result = res + return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Like_selection(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Like", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Like_collected(ctx context.Context, field graphql.CollectedField, obj *Like) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Like_collected(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Collected, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]string) + fc.Result = res + return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Like_collected(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Like", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Post_message(ctx context.Context, field graphql.CollectedField, obj *Post) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Post_message(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Message, 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) fieldContext_Post_message(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Post", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Post_sent(ctx context.Context, field graphql.CollectedField, obj *Post) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Post_sent(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Sent, 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.(time.Time) + fc.Result = res + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Post_sent(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Post", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Post_selection(ctx context.Context, field graphql.CollectedField, obj *Post) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Post_selection(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Selection, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]string) + fc.Result = res + return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Post_selection(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Post", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Post_collected(ctx context.Context, field graphql.CollectedField, obj *Post) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Post_collected(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Collected, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]string) + fc.Result = res + return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Post_collected(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Post", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_events(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_events(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Events(rctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]Event) + fc.Result = res + return ec.marshalOEvent2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋselectionᚐEventᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_events(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), 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.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), 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.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), 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.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +func (ec *executionContext) _Event(ctx context.Context, sel ast.SelectionSet, obj Event) graphql.Marshaler { + switch obj := (obj).(type) { + case nil: + return graphql.Null + case Post: + return ec._Post(ctx, sel, &obj) + case *Post: + if obj == nil { + return graphql.Null + } + return ec._Post(ctx, sel, obj) + case Like: + return ec._Like(ctx, sel, &obj) + case *Like: + if obj == nil { + return graphql.Null + } + return ec._Like(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Like") + case "reaction": + out.Values[i] = ec._Like_reaction(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "sent": + out.Values[i] = ec._Like_sent(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "selection": + out.Values[i] = ec._Like_selection(ctx, field, obj) + case "collected": + out.Values[i] = ec._Like_collected(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Post") + case "message": + out.Values[i] = ec._Post_message(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "sent": + out.Values[i] = ec._Post_sent(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "selection": + out.Values[i] = ec._Post_selection(ctx, field, obj) + case "collected": + out.Values[i] = ec._Post_collected(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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 + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_events(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNEvent2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋselectionᚐEvent(ctx context.Context, sel ast.SelectionSet, v Event) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Event(ctx, sel, v) +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + 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) marshalOEvent2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋselectionᚐEventᚄ(ctx context.Context, sel ast.SelectionSet, v []Event) 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.marshalNEvent2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋselectionᚐEvent(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) unmarshalOString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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 + } + 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) marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/_examples/selection/models_gen.go b/_examples/selection/models_gen.go new file mode 100644 index 0000000..5afdeaa --- /dev/null +++ b/_examples/selection/models_gen.go @@ -0,0 +1,74 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package selection + +import ( + "time" +) + +type Event interface { + IsEvent() + GetSelection() []string + GetCollected() []string +} + +type Like struct { + Reaction string `json:"reaction"` + Sent time.Time `json:"sent"` + Selection []string `json:"selection,omitempty"` + Collected []string `json:"collected,omitempty"` +} + +func (Like) IsEvent() {} +func (this Like) GetSelection() []string { + if this.Selection == nil { + return nil + } + interfaceSlice := make([]string, 0, len(this.Selection)) + for _, concrete := range this.Selection { + interfaceSlice = append(interfaceSlice, concrete) + } + return interfaceSlice +} +func (this Like) GetCollected() []string { + if this.Collected == nil { + return nil + } + interfaceSlice := make([]string, 0, len(this.Collected)) + for _, concrete := range this.Collected { + interfaceSlice = append(interfaceSlice, concrete) + } + return interfaceSlice +} + +type Post struct { + Message string `json:"message"` + Sent time.Time `json:"sent"` + Selection []string `json:"selection,omitempty"` + Collected []string `json:"collected,omitempty"` +} + +func (Post) IsEvent() {} +func (this Post) GetSelection() []string { + if this.Selection == nil { + return nil + } + interfaceSlice := make([]string, 0, len(this.Selection)) + for _, concrete := range this.Selection { + interfaceSlice = append(interfaceSlice, concrete) + } + return interfaceSlice +} +func (this Post) GetCollected() []string { + if this.Collected == nil { + return nil + } + interfaceSlice := make([]string, 0, len(this.Collected)) + for _, concrete := range this.Collected { + interfaceSlice = append(interfaceSlice, concrete) + } + return interfaceSlice +} + +type Query struct { +} diff --git a/_examples/selection/readme.md b/_examples/selection/readme.md new file mode 100644 index 0000000..6380de0 --- /dev/null +++ b/_examples/selection/readme.md @@ -0,0 +1,10 @@ +### selection app + +This is the simplest example of a graphql server. + +to run this server +```bash +go run ./server/server.go +``` + +and open http://localhost:8086 in your browser diff --git a/_examples/selection/schema.graphql b/_examples/selection/schema.graphql new file mode 100644 index 0000000..729a71c --- /dev/null +++ b/_examples/selection/schema.graphql @@ -0,0 +1,24 @@ +interface Event { + selection: [String!] + collected: [String!] +} + +type Post implements Event { + message: String! + sent: Time! + selection: [String!] + collected: [String!] +} + +type Like implements Event { + reaction: String! + sent: Time! + selection: [String!] + collected: [String!] +} + +type Query { + events: [Event!] +} + +scalar Time diff --git a/_examples/selection/selection.go b/_examples/selection/selection.go new file mode 100644 index 0000000..5f643d4 --- /dev/null +++ b/_examples/selection/selection.go @@ -0,0 +1,69 @@ +//go:generate go run ../../testdata/gqlgen.go + +package selection + +import ( + "context" + "fmt" + "time" + + "github.com/vektah/gqlparser/v2/ast" + + "github.com/niko0xdev/gqlgen/graphql" +) + +type Resolver struct{} + +func (r *Resolver) Query() QueryResolver { + return &queryResolver{r} +} + +type queryResolver struct{ *Resolver } + +func (r *queryResolver) Events(ctx context.Context) ([]Event, error) { + var sels []string + + reqCtx := graphql.GetOperationContext(ctx) + fieldSelections := graphql.GetFieldContext(ctx).Field.Selections + for _, sel := range fieldSelections { + switch sel := sel.(type) { + case *ast.Field: + sels = append(sels, fmt.Sprintf("%s as %s", sel.Name, sel.Alias)) + case *ast.InlineFragment: + sels = append(sels, fmt.Sprintf("inline fragment on %s", sel.TypeCondition)) + case *ast.FragmentSpread: + fragment := reqCtx.Doc.Fragments.ForName(sel.Name) + sels = append(sels, fmt.Sprintf("named fragment %s on %s", sel.Name, fragment.TypeCondition)) + } + } + + var events []Event + for i := 0; i < 10; i++ { + if i%2 == 0 { + events = append(events, &Like{ + Selection: sels, + Collected: formatCollected(graphql.CollectFieldsCtx(ctx, []string{"Like"})), + Reaction: ":=)", + Sent: time.Now(), + }) + } else { + events = append(events, &Post{ + Selection: sels, + Collected: formatCollected(graphql.CollectFieldsCtx(ctx, []string{"Post"})), + Message: "Hey", + Sent: time.Now(), + }) + } + } + + return events, nil +} + +func formatCollected(cf []graphql.CollectedField) []string { + res := make([]string, len(cf)) + + for i, f := range cf { + res[i] = f.Name + " as " + f.Alias + } + return res +} diff --git a/_examples/selection/selection_test.go b/_examples/selection/selection_test.go new file mode 100644 index 0000000..3509643 --- /dev/null +++ b/_examples/selection/selection_test.go @@ -0,0 +1,56 @@ +package selection + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +func TestSelection(t *testing.T) { + c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: &Resolver{}}))) + + query := `{ + events { + selection + collected + + ... on Post { + message + sent + } + + ...LikeFragment + } + } + fragment LikeFragment on Like { reaction sent } + ` + + var resp struct { + Events []struct { + Selection []string + Collected []string + + Message string + Reaction string + Sent string + } + } + c.MustPost(query, &resp) + + require.Equal(t, []string{ + "selection as selection", + "collected as collected", + "inline fragment on Post", + "named fragment LikeFragment on Like", + }, resp.Events[0].Selection) + + require.Equal(t, []string{ + "selection as selection", + "collected as collected", + "reaction as reaction", + "sent as sent", + }, resp.Events[0].Collected) +} diff --git a/_examples/selection/server/server.go b/_examples/selection/server/server.go new file mode 100644 index 0000000..ae05ea0 --- /dev/null +++ b/_examples/selection/server/server.go @@ -0,0 +1,16 @@ +package main + +import ( + "log" + "net/http" + + "github.com/niko0xdev/gqlgen/_examples/selection" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/playground" +) + +func main() { + http.Handle("/", playground.Handler("Selection Demo", "/query")) + http.Handle("/query", handler.NewDefaultServer(selection.NewExecutableSchema(selection.Config{Resolvers: &selection.Resolver{}}))) + log.Fatal(http.ListenAndServe(":8086", nil)) +} diff --git a/_examples/starwars/.gqlgen.yml b/_examples/starwars/.gqlgen.yml new file mode 100644 index 0000000..fa30eaa --- /dev/null +++ b/_examples/starwars/.gqlgen.yml @@ -0,0 +1,16 @@ +exec: + filename: generated/exec.go +model: + filename: models/generated.go + package: models + +autobind: + - github.com/niko0xdev/gqlgen/_examples/starwars/models + +models: + ReviewInput: + model: models.Review + Starship: + fields: + length: + resolver: true diff --git a/_examples/starwars/benchmarks_test.go b/_examples/starwars/benchmarks_test.go new file mode 100644 index 0000000..95d1506 --- /dev/null +++ b/_examples/starwars/benchmarks_test.go @@ -0,0 +1,34 @@ +package starwars + +import ( + "net/http/httptest" + "strings" + "testing" + + "github.com/niko0xdev/gqlgen/_examples/starwars/generated" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +func BenchmarkSimpleQueryNoArgs(b *testing.B) { + server := handler.NewDefaultServer(generated.NewExecutableSchema(NewResolver())) + + q := `{"query":"{ search(text:\"Luke\") { ... on Human { starships { name } } } }"}` + + var body strings.Reader + r := httptest.NewRequest("POST", "/graphql", &body) + r.Header.Set("Content-Type", "application/json") + + b.ReportAllocs() + b.ResetTimer() + + rec := httptest.NewRecorder() + for i := 0; i < b.N; i++ { + body.Reset(q) + rec.Body.Reset() + server.ServeHTTP(rec, r) + if rec.Body.String() != `{"data":{"search":[{"starships":[{"name":"X-Wing"},{"name":"Imperial shuttle"}]}]}}` { + b.Fatalf("Unexpected response: %s", rec.Body.String()) + } + + } +} diff --git a/_examples/starwars/generated/exec.go b/_examples/starwars/generated/exec.go new file mode 100644 index 0000000..f7abfe6 --- /dev/null +++ b/_examples/starwars/generated/exec.go @@ -0,0 +1,7328 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package generated + +import ( + "bytes" + "context" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + "time" + + "github.com/niko0xdev/gqlgen/_examples/starwars/models" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Droid() DroidResolver + FriendsConnection() FriendsConnectionResolver + Human() HumanResolver + Mutation() MutationResolver + Query() QueryResolver + Starship() StarshipResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + Droid struct { + AppearsIn func(childComplexity int) int + Friends func(childComplexity int) int + FriendsConnection func(childComplexity int, first *int, after *string) int + ID func(childComplexity int) int + Name func(childComplexity int) int + PrimaryFunction func(childComplexity int) int + } + + FriendsConnection struct { + Edges func(childComplexity int) int + Friends func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + FriendsEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + + Human struct { + AppearsIn func(childComplexity int) int + Friends func(childComplexity int) int + FriendsConnection func(childComplexity int, first *int, after *string) int + Height func(childComplexity int, unit models.LengthUnit) int + ID func(childComplexity int) int + Mass func(childComplexity int) int + Mutation func(childComplexity int) int + Name func(childComplexity int) int + Query func(childComplexity int) int + Starships func(childComplexity int) int + } + + Mutation struct { + CreateReview func(childComplexity int, episode models.Episode, review models.Review) int + } + + PageInfo struct { + EndCursor func(childComplexity int) int + HasNextPage func(childComplexity int) int + StartCursor func(childComplexity int) int + } + + Query struct { + Character func(childComplexity int, id string) int + Droid func(childComplexity int, id string) int + Hero func(childComplexity int, episode *models.Episode) int + Human func(childComplexity int, id string) int + Reviews func(childComplexity int, episode models.Episode, since *time.Time) int + Search func(childComplexity int, text string) int + Starship func(childComplexity int, id string) int + } + + Review struct { + Commentary func(childComplexity int) int + Stars func(childComplexity int) int + Time func(childComplexity int) int + } + + Starship struct { + History func(childComplexity int) int + ID func(childComplexity int) int + Length func(childComplexity int, unit *models.LengthUnit) int + Name func(childComplexity int) int + } +} + +type DroidResolver interface { + Friends(ctx context.Context, obj *models.Droid) ([]models.Character, error) + FriendsConnection(ctx context.Context, obj *models.Droid, first *int, after *string) (*models.FriendsConnection, error) +} +type FriendsConnectionResolver interface { + Edges(ctx context.Context, obj *models.FriendsConnection) ([]*models.FriendsEdge, error) + Friends(ctx context.Context, obj *models.FriendsConnection) ([]models.Character, error) +} +type HumanResolver interface { + Friends(ctx context.Context, obj *models.Human) ([]models.Character, error) + FriendsConnection(ctx context.Context, obj *models.Human, first *int, after *string) (*models.FriendsConnection, error) + + Starships(ctx context.Context, obj *models.Human) ([]*models.Starship, error) +} +type MutationResolver interface { + CreateReview(ctx context.Context, episode models.Episode, review models.Review) (*models.Review, error) +} +type QueryResolver interface { + Hero(ctx context.Context, episode *models.Episode) (models.Character, error) + Reviews(ctx context.Context, episode models.Episode, since *time.Time) ([]*models.Review, error) + Search(ctx context.Context, text string) ([]models.SearchResult, error) + Character(ctx context.Context, id string) (models.Character, error) + Droid(ctx context.Context, id string) (*models.Droid, error) + Human(ctx context.Context, id string) (*models.Human, error) + Starship(ctx context.Context, id string) (*models.Starship, error) +} +type StarshipResolver interface { + Length(ctx context.Context, obj *models.Starship, unit *models.LengthUnit) (float64, error) +} + +type executableSchema struct { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = ec + switch typeName + "." + field { + + case "Droid.appearsIn": + if e.complexity.Droid.AppearsIn == nil { + break + } + + return e.complexity.Droid.AppearsIn(childComplexity), true + + case "Droid.friends": + if e.complexity.Droid.Friends == nil { + break + } + + return e.complexity.Droid.Friends(childComplexity), true + + case "Droid.friendsConnection": + if e.complexity.Droid.FriendsConnection == nil { + break + } + + args, err := ec.field_Droid_friendsConnection_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Droid.FriendsConnection(childComplexity, args["first"].(*int), args["after"].(*string)), true + + case "Droid.id": + if e.complexity.Droid.ID == nil { + break + } + + return e.complexity.Droid.ID(childComplexity), true + + case "Droid.name": + if e.complexity.Droid.Name == nil { + break + } + + return e.complexity.Droid.Name(childComplexity), true + + case "Droid.primaryFunction": + if e.complexity.Droid.PrimaryFunction == nil { + break + } + + return e.complexity.Droid.PrimaryFunction(childComplexity), true + + case "FriendsConnection.edges": + if e.complexity.FriendsConnection.Edges == nil { + break + } + + return e.complexity.FriendsConnection.Edges(childComplexity), true + + case "FriendsConnection.friends": + if e.complexity.FriendsConnection.Friends == nil { + break + } + + return e.complexity.FriendsConnection.Friends(childComplexity), true + + case "FriendsConnection.pageInfo": + if e.complexity.FriendsConnection.PageInfo == nil { + break + } + + return e.complexity.FriendsConnection.PageInfo(childComplexity), true + + case "FriendsConnection.totalCount": + if e.complexity.FriendsConnection.TotalCount == nil { + break + } + + return e.complexity.FriendsConnection.TotalCount(childComplexity), true + + case "FriendsEdge.cursor": + if e.complexity.FriendsEdge.Cursor == nil { + break + } + + return e.complexity.FriendsEdge.Cursor(childComplexity), true + + case "FriendsEdge.node": + if e.complexity.FriendsEdge.Node == nil { + break + } + + return e.complexity.FriendsEdge.Node(childComplexity), true + + case "Human.appearsIn": + if e.complexity.Human.AppearsIn == nil { + break + } + + return e.complexity.Human.AppearsIn(childComplexity), true + + case "Human.friends": + if e.complexity.Human.Friends == nil { + break + } + + return e.complexity.Human.Friends(childComplexity), true + + case "Human.friendsConnection": + if e.complexity.Human.FriendsConnection == nil { + break + } + + args, err := ec.field_Human_friendsConnection_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Human.FriendsConnection(childComplexity, args["first"].(*int), args["after"].(*string)), true + + case "Human.height": + if e.complexity.Human.Height == nil { + break + } + + args, err := ec.field_Human_height_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Human.Height(childComplexity, args["unit"].(models.LengthUnit)), true + + case "Human.id": + if e.complexity.Human.ID == nil { + break + } + + return e.complexity.Human.ID(childComplexity), true + + case "Human.mass": + if e.complexity.Human.Mass == nil { + break + } + + return e.complexity.Human.Mass(childComplexity), true + + case "Human.mutation": + if e.complexity.Human.Mutation == nil { + break + } + + return e.complexity.Human.Mutation(childComplexity), true + + case "Human.name": + if e.complexity.Human.Name == nil { + break + } + + return e.complexity.Human.Name(childComplexity), true + + case "Human.query": + if e.complexity.Human.Query == nil { + break + } + + return e.complexity.Human.Query(childComplexity), true + + case "Human.starships": + if e.complexity.Human.Starships == nil { + break + } + + return e.complexity.Human.Starships(childComplexity), true + + case "Mutation.createReview": + if e.complexity.Mutation.CreateReview == nil { + break + } + + args, err := ec.field_Mutation_createReview_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.CreateReview(childComplexity, args["episode"].(models.Episode), args["review"].(models.Review)), true + + case "PageInfo.endCursor": + if e.complexity.PageInfo.EndCursor == nil { + break + } + + return e.complexity.PageInfo.EndCursor(childComplexity), true + + case "PageInfo.hasNextPage": + if e.complexity.PageInfo.HasNextPage == nil { + break + } + + return e.complexity.PageInfo.HasNextPage(childComplexity), true + + case "PageInfo.startCursor": + if e.complexity.PageInfo.StartCursor == nil { + break + } + + return e.complexity.PageInfo.StartCursor(childComplexity), true + + case "Query.character": + if e.complexity.Query.Character == nil { + break + } + + args, err := ec.field_Query_character_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Character(childComplexity, args["id"].(string)), true + + case "Query.droid": + if e.complexity.Query.Droid == nil { + break + } + + args, err := ec.field_Query_droid_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Droid(childComplexity, args["id"].(string)), true + + case "Query.hero": + if e.complexity.Query.Hero == nil { + break + } + + args, err := ec.field_Query_hero_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Hero(childComplexity, args["episode"].(*models.Episode)), true + + case "Query.human": + if e.complexity.Query.Human == nil { + break + } + + args, err := ec.field_Query_human_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Human(childComplexity, args["id"].(string)), true + + case "Query.reviews": + if e.complexity.Query.Reviews == nil { + break + } + + args, err := ec.field_Query_reviews_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Reviews(childComplexity, args["episode"].(models.Episode), args["since"].(*time.Time)), true + + case "Query.search": + if e.complexity.Query.Search == nil { + break + } + + args, err := ec.field_Query_search_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Search(childComplexity, args["text"].(string)), true + + case "Query.starship": + if e.complexity.Query.Starship == nil { + break + } + + args, err := ec.field_Query_starship_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Starship(childComplexity, args["id"].(string)), true + + case "Review.commentary": + if e.complexity.Review.Commentary == nil { + break + } + + return e.complexity.Review.Commentary(childComplexity), true + + case "Review.stars": + if e.complexity.Review.Stars == nil { + break + } + + return e.complexity.Review.Stars(childComplexity), true + + case "Review.time": + if e.complexity.Review.Time == nil { + break + } + + return e.complexity.Review.Time(childComplexity), true + + case "Starship.history": + if e.complexity.Starship.History == nil { + break + } + + return e.complexity.Starship.History(childComplexity), true + + case "Starship.id": + if e.complexity.Starship.ID == nil { + break + } + + return e.complexity.Starship.ID(childComplexity), true + + case "Starship.length": + if e.complexity.Starship.Length == nil { + break + } + + args, err := ec.field_Starship_length_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Starship.Length(childComplexity, args["unit"].(*models.LengthUnit)), true + + case "Starship.name": + if e.complexity.Starship.Name == nil { + break + } + + return e.complexity.Starship.Name(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap( + ec.unmarshalInputReviewInput, + ) + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + case ast.Mutation: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data := ec._Mutation(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + 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 + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + +var sources = []*ast.Source{ + {Name: "../schema.graphql", Input: `# The query type, represents all of the entry points into our object graph +type Query { + hero(episode: Episode = NEWHOPE): Character + reviews(episode: Episode!, since: Time): [Review!]! + search(text: String!): [SearchResult!]! + character(id: ID!): Character + droid(id: ID!): Droid + human(id: ID!): Human + starship(id: ID!): Starship +} +# The mutation type, represents all updates we can make to our data +type Mutation { + createReview(episode: Episode!, review: ReviewInput!): Review +} +# The episodes in the Star Wars trilogy +enum Episode { + # Star Wars Episode IV: A New Hope, released in 1977. + NEWHOPE + # Star Wars Episode V: The Empire Strikes Back, released in 1980. + EMPIRE + # Star Wars Episode VI: Return of the Jedi, released in 1983. + JEDI +} +# A character from the Star Wars universe +interface Character { + # The ID of the character + id: ID! + # The name of the character + name: String! + # The friends of the character, or an empty list if they have none + friends: [Character!] + # The friends of the character exposed as a connection with edges + friendsConnection(first: Int, after: ID): FriendsConnection! + # The movies this character appears in + appearsIn: [Episode!]! +} +# Units of height +enum LengthUnit { + # The standard unit around the world + METER + # Primarily used in the United States + FOOT +} +# A humanoid creature from the Star Wars universe +type Human implements Character { + # The ID of the human + id: ID! + # What this human calls themselves + name: String! + # Height in the preferred unit, default is meters + height(unit: LengthUnit = METER): Float! + # Mass in kilograms, or null if unknown + mass: Float + # This human's friends, or an empty list if they have none + friends: [Character!] + # The friends of the human exposed as a connection with edges + friendsConnection(first: Int, after: ID): FriendsConnection! + # The movies this human appears in + appearsIn: [Episode!]! + # A list of starships this person has piloted, or an empty list if none + starships: [Starship!] + # Root level query + query: Query! + # Root level mutation + mutation: Mutation! +} +# An autonomous mechanical character in the Star Wars universe +type Droid implements Character { + # The ID of the droid + id: ID! + # What others call this droid + name: String! + # This droid's friends, or an empty list if they have none + friends: [Character!] + # The friends of the droid exposed as a connection with edges + friendsConnection(first: Int, after: ID): FriendsConnection! + # The movies this droid appears in + appearsIn: [Episode!]! + # This droid's primary function + primaryFunction: String +} +# A connection object for a character's friends +type FriendsConnection { + # The total number of friends + totalCount: Int! + # The edges for each of the character's friends. + edges: [FriendsEdge!] + # A list of the friends, as a convenience when edges are not needed. + friends: [Character!] + # Information for paginating this connection + pageInfo: PageInfo! +} +# An edge object for a character's friends +type FriendsEdge { + # A cursor used for pagination + cursor: ID! + # The character represented by this friendship edge + node: Character +} +# Information for paginating this connection +type PageInfo { + startCursor: ID! + endCursor: ID! + hasNextPage: Boolean! +} +# Represents a review for a movie +type Review { + # The number of stars this review gave, 1-5 + stars: Int! + # Comment about the movie + commentary: String + # when the review was posted + time: Time +} +# The input object sent when someone is creating a new review +input ReviewInput { + # 0-5 stars + stars: Int! + # Comment about the movie, optional + commentary: String + # when the review was posted + time: Time +} +type Starship { + # The ID of the starship + id: ID! + # The name of the starship + name: String! + # Length of the starship, along the longest axis + length(unit: LengthUnit = METER): Float! + # coordinates tracking this ship + history: [[Int!]!]! +} +union SearchResult = Human | Droid | Starship +scalar Time +`, BuiltIn: false}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (ec *executionContext) field_Droid_friendsConnection_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["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg0, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Human_friendsConnection_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["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg0, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Human_height_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 models.LengthUnit + if tmp, ok := rawArgs["unit"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("unit")) + arg0, err = ec.unmarshalOLengthUnit2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐLengthUnit(ctx, tmp) + if err != nil { + return nil, err + } + } + args["unit"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_createReview_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 models.Episode + if tmp, ok := rawArgs["episode"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("episode")) + arg0, err = ec.unmarshalNEpisode2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisode(ctx, tmp) + if err != nil { + return nil, err + } + } + args["episode"] = arg0 + var arg1 models.Review + if tmp, ok := rawArgs["review"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("review")) + arg1, err = ec.unmarshalNReviewInput2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐReview(ctx, tmp) + if err != nil { + return nil, err + } + } + args["review"] = arg1 + return args, nil +} + +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_character_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.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_droid_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.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_hero_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 *models.Episode + if tmp, ok := rawArgs["episode"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("episode")) + arg0, err = ec.unmarshalOEpisode2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisode(ctx, tmp) + if err != nil { + return nil, err + } + } + args["episode"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_human_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.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_reviews_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 models.Episode + if tmp, ok := rawArgs["episode"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("episode")) + arg0, err = ec.unmarshalNEpisode2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisode(ctx, tmp) + if err != nil { + return nil, err + } + } + args["episode"] = arg0 + var arg1 *time.Time + if tmp, ok := rawArgs["since"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("since")) + arg1, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, tmp) + if err != nil { + return nil, err + } + } + args["since"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Query_search_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["text"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["text"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_starship_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.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Starship_length_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 *models.LengthUnit + if tmp, ok := rawArgs["unit"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("unit")) + arg0, err = ec.unmarshalOLengthUnit2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐLengthUnit(ctx, tmp) + if err != nil { + return nil, err + } + } + args["unit"] = arg0 + return args, nil +} + +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) _Droid_id(ctx context.Context, field graphql.CollectedField, obj *models.Droid) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Droid_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Droid_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Droid", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Droid_name(ctx context.Context, field graphql.CollectedField, obj *models.Droid) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Droid_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Droid_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Droid", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.CollectedField, obj *models.Droid) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Droid_friends(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Droid().Friends(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]models.Character) + fc.Result = res + return ec.marshalOCharacter2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐCharacterᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Droid_friends(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Droid", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + }, + } + return fc, nil +} + +func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *models.Droid) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Droid_friendsConnection(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Droid().FriendsConnection(rctx, obj, fc.Args["first"].(*int), fc.Args["after"].(*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.(*models.FriendsConnection) + fc.Result = res + return ec.marshalNFriendsConnection2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐFriendsConnection(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Droid_friendsConnection(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Droid", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "totalCount": + return ec.fieldContext_FriendsConnection_totalCount(ctx, field) + case "edges": + return ec.fieldContext_FriendsConnection_edges(ctx, field) + case "friends": + return ec.fieldContext_FriendsConnection_friends(ctx, field) + case "pageInfo": + return ec.fieldContext_FriendsConnection_pageInfo(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type FriendsConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Droid_friendsConnection_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql.CollectedField, obj *models.Droid) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Droid_appearsIn(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.AppearsIn, 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.([]models.Episode) + fc.Result = res + return ec.marshalNEpisode2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisodeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Droid_appearsIn(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Droid", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Episode does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Droid_primaryFunction(ctx context.Context, field graphql.CollectedField, obj *models.Droid) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Droid_primaryFunction(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PrimaryFunction, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalOString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Droid_primaryFunction(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Droid", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _FriendsConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *models.FriendsConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_FriendsConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount(), 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.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_FriendsConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "FriendsConnection", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _FriendsConnection_edges(ctx context.Context, field graphql.CollectedField, obj *models.FriendsConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_FriendsConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.FriendsConnection().Edges(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*models.FriendsEdge) + fc.Result = res + return ec.marshalOFriendsEdge2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐFriendsEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_FriendsConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "FriendsConnection", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_FriendsEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_FriendsEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type FriendsEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, field graphql.CollectedField, obj *models.FriendsConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_FriendsConnection_friends(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.FriendsConnection().Friends(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]models.Character) + fc.Result = res + return ec.marshalOCharacter2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐCharacterᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_FriendsConnection_friends(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "FriendsConnection", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + }, + } + return fc, nil +} + +func (ec *executionContext) _FriendsConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *models.FriendsConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_FriendsConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo(), 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.(models.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_FriendsConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "FriendsConnection", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _FriendsEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *models.FriendsEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_FriendsEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, 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.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_FriendsEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "FriendsEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _FriendsEdge_node(ctx context.Context, field graphql.CollectedField, obj *models.FriendsEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_FriendsEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(models.Character) + fc.Result = res + return ec.marshalOCharacter2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐCharacter(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_FriendsEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "FriendsEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + }, + } + return fc, nil +} + +func (ec *executionContext) _Human_id(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Human_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Human_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Human", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Human_name(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Human_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Human_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Human", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Human_height(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Human_height(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Height(fc.Args["unit"].(models.LengthUnit)), 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.(float64) + fc.Result = res + return ec.marshalNFloat2float64(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Human_height(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Human", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Human_height_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Human_mass(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Human_mass(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Mass, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(float64) + fc.Result = res + return ec.marshalOFloat2float64(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Human_mass(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Human", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Human_friends(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Human().Friends(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]models.Character) + fc.Result = res + return ec.marshalOCharacter2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐCharacterᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Human_friends(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Human", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + }, + } + return fc, nil +} + +func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Human_friendsConnection(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Human().FriendsConnection(rctx, obj, fc.Args["first"].(*int), fc.Args["after"].(*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.(*models.FriendsConnection) + fc.Result = res + return ec.marshalNFriendsConnection2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐFriendsConnection(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Human_friendsConnection(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Human", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "totalCount": + return ec.fieldContext_FriendsConnection_totalCount(ctx, field) + case "edges": + return ec.fieldContext_FriendsConnection_edges(ctx, field) + case "friends": + return ec.fieldContext_FriendsConnection_friends(ctx, field) + case "pageInfo": + return ec.fieldContext_FriendsConnection_pageInfo(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type FriendsConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Human_friendsConnection_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Human_appearsIn(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.AppearsIn, 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.([]models.Episode) + fc.Result = res + return ec.marshalNEpisode2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisodeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Human_appearsIn(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Human", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Episode does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Human_starships(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Human_starships(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Human().Starships(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*models.Starship) + fc.Result = res + return ec.marshalOStarship2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐStarshipᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Human_starships(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Human", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Starship_id(ctx, field) + case "name": + return ec.fieldContext_Starship_name(ctx, field) + case "length": + return ec.fieldContext_Starship_length(ctx, field) + case "history": + return ec.fieldContext_Starship_history(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Starship", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Human_query(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Human_query(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + res := models.Query{} + fc.Result = res + return ec.marshalNQuery2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐQuery(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Human_query(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Human", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hero": + return ec.fieldContext_Query_hero(ctx, field) + case "reviews": + return ec.fieldContext_Query_reviews(ctx, field) + case "search": + return ec.fieldContext_Query_search(ctx, field) + case "character": + return ec.fieldContext_Query_character(ctx, field) + case "droid": + return ec.fieldContext_Query_droid(ctx, field) + case "human": + return ec.fieldContext_Query_human(ctx, field) + case "starship": + return ec.fieldContext_Query_starship(ctx, field) + case "__schema": + return ec.fieldContext_Query___schema(ctx, field) + case "__type": + return ec.fieldContext_Query___type(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Query", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Human_mutation(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Human_mutation(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + res := models.Mutation{} + fc.Result = res + return ec.marshalNMutation2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐMutation(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Human_mutation(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Human", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "createReview": + return ec.fieldContext_Mutation_createReview(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Mutation", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Mutation_createReview(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createReview(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateReview(rctx, fc.Args["episode"].(models.Episode), fc.Args["review"].(models.Review)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*models.Review) + fc.Result = res + return ec.marshalOReview2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐReview(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_createReview(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "stars": + return ec.fieldContext_Review_stars(ctx, field) + case "commentary": + return ec.fieldContext_Review_commentary(ctx, field) + case "time": + return ec.fieldContext_Review_time(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Review", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_createReview_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *models.PageInfo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_startCursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.StartCursor, 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.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PageInfo_startCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PageInfo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *models.PageInfo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_endCursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EndCursor, 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.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PageInfo_endCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PageInfo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *models.PageInfo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_hasNextPage(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.HasNextPage, 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) fieldContext_PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PageInfo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_hero(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_hero(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Hero(rctx, fc.Args["episode"].(*models.Episode)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(models.Character) + fc.Result = res + return ec.marshalOCharacter2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐCharacter(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_hero(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_hero_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_reviews(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Reviews(rctx, fc.Args["episode"].(models.Episode), fc.Args["since"].(*time.Time)) + }) + 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.([]*models.Review) + fc.Result = res + return ec.marshalNReview2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐReviewᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_reviews(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "stars": + return ec.fieldContext_Review_stars(ctx, field) + case "commentary": + return ec.fieldContext_Review_commentary(ctx, field) + case "time": + return ec.fieldContext_Review_time(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Review", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_reviews_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_search(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Search(rctx, fc.Args["text"].(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.([]models.SearchResult) + fc.Result = res + return ec.marshalNSearchResult2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐSearchResultᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_search(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type SearchResult does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_search_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_character(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_character(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Character(rctx, fc.Args["id"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(models.Character) + fc.Result = res + return ec.marshalOCharacter2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐCharacter(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_character(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_character_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_droid(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Droid(rctx, fc.Args["id"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*models.Droid) + fc.Result = res + return ec.marshalODroid2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐDroid(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_droid(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Droid_id(ctx, field) + case "name": + return ec.fieldContext_Droid_name(ctx, field) + case "friends": + return ec.fieldContext_Droid_friends(ctx, field) + case "friendsConnection": + return ec.fieldContext_Droid_friendsConnection(ctx, field) + case "appearsIn": + return ec.fieldContext_Droid_appearsIn(ctx, field) + case "primaryFunction": + return ec.fieldContext_Droid_primaryFunction(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Droid", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_droid_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_human(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_human(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Human(rctx, fc.Args["id"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*models.Human) + fc.Result = res + return ec.marshalOHuman2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐHuman(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_human(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Human_id(ctx, field) + case "name": + return ec.fieldContext_Human_name(ctx, field) + case "height": + return ec.fieldContext_Human_height(ctx, field) + case "mass": + return ec.fieldContext_Human_mass(ctx, field) + case "friends": + return ec.fieldContext_Human_friends(ctx, field) + case "friendsConnection": + return ec.fieldContext_Human_friendsConnection(ctx, field) + case "appearsIn": + return ec.fieldContext_Human_appearsIn(ctx, field) + case "starships": + return ec.fieldContext_Human_starships(ctx, field) + case "query": + return ec.fieldContext_Human_query(ctx, field) + case "mutation": + return ec.fieldContext_Human_mutation(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Human", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_human_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_starship(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Starship(rctx, fc.Args["id"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*models.Starship) + fc.Result = res + return ec.marshalOStarship2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐStarship(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_starship(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Starship_id(ctx, field) + case "name": + return ec.fieldContext_Starship_name(ctx, field) + case "length": + return ec.fieldContext_Starship_length(ctx, field) + case "history": + return ec.fieldContext_Starship_history(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Starship", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_starship_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Review_stars(ctx context.Context, field graphql.CollectedField, obj *models.Review) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Review_stars(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Stars, 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.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Review_stars(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Review", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Review_commentary(ctx context.Context, field graphql.CollectedField, obj *models.Review) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Review_commentary(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Commentary, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Review_commentary(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Review", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Review_time(ctx context.Context, field graphql.CollectedField, obj *models.Review) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Review_time(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Time, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(time.Time) + fc.Result = res + return ec.marshalOTime2timeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Review_time(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Review", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Starship_id(ctx context.Context, field graphql.CollectedField, obj *models.Starship) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Starship_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Starship_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Starship", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Starship_name(ctx context.Context, field graphql.CollectedField, obj *models.Starship) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Starship_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Starship_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Starship", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Starship_length(ctx context.Context, field graphql.CollectedField, obj *models.Starship) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Starship_length(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Starship().Length(rctx, obj, fc.Args["unit"].(*models.LengthUnit)) + }) + 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.(float64) + fc.Result = res + return ec.marshalNFloat2float64(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Starship_length(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Starship", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Starship_length_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Starship_history(ctx context.Context, field graphql.CollectedField, obj *models.Starship) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Starship_history(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.History, 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.([][]int) + fc.Result = res + return ec.marshalNInt2ᚕᚕintᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Starship_history(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Starship", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), 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.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), 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.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), 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.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputReviewInput(ctx context.Context, obj interface{}) (models.Review, error) { + var it models.Review + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"stars", "commentary", "time"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "stars": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("stars")) + data, err := ec.unmarshalNInt2int(ctx, v) + if err != nil { + return it, err + } + it.Stars = data + case "commentary": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("commentary")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Commentary = data + case "time": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("time")) + data, err := ec.unmarshalOTime2timeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.Time = data + } + } + + return it, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +func (ec *executionContext) _Character(ctx context.Context, sel ast.SelectionSet, obj models.Character) graphql.Marshaler { + switch obj := (obj).(type) { + case nil: + return graphql.Null + case models.Human: + return ec._Human(ctx, sel, &obj) + case *models.Human: + if obj == nil { + return graphql.Null + } + return ec._Human(ctx, sel, obj) + case models.Droid: + return ec._Droid(ctx, sel, &obj) + case *models.Droid: + if obj == nil { + return graphql.Null + } + return ec._Droid(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +func (ec *executionContext) _SearchResult(ctx context.Context, sel ast.SelectionSet, obj models.SearchResult) graphql.Marshaler { + switch obj := (obj).(type) { + case nil: + return graphql.Null + case models.Human: + return ec._Human(ctx, sel, &obj) + case *models.Human: + if obj == nil { + return graphql.Null + } + return ec._Human(ctx, sel, obj) + case models.Droid: + return ec._Droid(ctx, sel, &obj) + case *models.Droid: + if obj == nil { + return graphql.Null + } + return ec._Droid(ctx, sel, obj) + case models.Starship: + return ec._Starship(ctx, sel, &obj) + case *models.Starship: + if obj == nil { + return graphql.Null + } + return ec._Starship(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Droid") + case "id": + out.Values[i] = ec._Droid_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "name": + out.Values[i] = ec._Droid_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "friends": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Droid_friends(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "friendsConnection": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Droid_friendsConnection(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "appearsIn": + out.Values[i] = ec._Droid_appearsIn(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "primaryFunction": + out.Values[i] = ec._Droid_primaryFunction(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("FriendsConnection") + case "totalCount": + out.Values[i] = ec._FriendsConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "edges": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._FriendsConnection_edges(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "friends": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._FriendsConnection_friends(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "pageInfo": + out.Values[i] = ec._FriendsConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("FriendsEdge") + case "cursor": + out.Values[i] = ec._FriendsEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._FriendsEdge_node(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Human") + case "id": + out.Values[i] = ec._Human_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "name": + out.Values[i] = ec._Human_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "height": + out.Values[i] = ec._Human_height(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "mass": + out.Values[i] = ec._Human_mass(ctx, field, obj) + case "friends": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Human_friends(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "friendsConnection": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Human_friendsConnection(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "appearsIn": + out.Values[i] = ec._Human_appearsIn(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "starships": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Human_starships(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "query": + out.Values[i] = ec._Human_query(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "mutation": + out.Values[i] = ec._Human_mutation(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_createReview(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("PageInfo") + case "startCursor": + out.Values[i] = ec._PageInfo_startCursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "endCursor": + out.Values[i] = ec._PageInfo_endCursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "hasNextPage": + out.Values[i] = ec._PageInfo_hasNextPage(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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 + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_hero(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "reviews": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_reviews(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "search": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_search(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "character": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_character(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "droid": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_droid(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "human": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_human(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "starship": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_starship(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Review") + case "stars": + out.Values[i] = ec._Review_stars(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "commentary": + out.Values[i] = ec._Review_commentary(ctx, field, obj) + case "time": + out.Values[i] = ec._Review_time(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Starship") + case "id": + out.Values[i] = ec._Starship_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "name": + out.Values[i] = ec._Starship_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "length": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Starship_length(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "history": + out.Values[i] = ec._Starship_history(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNCharacter2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v models.Character) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Character(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNEpisode2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisode(ctx context.Context, v interface{}) (models.Episode, error) { + var res models.Episode + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNEpisode2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v models.Episode) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalNEpisode2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisodeᚄ(ctx context.Context, v interface{}) ([]models.Episode, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]models.Episode, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNEpisode2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisode(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalNEpisode2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisodeᚄ(ctx context.Context, sel ast.SelectionSet, v []models.Episode) 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.marshalNEpisode2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisode(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) 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, "the requested element is null which the schema does not allow") + } + } + return graphql.WrapContextMarshaler(ctx, res) +} + +func (ec *executionContext) marshalNFriendsConnection2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐFriendsConnection(ctx context.Context, sel ast.SelectionSet, v models.FriendsConnection) graphql.Marshaler { + return ec._FriendsConnection(ctx, sel, &v) +} + +func (ec *executionContext) marshalNFriendsConnection2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐFriendsConnection(ctx context.Context, sel ast.SelectionSet, v *models.FriendsConnection) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._FriendsConnection(ctx, sel, v) +} + +func (ec *executionContext) marshalNFriendsEdge2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐFriendsEdge(ctx context.Context, sel ast.SelectionSet, v *models.FriendsEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._FriendsEdge(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) +} + +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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNInt2ᚕintᚄ(ctx context.Context, v interface{}) ([]int, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]int, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNInt2int(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalNInt2ᚕintᚄ(ctx context.Context, sel ast.SelectionSet, v []int) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNInt2int(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) unmarshalNInt2ᚕᚕintᚄ(ctx context.Context, v interface{}) ([][]int, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([][]int, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNInt2ᚕintᚄ(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalNInt2ᚕᚕintᚄ(ctx context.Context, sel ast.SelectionSet, v [][]int) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNInt2ᚕintᚄ(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNMutation2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐMutation(ctx context.Context, sel ast.SelectionSet, v models.Mutation) graphql.Marshaler { + return ec._Mutation(ctx, sel) +} + +func (ec *executionContext) marshalNPageInfo2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐPageInfo(ctx context.Context, sel ast.SelectionSet, v models.PageInfo) graphql.Marshaler { + return ec._PageInfo(ctx, sel, &v) +} + +func (ec *executionContext) marshalNQuery2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐQuery(ctx context.Context, sel ast.SelectionSet, v models.Query) graphql.Marshaler { + return ec._Query(ctx, sel) +} + +func (ec *executionContext) marshalNReview2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐReviewᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.Review) 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.marshalNReview2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐReview(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) marshalNReview2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐReview(ctx context.Context, sel ast.SelectionSet, v *models.Review) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Review(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNReviewInput2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐReview(ctx context.Context, v interface{}) (models.Review, error) { + res, err := ec.unmarshalInputReviewInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNSearchResult2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐSearchResult(ctx context.Context, sel ast.SelectionSet, v models.SearchResult) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._SearchResult(ctx, sel, v) +} + +func (ec *executionContext) marshalNSearchResult2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐSearchResultᚄ(ctx context.Context, sel ast.SelectionSet, v []models.SearchResult) 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.marshalNSearchResult2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐSearchResult(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) marshalNStarship2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐStarship(ctx context.Context, sel ast.SelectionSet, v *models.Starship) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Starship(ctx, sel, v) +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + 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) marshalOCharacter2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v models.Character) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Character(ctx, sel, v) +} + +func (ec *executionContext) marshalOCharacter2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐCharacterᚄ(ctx context.Context, sel ast.SelectionSet, v []models.Character) 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.marshalNCharacter2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐCharacter(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) marshalODroid2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐDroid(ctx context.Context, sel ast.SelectionSet, v *models.Droid) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Droid(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOEpisode2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisode(ctx context.Context, v interface{}) (*models.Episode, error) { + if v == nil { + return nil, nil + } + var res = new(models.Episode) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOEpisode2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v *models.Episode) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +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) marshalOFriendsEdge2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐFriendsEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.FriendsEdge) 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.marshalNFriendsEdge2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐFriendsEdge(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) marshalOHuman2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐHuman(ctx context.Context, sel ast.SelectionSet, v *models.Human) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Human(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOID2ᚖstring(ctx context.Context, v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalID(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOID2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := graphql.MarshalID(*v) + return 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) unmarshalOLengthUnit2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐLengthUnit(ctx context.Context, v interface{}) (models.LengthUnit, error) { + var res models.LengthUnit + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOLengthUnit2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐLengthUnit(ctx context.Context, sel ast.SelectionSet, v models.LengthUnit) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalOLengthUnit2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐLengthUnit(ctx context.Context, v interface{}) (*models.LengthUnit, error) { + if v == nil { + return nil, nil + } + var res = new(models.LengthUnit) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOLengthUnit2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐLengthUnit(ctx context.Context, sel ast.SelectionSet, v *models.LengthUnit) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) marshalOReview2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐReview(ctx context.Context, sel ast.SelectionSet, v *models.Review) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Review(ctx, sel, v) +} + +func (ec *executionContext) marshalOStarship2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐStarshipᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.Starship) 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.marshalNStarship2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐStarship(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) marshalOStarship2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐStarship(ctx context.Context, sel ast.SelectionSet, v *models.Starship) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Starship(ctx, sel, v) +} + +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 + } + 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) unmarshalOTime2timeᚐTime(ctx context.Context, v interface{}) (time.Time, error) { + res, err := graphql.UnmarshalTime(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { + res := graphql.MarshalTime(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 +} + +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/_examples/starwars/models/generated.go b/_examples/starwars/models/generated.go new file mode 100644 index 0000000..a0f3fce --- /dev/null +++ b/_examples/starwars/models/generated.go @@ -0,0 +1,132 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package models + +import ( + "fmt" + "io" + "strconv" +) + +type Character interface { + IsCharacter() + GetID() string + GetName() string + GetFriends() []Character + GetFriendsConnection() *FriendsConnection + GetAppearsIn() []Episode +} + +type SearchResult interface { + IsSearchResult() +} + +type FriendsEdge struct { + Cursor string `json:"cursor"` + Node Character `json:"node,omitempty"` +} + +type Mutation struct { +} + +type PageInfo struct { + StartCursor string `json:"startCursor"` + EndCursor string `json:"endCursor"` + HasNextPage bool `json:"hasNextPage"` +} + +type Query struct { +} + +type Starship struct { + ID string `json:"id"` + Name string `json:"name"` + Length float64 `json:"length"` + History [][]int `json:"history"` +} + +func (Starship) IsSearchResult() {} + +type Episode string + +const ( + EpisodeNewhope Episode = "NEWHOPE" + EpisodeEmpire Episode = "EMPIRE" + EpisodeJedi Episode = "JEDI" +) + +var AllEpisode = []Episode{ + EpisodeNewhope, + EpisodeEmpire, + EpisodeJedi, +} + +func (e Episode) IsValid() bool { + switch e { + case EpisodeNewhope, EpisodeEmpire, EpisodeJedi: + return true + } + return false +} + +func (e Episode) String() string { + return string(e) +} + +func (e *Episode) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = Episode(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid Episode", str) + } + return nil +} + +func (e Episode) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +type LengthUnit string + +const ( + LengthUnitMeter LengthUnit = "METER" + LengthUnitFoot LengthUnit = "FOOT" +) + +var AllLengthUnit = []LengthUnit{ + LengthUnitMeter, + LengthUnitFoot, +} + +func (e LengthUnit) IsValid() bool { + switch e { + case LengthUnitMeter, LengthUnitFoot: + return true + } + return false +} + +func (e LengthUnit) String() string { + return string(e) +} + +func (e *LengthUnit) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = LengthUnit(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid LengthUnit", str) + } + return nil +} + +func (e LengthUnit) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} diff --git a/_examples/starwars/models/model.go b/_examples/starwars/models/model.go new file mode 100644 index 0000000..3729753 --- /dev/null +++ b/_examples/starwars/models/model.go @@ -0,0 +1,77 @@ +package models + +import ( + "encoding/base64" + "fmt" + "time" +) + +type CharacterFields struct { + ID string + Name string + FriendIds []string + AppearsIn []Episode +} + +func (cf CharacterFields) GetID() string { return cf.ID } +func (cf CharacterFields) GetName() string { return cf.Name } +func (cf CharacterFields) GetAppearsIn() []Episode { return cf.AppearsIn } +func (cf CharacterFields) GetFriendsConnection() *FriendsConnection { return nil } // Handled in resolver +func (cf CharacterFields) GetFriends() []Character { return nil } // Handled in resolver + +type Human struct { + CharacterFields + StarshipIds []string + HeightMeters float64 + Mass float64 +} + +func (h *Human) Height(unit LengthUnit) float64 { + switch unit { + case "METER", "": + return h.HeightMeters + case "FOOT": + return h.HeightMeters * 3.28084 + default: + panic("invalid unit") + } +} + +func (Human) IsCharacter() {} +func (Human) IsSearchResult() {} + +type Review struct { + Stars int + Commentary *string + Time time.Time +} + +type Droid struct { + CharacterFields + PrimaryFunction string +} + +func (Droid) IsCharacter() {} +func (Droid) IsSearchResult() {} + +type FriendsConnection struct { + Ids []string + From int + To int +} + +func (f *FriendsConnection) TotalCount() int { + return len(f.Ids) +} + +func (f *FriendsConnection) PageInfo() PageInfo { + return PageInfo{ + StartCursor: EncodeCursor(f.From), + EndCursor: EncodeCursor(f.To - 1), + HasNextPage: f.To < len(f.Ids), + } +} + +func EncodeCursor(i int) string { + return base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("cursor%d", i+1))) +} diff --git a/_examples/starwars/readme.md b/_examples/starwars/readme.md new file mode 100644 index 0000000..e615c88 --- /dev/null +++ b/_examples/starwars/readme.md @@ -0,0 +1,14 @@ +### starwars example + +This server demonstrates a few advanced features of graphql: + - connections + - unions + - interfaces + - enums + +to run this server +```bash +go run ./server/server.go +``` + +and open http://localhost:8080 in your browser diff --git a/_examples/starwars/resolvers.go b/_examples/starwars/resolvers.go new file mode 100644 index 0000000..8cd544e --- /dev/null +++ b/_examples/starwars/resolvers.go @@ -0,0 +1,373 @@ +//go:generate rm -rf generated +//go:generate go run ../../testdata/gqlgen.go + +package starwars + +import ( + "context" + "encoding/base64" + "errors" + "strconv" + "strings" + "time" + + "github.com/niko0xdev/gqlgen/_examples/starwars/generated" + "github.com/niko0xdev/gqlgen/_examples/starwars/models" +) + +type Resolver struct { + humans map[string]models.Human + droid map[string]models.Droid + starships map[string]models.Starship + reviews map[models.Episode][]*models.Review +} + +func (r *Resolver) Droid() generated.DroidResolver { + return &droidResolver{r} +} + +func (r *Resolver) FriendsConnection() generated.FriendsConnectionResolver { + return &friendsConnectionResolver{r} +} + +func (r *Resolver) Human() generated.HumanResolver { + return &humanResolver{r} +} + +func (r *Resolver) Mutation() generated.MutationResolver { + return &mutationResolver{r} +} + +func (r *Resolver) Query() generated.QueryResolver { + return &queryResolver{r} +} + +func (r *Resolver) Starship() generated.StarshipResolver { + return &starshipResolver{r} +} + +func (r *Resolver) resolveCharacters(ctx context.Context, ids []string) ([]models.Character, error) { + result := make([]models.Character, len(ids)) + for i, id := range ids { + char, err := r.Query().Character(ctx, id) + if err != nil { + return nil, err + } + result[i] = char + } + return result, nil +} + +type droidResolver struct{ *Resolver } + +func (r *droidResolver) Friends(ctx context.Context, obj *models.Droid) ([]models.Character, error) { + return r.resolveCharacters(ctx, obj.FriendIds) +} + +func (r *droidResolver) FriendsConnection(ctx context.Context, obj *models.Droid, first *int, after *string) (*models.FriendsConnection, error) { + return r.resolveFriendConnection(ctx, obj.FriendIds, first, after) +} + +type friendsConnectionResolver struct{ *Resolver } + +func (r *Resolver) resolveFriendConnection(_ context.Context, ids []string, first *int, after *string) (*models.FriendsConnection, error) { + from := 0 + if after != nil { + b, err := base64.StdEncoding.DecodeString(*after) + if err != nil { + return nil, err + } + i, err := strconv.Atoi(strings.TrimPrefix(string(b), "cursor")) + if err != nil { + return nil, err + } + from = i + } + + to := len(ids) + if first != nil { + to = from + *first + if to > len(ids) { + to = len(ids) + } + } + + return &models.FriendsConnection{ + Ids: ids, + From: from, + To: to, + }, nil +} + +func (r *friendsConnectionResolver) Edges(ctx context.Context, obj *models.FriendsConnection) ([]*models.FriendsEdge, error) { + friends, err := r.resolveCharacters(ctx, obj.Ids) + if err != nil { + return nil, err + } + + edges := make([]*models.FriendsEdge, obj.To-obj.From) + for i := range edges { + edges[i] = &models.FriendsEdge{ + Cursor: models.EncodeCursor(obj.From + i), + Node: friends[obj.From+i], + } + } + return edges, nil +} + +func (r *friendsConnectionResolver) Friends(ctx context.Context, obj *models.FriendsConnection) ([]models.Character, error) { + return r.resolveCharacters(ctx, obj.Ids) +} + +type humanResolver struct{ *Resolver } + +func (r *humanResolver) Friends(ctx context.Context, obj *models.Human) ([]models.Character, error) { + return r.resolveCharacters(ctx, obj.FriendIds) +} + +func (r *humanResolver) FriendsConnection(ctx context.Context, obj *models.Human, first *int, after *string) (*models.FriendsConnection, error) { + return r.resolveFriendConnection(ctx, obj.FriendIds, first, after) +} + +func (r *humanResolver) Starships(ctx context.Context, obj *models.Human) ([]*models.Starship, error) { + var result []*models.Starship + for _, id := range obj.StarshipIds { + char, err := r.Query().Starship(ctx, id) + if err != nil { + return nil, err + } + if char != nil { + result = append(result, char) + } + } + return result, nil +} + +type mutationResolver struct{ *Resolver } + +func (r *mutationResolver) CreateReview(ctx context.Context, episode models.Episode, review models.Review) (*models.Review, error) { + review.Time = time.Now() + time.Sleep(1 * time.Second) + r.reviews[episode] = append(r.reviews[episode], &review) + return &review, nil +} + +type queryResolver struct{ *Resolver } + +func (r *queryResolver) Hero(ctx context.Context, episode *models.Episode) (models.Character, error) { + if *episode == models.EpisodeEmpire { + return r.humans["1000"], nil + } + return r.droid["2001"], nil +} + +func (r *queryResolver) Reviews(ctx context.Context, episode models.Episode, since *time.Time) ([]*models.Review, error) { + if since == nil { + return r.reviews[episode], nil + } + + var filtered []*models.Review + for _, rev := range r.reviews[episode] { + if rev.Time.After(*since) { + filtered = append(filtered, rev) + } + } + return filtered, nil +} + +func (r *queryResolver) Search(ctx context.Context, text string) ([]models.SearchResult, error) { + var l []models.SearchResult + for _, h := range r.humans { + if strings.Contains(h.Name, text) { + l = append(l, h) + } + } + for _, d := range r.droid { + if strings.Contains(d.Name, text) { + l = append(l, d) + } + } + for _, s := range r.starships { + if strings.Contains(s.Name, text) { + l = append(l, s) + } + } + return l, nil +} + +func (r *queryResolver) Character(ctx context.Context, id string) (models.Character, error) { + if h, ok := r.humans[id]; ok { + return &h, nil + } + if d, ok := r.droid[id]; ok { + return &d, nil + } + return nil, nil +} + +func (r *queryResolver) Droid(ctx context.Context, id string) (*models.Droid, error) { + if d, ok := r.droid[id]; ok { + return &d, nil + } + return nil, nil +} + +func (r *queryResolver) Human(ctx context.Context, id string) (*models.Human, error) { + if h, ok := r.humans[id]; ok { + return &h, nil + } + return nil, nil +} + +func (r *queryResolver) Starship(ctx context.Context, id string) (*models.Starship, error) { + if s, ok := r.starships[id]; ok { + return &s, nil + } + return nil, nil +} + +type starshipResolver struct{ *Resolver } + +func (r *starshipResolver) Length(ctx context.Context, obj *models.Starship, unit *models.LengthUnit) (float64, error) { + switch *unit { + case models.LengthUnitMeter, "": + return obj.Length, nil + case models.LengthUnitFoot: + return obj.Length * 3.28084, nil + default: + return 0, errors.New("invalid unit") + } +} + +func NewResolver() generated.Config { + r := Resolver{} + r.humans = map[string]models.Human{ + "1000": { + CharacterFields: models.CharacterFields{ + ID: "1000", + Name: "Luke Skywalker", + FriendIds: []string{"1002", "1003", "2000", "2001"}, + AppearsIn: []models.Episode{models.EpisodeNewhope, models.EpisodeEmpire, models.EpisodeJedi}, + }, + HeightMeters: 1.72, + Mass: 77, + StarshipIds: []string{"3001", "3003"}, + }, + "1001": { + CharacterFields: models.CharacterFields{ + ID: "1001", + Name: "Darth Vader", + FriendIds: []string{"1004"}, + AppearsIn: []models.Episode{models.EpisodeNewhope, models.EpisodeEmpire, models.EpisodeJedi}, + }, + HeightMeters: 2.02, + Mass: 136, + StarshipIds: []string{"3002"}, + }, + "1002": { + CharacterFields: models.CharacterFields{ + ID: "1002", + Name: "Han Solo", + FriendIds: []string{"1000", "1003", "2001"}, + AppearsIn: []models.Episode{models.EpisodeNewhope, models.EpisodeEmpire, models.EpisodeJedi}, + }, + HeightMeters: 1.8, + Mass: 80, + StarshipIds: []string{"3000", "3003"}, + }, + "1003": { + CharacterFields: models.CharacterFields{ + ID: "1003", + Name: "Leia Organa", + FriendIds: []string{"1000", "1002", "2000", "2001"}, + AppearsIn: []models.Episode{models.EpisodeNewhope, models.EpisodeEmpire, models.EpisodeJedi}, + }, + HeightMeters: 1.5, + Mass: 49, + }, + "1004": { + CharacterFields: models.CharacterFields{ + ID: "1004", + Name: "Wilhuff Tarkin", + FriendIds: []string{"1001"}, + AppearsIn: []models.Episode{models.EpisodeNewhope}, + }, + HeightMeters: 1.8, + Mass: 0, + }, + } + + r.droid = map[string]models.Droid{ + "2000": { + CharacterFields: models.CharacterFields{ + ID: "2000", + Name: "C-3PO", + FriendIds: []string{"1000", "1002", "1003", "2001"}, + AppearsIn: []models.Episode{models.EpisodeNewhope, models.EpisodeEmpire, models.EpisodeJedi}, + }, + PrimaryFunction: "Protocol", + }, + "2001": { + CharacterFields: models.CharacterFields{ + ID: "2001", + Name: "R2-D2", + FriendIds: []string{"1000", "1002", "1003"}, + AppearsIn: []models.Episode{models.EpisodeNewhope, models.EpisodeEmpire, models.EpisodeJedi}, + }, + PrimaryFunction: "Astromech", + }, + } + + r.starships = map[string]models.Starship{ + "3000": { + ID: "3000", + Name: "Millennium Falcon", + History: [][]int{ + {1, 2}, + {4, 5}, + {1, 2}, + {3, 2}, + }, + Length: 34.37, + }, + "3001": { + ID: "3001", + Name: "X-Wing", + History: [][]int{ + {6, 4}, + {3, 2}, + {2, 3}, + {5, 1}, + }, + Length: 12.5, + }, + "3002": { + ID: "3002", + Name: "TIE Advanced x1", + History: [][]int{ + {3, 2}, + {7, 2}, + {6, 4}, + {3, 2}, + }, + Length: 9.2, + }, + "3003": { + ID: "3003", + Name: "Imperial shuttle", + History: [][]int{ + {1, 7}, + {3, 5}, + {5, 3}, + {7, 1}, + }, + Length: 20, + }, + } + + r.reviews = map[models.Episode][]*models.Review{} + + return generated.Config{ + Resolvers: &r, + } +} diff --git a/_examples/starwars/schema.graphql b/_examples/starwars/schema.graphql new file mode 100644 index 0000000..0c6aa73 --- /dev/null +++ b/_examples/starwars/schema.graphql @@ -0,0 +1,135 @@ +# The query type, represents all of the entry points into our object graph +type Query { + hero(episode: Episode = NEWHOPE): Character + reviews(episode: Episode!, since: Time): [Review!]! + search(text: String!): [SearchResult!]! + character(id: ID!): Character + droid(id: ID!): Droid + human(id: ID!): Human + starship(id: ID!): Starship +} +# The mutation type, represents all updates we can make to our data +type Mutation { + createReview(episode: Episode!, review: ReviewInput!): Review +} +# The episodes in the Star Wars trilogy +enum Episode { + # Star Wars Episode IV: A New Hope, released in 1977. + NEWHOPE + # Star Wars Episode V: The Empire Strikes Back, released in 1980. + EMPIRE + # Star Wars Episode VI: Return of the Jedi, released in 1983. + JEDI +} +# A character from the Star Wars universe +interface Character { + # The ID of the character + id: ID! + # The name of the character + name: String! + # The friends of the character, or an empty list if they have none + friends: [Character!] + # The friends of the character exposed as a connection with edges + friendsConnection(first: Int, after: ID): FriendsConnection! + # The movies this character appears in + appearsIn: [Episode!]! +} +# Units of height +enum LengthUnit { + # The standard unit around the world + METER + # Primarily used in the United States + FOOT +} +# A humanoid creature from the Star Wars universe +type Human implements Character { + # The ID of the human + id: ID! + # What this human calls themselves + name: String! + # Height in the preferred unit, default is meters + height(unit: LengthUnit = METER): Float! + # Mass in kilograms, or null if unknown + mass: Float + # This human's friends, or an empty list if they have none + friends: [Character!] + # The friends of the human exposed as a connection with edges + friendsConnection(first: Int, after: ID): FriendsConnection! + # The movies this human appears in + appearsIn: [Episode!]! + # A list of starships this person has piloted, or an empty list if none + starships: [Starship!] + # Root level query + query: Query! + # Root level mutation + mutation: Mutation! +} +# An autonomous mechanical character in the Star Wars universe +type Droid implements Character { + # The ID of the droid + id: ID! + # What others call this droid + name: String! + # This droid's friends, or an empty list if they have none + friends: [Character!] + # The friends of the droid exposed as a connection with edges + friendsConnection(first: Int, after: ID): FriendsConnection! + # The movies this droid appears in + appearsIn: [Episode!]! + # This droid's primary function + primaryFunction: String +} +# A connection object for a character's friends +type FriendsConnection { + # The total number of friends + totalCount: Int! + # The edges for each of the character's friends. + edges: [FriendsEdge!] + # A list of the friends, as a convenience when edges are not needed. + friends: [Character!] + # Information for paginating this connection + pageInfo: PageInfo! +} +# An edge object for a character's friends +type FriendsEdge { + # A cursor used for pagination + cursor: ID! + # The character represented by this friendship edge + node: Character +} +# Information for paginating this connection +type PageInfo { + startCursor: ID! + endCursor: ID! + hasNextPage: Boolean! +} +# Represents a review for a movie +type Review { + # The number of stars this review gave, 1-5 + stars: Int! + # Comment about the movie + commentary: String + # when the review was posted + time: Time +} +# The input object sent when someone is creating a new review +input ReviewInput { + # 0-5 stars + stars: Int! + # Comment about the movie, optional + commentary: String + # when the review was posted + time: Time +} +type Starship { + # The ID of the starship + id: ID! + # The name of the starship + name: String! + # Length of the starship, along the longest axis + length(unit: LengthUnit = METER): Float! + # coordinates tracking this ship + history: [[Int!]!]! +} +union SearchResult = Human | Droid | Starship +scalar Time diff --git a/_examples/starwars/server/server.go b/_examples/starwars/server/server.go new file mode 100644 index 0000000..c82578c --- /dev/null +++ b/_examples/starwars/server/server.go @@ -0,0 +1,30 @@ +package main + +import ( + "context" + "fmt" + "log" + "net/http" + + "github.com/niko0xdev/gqlgen/_examples/starwars" + "github.com/niko0xdev/gqlgen/_examples/starwars/generated" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/playground" +) + +func main() { + srv := handler.NewDefaultServer(generated.NewExecutableSchema(starwars.NewResolver())) + srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + rc := graphql.GetFieldContext(ctx) + fmt.Println("Entered", rc.Object, rc.Field.Name) + res, err = next(ctx) + fmt.Println("Left", rc.Object, rc.Field.Name, "=>", res, err) + return res, err + }) + + http.Handle("/", playground.Handler("Starwars", "/query")) + http.Handle("/query", srv) + + log.Fatal(http.ListenAndServe(":8080", nil)) +} diff --git a/_examples/starwars/starwars_test.go b/_examples/starwars/starwars_test.go new file mode 100644 index 0000000..63b1039 --- /dev/null +++ b/_examples/starwars/starwars_test.go @@ -0,0 +1,242 @@ +package starwars + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/_examples/starwars/generated" + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/introspection" +) + +func TestStarwars(t *testing.T) { + c := client.New(handler.NewDefaultServer(generated.NewExecutableSchema(NewResolver()))) + + t.Run("Lukes starships", func(t *testing.T) { + var resp struct { + Search []struct{ Starships []struct{ Name string } } + } + c.MustPost(`{ search(text:"Luke") { ... on Human { starships { name } } } }`, &resp) + + require.Equal(t, "X-Wing", resp.Search[0].Starships[0].Name) + require.Equal(t, "Imperial shuttle", resp.Search[0].Starships[1].Name) + }) + + t.Run("get character", func(t *testing.T) { + var resp struct { + Character struct { + Name string + Typename string `json:"__typename"` + } + } + c.MustPost(`{ character(id:"2001") { name, __typename } }`, &resp) + + require.Equal(t, "R2-D2", resp.Character.Name) + require.Equal(t, "Droid", resp.Character.Typename) + }) + + t.Run("missing character", func(t *testing.T) { + var resp struct { + Character *struct{ Name string } + } + c.MustPost(`{ character(id:"2002") { name } }`, &resp) + + require.Nil(t, resp.Character) + }) + + t.Run("get droid", func(t *testing.T) { + var resp struct { + Droid struct{ PrimaryFunction string } + } + c.MustPost(`{ droid(id:"2001") { primaryFunction } }`, &resp) + + require.Equal(t, "Astromech", resp.Droid.PrimaryFunction) + }) + + t.Run("get human", func(t *testing.T) { + var resp struct { + Human struct { + Starships []struct { + Name string + Length float64 + } + } + } + c.MustPost(`{ human(id:"1000") { starships { name length(unit:FOOT) } } }`, &resp) + + require.Equal(t, "X-Wing", resp.Human.Starships[0].Name) + require.Equal(t, 41.0105, resp.Human.Starships[0].Length) + + require.Equal(t, "Imperial shuttle", resp.Human.Starships[1].Name) + require.Equal(t, 65.6168, resp.Human.Starships[1].Length) + }) + + t.Run("hero height", func(t *testing.T) { + var resp struct { + Hero struct { + Height float64 + } + } + c.MustPost(`{ hero(episode:EMPIRE) { ... on Human { height(unit:METER) } } }`, &resp) + + require.Equal(t, 1.72, resp.Hero.Height) + }) + + t.Run("default hero episode", func(t *testing.T) { + var resp struct { + Hero struct { + Name string + } + } + c.MustPost(`{ hero { ... on Droid { name } } }`, &resp) + + require.Equal(t, "R2-D2", resp.Hero.Name) + }) + + t.Run("friends", func(t *testing.T) { + var resp struct { + Human struct { + Friends []struct { + Name string + } + } + } + c.MustPost(`{ human(id: "1001") { friends { name } } }`, &resp) + + require.Equal(t, "Wilhuff Tarkin", resp.Human.Friends[0].Name) + }) + + t.Run("friendsConnection.friends", func(t *testing.T) { + var resp struct { + Droid struct { + FriendsConnection struct { + Friends []struct { + Name string + } + } + } + } + c.MustPost(`{ droid(id:"2001") { friendsConnection { friends { name } } } }`, &resp) + + require.Equal(t, "Luke Skywalker", resp.Droid.FriendsConnection.Friends[0].Name) + require.Equal(t, "Han Solo", resp.Droid.FriendsConnection.Friends[1].Name) + require.Equal(t, "Leia Organa", resp.Droid.FriendsConnection.Friends[2].Name) + }) + + t.Run("friendsConnection.edges", func(t *testing.T) { + var resp struct { + Droid struct { + FriendsConnection struct { + Edges []struct { + Cursor string + Node struct { + Name string + } + } + } + } + } + c.MustPost(`{ droid(id:"2001") { friendsConnection { edges { cursor, node { name } } } } }`, &resp) + + require.Equal(t, "Y3Vyc29yMQ==", resp.Droid.FriendsConnection.Edges[0].Cursor) + require.Equal(t, "Luke Skywalker", resp.Droid.FriendsConnection.Edges[0].Node.Name) + require.Equal(t, "Y3Vyc29yMg==", resp.Droid.FriendsConnection.Edges[1].Cursor) + require.Equal(t, "Han Solo", resp.Droid.FriendsConnection.Edges[1].Node.Name) + require.Equal(t, "Y3Vyc29yMw==", resp.Droid.FriendsConnection.Edges[2].Cursor) + require.Equal(t, "Leia Organa", resp.Droid.FriendsConnection.Edges[2].Node.Name) + }) + + t.Run("unset optional arguments", func(t *testing.T) { + var resp struct { + Hero struct { + FriendsConnection struct { + Friends []struct { + Name string + } + } + } + } + query := ` + query a($first:Int, $after:ID) { + hero { + friendsConnection(first:$first, after:$after) { + friends { name } + } + } + }` + c.MustPost(query, &resp) + + require.Len(t, resp.Hero.FriendsConnection.Friends, 3) + }) + + t.Run("mutations must be run in sequence", func(t *testing.T) { + var resp struct { + A struct{ Time string } + B struct{ Time string } + C struct{ Time string } + } + + c.MustPost(`mutation f{ + a:createReview(episode: NEWHOPE, review:{stars:1, commentary:"Blah blah"}) { + time + } + b:createReview(episode: NEWHOPE, review:{stars:1, commentary:"Blah blah"}) { + time + } + c:createReview(episode: NEWHOPE, review:{stars:1, commentary:"Blah blah"}) { + time + } + }`, &resp) + + require.NotEqual(t, resp.A.Time, resp.B.Time) + require.NotEqual(t, resp.C.Time, resp.B.Time) + }) + + t.Run("multidimensional arrays", func(t *testing.T) { + var resp struct { + Starship struct { + History [][]int + } + } + c.MustPost(`{ starship(id:"3001") { history } }`, &resp) + + require.Len(t, resp.Starship.History, 4) + require.Len(t, resp.Starship.History[0], 2) + }) + + t.Run("invalid enums in variables", func(t *testing.T) { + var resp struct{} + + err := c.Post(`mutation($episode: Episode!) { + createReview(episode: $episode, review:{stars:1, commentary:"Blah blah"}) { + time + } + }`, &resp, client.Var("episode", "INVALID")) + + require.EqualError(t, err, `http 422: {"errors":[{"message":"INVALID is not a valid Episode","path":["variable","episode"],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}],"data":null}`) + }) + + t.Run("introspection", func(t *testing.T) { + // Make sure we can run the graphiql introspection query without errors + var resp interface{} + c.MustPost(introspection.Query, &resp) + }) + + t.Run("aliased field and non-aliased field", func(t *testing.T) { + var resp struct { + Character struct { + Name string + } + AliasedCharacter struct { + Name string + } + } + c.MustPost(`{ + character(id: "2001") { name } + aliasedCharacter: character(id: "2001") { name } + }`, &resp) + require.Equal(t, resp.Character, resp.AliasedCharacter) + }) +} diff --git a/_examples/todo/generated.go b/_examples/todo/generated.go new file mode 100644 index 0000000..bd6fce5 --- /dev/null +++ b/_examples/todo/generated.go @@ -0,0 +1,3959 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package todo + +import ( + "bytes" + "context" + "embed" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + MyMutation() MyMutationResolver + MyQuery() MyQueryResolver +} + +type DirectiveRoot struct { + HasRole func(ctx context.Context, obj interface{}, next graphql.Resolver, role Role) (res interface{}, err error) + User func(ctx context.Context, obj interface{}, next graphql.Resolver, id int) (res interface{}, err error) +} + +type ComplexityRoot struct { + MyMutation struct { + CreateTodo func(childComplexity int, todo TodoInput) int + UpdateTodo func(childComplexity int, id int, changes map[string]interface{}) int + } + + MyQuery struct { + LastTodo func(childComplexity int) int + Todo func(childComplexity int, id int) int + Todos func(childComplexity int) int + } + + Todo struct { + Done func(childComplexity int) int + ID func(childComplexity int) int + Text func(childComplexity int) int + } +} + +type MyMutationResolver interface { + CreateTodo(ctx context.Context, todo TodoInput) (*Todo, error) + UpdateTodo(ctx context.Context, id int, changes map[string]interface{}) (*Todo, error) +} +type MyQueryResolver interface { + Todo(ctx context.Context, id int) (*Todo, error) + LastTodo(ctx context.Context) (*Todo, error) + Todos(ctx context.Context) ([]*Todo, error) +} + +type executableSchema struct { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = ec + switch typeName + "." + field { + + case "MyMutation.createTodo": + if e.complexity.MyMutation.CreateTodo == nil { + break + } + + args, err := ec.field_MyMutation_createTodo_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.MyMutation.CreateTodo(childComplexity, args["todo"].(TodoInput)), true + + case "MyMutation.updateTodo": + if e.complexity.MyMutation.UpdateTodo == nil { + break + } + + args, err := ec.field_MyMutation_updateTodo_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.MyMutation.UpdateTodo(childComplexity, args["id"].(int), args["changes"].(map[string]interface{})), true + + case "MyQuery.lastTodo": + if e.complexity.MyQuery.LastTodo == nil { + break + } + + return e.complexity.MyQuery.LastTodo(childComplexity), true + + case "MyQuery.todo": + if e.complexity.MyQuery.Todo == nil { + break + } + + args, err := ec.field_MyQuery_todo_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.MyQuery.Todo(childComplexity, args["id"].(int)), true + + case "MyQuery.todos": + if e.complexity.MyQuery.Todos == nil { + break + } + + return e.complexity.MyQuery.Todos(childComplexity), true + + case "Todo.done": + if e.complexity.Todo.Done == nil { + break + } + + return e.complexity.Todo.Done(childComplexity), true + + case "Todo.id": + if e.complexity.Todo.ID == nil { + break + } + + return e.complexity.Todo.ID(childComplexity), true + + case "Todo.text": + if e.complexity.Todo.Text == nil { + break + } + + return e.complexity.Todo.Text(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap( + ec.unmarshalInputTodoInput, + ) + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._queryMiddleware(ctx, rc.Operation, func(ctx context.Context) (interface{}, error) { + return ec._MyQuery(ctx, rc.Operation.SelectionSet), nil + }) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + case ast.Mutation: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data := ec._mutationMiddleware(ctx, rc.Operation, func(ctx context.Context) (interface{}, error) { + return ec._MyMutation(ctx, rc.Operation.SelectionSet), nil + }) + var buf bytes.Buffer + 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 + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + +//go:embed "schema.graphql" +var sourcesFS embed.FS + +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) +} + +var sources = []*ast.Source{ + {Name: "schema.graphql", Input: sourceData("schema.graphql"), BuiltIn: false}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (ec *executionContext) dir_hasRole_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 Role + if tmp, ok := rawArgs["role"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("role")) + arg0, err = ec.unmarshalNRole2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtodoᚐRole(ctx, tmp) + if err != nil { + return nil, err + } + } + args["role"] = arg0 + return args, nil +} + +func (ec *executionContext) dir_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.unmarshalNID2int(ctx, tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil +} + +func (ec *executionContext) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 TodoInput + if tmp, ok := rawArgs["todo"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("todo")) + arg0, err = ec.unmarshalNTodoInput2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtodoᚐTodoInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["todo"] = arg0 + return args, nil +} + +func (ec *executionContext) field_MyMutation_updateTodo_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.unmarshalNID2int(ctx, tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + var arg1 map[string]interface{} + if tmp, ok := rawArgs["changes"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("changes")) + arg1, err = ec.unmarshalNMap2map(ctx, tmp) + if err != nil { + return nil, err + } + } + args["changes"] = arg1 + return args, nil +} + +func (ec *executionContext) field_MyQuery___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_MyQuery_todo_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.unmarshalNID2int(ctx, tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil +} + +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 ************************** + +func (ec *executionContext) _queryMiddleware(ctx context.Context, obj *ast.OperationDefinition, next func(ctx context.Context) (interface{}, error)) graphql.Marshaler { + + for _, d := range obj.Directives { + switch d.Name { + case "user": + rawArgs := d.ArgumentMap(ec.Variables) + args, err := ec.dir_user_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + n := next + next = func(ctx context.Context) (interface{}, error) { + if ec.directives.User == nil { + return nil, errors.New("directive user is not implemented") + } + return ec.directives.User(ctx, obj, n, args["id"].(int)) + } + } + } + tmp, err := next(ctx) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if data, ok := tmp.(graphql.Marshaler); ok { + return data + } + ec.Errorf(ctx, `unexpected type %T from directive, should be graphql.Marshaler`, tmp) + return graphql.Null + +} + +func (ec *executionContext) _mutationMiddleware(ctx context.Context, obj *ast.OperationDefinition, next func(ctx context.Context) (interface{}, error)) graphql.Marshaler { + + for _, d := range obj.Directives { + switch d.Name { + case "user": + rawArgs := d.ArgumentMap(ec.Variables) + args, err := ec.dir_user_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + n := next + next = func(ctx context.Context) (interface{}, error) { + if ec.directives.User == nil { + return nil, errors.New("directive user is not implemented") + } + return ec.directives.User(ctx, obj, n, args["id"].(int)) + } + } + } + tmp, err := next(ctx) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if data, ok := tmp.(graphql.Marshaler); ok { + return data + } + ec.Errorf(ctx, `unexpected type %T from directive, should be graphql.Marshaler`, tmp) + return graphql.Null + +} + +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 "user": + rawArgs := d.ArgumentMap(ec.Variables) + args, err := ec.dir_user_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return nil + } + n := next + next = func(ctx context.Context) (interface{}, error) { + if ec.directives.User == nil { + return nil, errors.New("directive user is not implemented") + } + return ec.directives.User(ctx, obj, n, args["id"].(int)) + } + } + } + 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) _MyMutation_createTodo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MyMutation_createTodo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.MyMutation().CreateTodo(rctx, fc.Args["todo"].(TodoInput)) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*Todo) + fc.Result = res + return ec.marshalNTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtodoᚐTodo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MyMutation_createTodo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MyMutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Todo_id(ctx, field) + case "text": + return ec.fieldContext_Todo_text(ctx, field) + case "done": + return ec.fieldContext_Todo_done(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_MyMutation_createTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _MyMutation_updateTodo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MyMutation_updateTodo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.MyMutation().UpdateTodo(rctx, fc.Args["id"].(int), fc.Args["changes"].(map[string]interface{})) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Todo) + fc.Result = res + return ec.marshalOTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtodoᚐTodo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MyMutation_updateTodo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MyMutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Todo_id(ctx, field) + case "text": + return ec.fieldContext_Todo_text(ctx, field) + case "done": + return ec.fieldContext_Todo_done(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_MyMutation_updateTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MyQuery_todo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.MyQuery().Todo(rctx, fc.Args["id"].(int)) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Todo) + fc.Result = res + return ec.marshalOTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtodoᚐTodo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MyQuery_todo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MyQuery", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Todo_id(ctx, field) + case "text": + return ec.fieldContext_Todo_text(ctx, field) + case "done": + return ec.fieldContext_Todo_done(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_MyQuery_todo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _MyQuery_lastTodo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MyQuery_lastTodo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.MyQuery().LastTodo(rctx) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Todo) + fc.Result = res + return ec.marshalOTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtodoᚐTodo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MyQuery_lastTodo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MyQuery", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Todo_id(ctx, field) + case "text": + return ec.fieldContext_Todo_text(ctx, field) + case "done": + return ec.fieldContext_Todo_done(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MyQuery_todos(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.MyQuery().Todos(rctx) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*Todo) + fc.Result = res + return ec.marshalNTodo2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtodoᚐTodoᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MyQuery_todos(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MyQuery", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Todo_id(ctx, field) + case "text": + return ec.fieldContext_Todo_text(ctx, field) + case "done": + return ec.fieldContext_Todo_done(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MyQuery___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MyQuery___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MyQuery", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_MyQuery___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MyQuery___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MyQuery___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MyQuery", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalNID2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Todo_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_text(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Text, 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) fieldContext_Todo_text(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_done(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.Done, nil + } + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtodoᚐRole(ctx, "OWNER") + if err != nil { + return nil, err + } + if ec.directives.HasRole == nil { + return nil, errors.New("directive hasRole is not implemented") + } + return ec.directives.HasRole(ctx, obj, directive0, role) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) + }) + + 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) fieldContext_Todo_done(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputTodoInput(ctx context.Context, obj interface{}) (TodoInput, error) { + var it TodoInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"text", "done"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "text": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Text = data + case "done": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("done")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.Done = data + } + } + + return it, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +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", + }) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + 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.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._MyMutation_createTodo(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "updateTodo": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._MyMutation_updateTodo(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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", + }) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + 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 + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._MyQuery_todo(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "lastTodo": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._MyQuery_lastTodo(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "todos": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._MyQuery_todos(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._MyQuery___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._MyQuery___schema(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Todo") + case "id": + out.Values[i] = ec._Todo_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "text": + out.Values[i] = ec._Todo_text(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "done": + out.Values[i] = ec._Todo_done(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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, "the requested element is null which the schema does not allow") + } + } + return 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNMap2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { + res, err := graphql.UnmarshalMap(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNMap2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + res := graphql.MarshalMap(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNRole2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtodoᚐRole(ctx context.Context, v interface{}) (Role, error) { + var res Role + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNRole2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtodoᚐRole(ctx context.Context, sel ast.SelectionSet, v Role) graphql.Marshaler { + return v +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNTodo2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { + return ec._Todo(ctx, sel, &v) +} + +func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtodoᚐTodoᚄ(ctx context.Context, sel ast.SelectionSet, v []*Todo) 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.marshalNTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtodoᚐTodo(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) marshalNTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Todo(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNTodoInput2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtodoᚐTodoInput(ctx context.Context, v interface{}) (TodoInput, error) { + res, err := ec.unmarshalInputTodoInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + 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) 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) marshalOTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Todo(ctx, sel, v) +} + +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/_examples/todo/gqlgen.yml b/_examples/todo/gqlgen.yml new file mode 100644 index 0000000..3c447ad --- /dev/null +++ b/_examples/todo/gqlgen.yml @@ -0,0 +1,7 @@ +models: + Todo: + model: github.com/niko0xdev/gqlgen/_examples/todo.Todo + ID: + model: # override the default id marshaller to use ints + - github.com/niko0xdev/gqlgen/graphql.IntID + - github.com/niko0xdev/gqlgen/graphql.ID diff --git a/_examples/todo/models.go b/_examples/todo/models.go new file mode 100644 index 0000000..2a5771c --- /dev/null +++ b/_examples/todo/models.go @@ -0,0 +1,21 @@ +package todo + +type Ownable interface { + Owner() *User +} + +type Todo struct { + ID int + Text string + Done bool + owner *User +} + +func (t Todo) Owner() *User { + return t.owner +} + +type User struct { + ID int + Name string +} diff --git a/_examples/todo/models_gen.go b/_examples/todo/models_gen.go new file mode 100644 index 0000000..8fba788 --- /dev/null +++ b/_examples/todo/models_gen.go @@ -0,0 +1,64 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package todo + +import ( + "fmt" + "io" + "strconv" +) + +type MyMutation struct { +} + +type MyQuery struct { +} + +// Passed to createTodo to create a new todo +type TodoInput struct { + // The body text + Text string `json:"text"` + // Is it done already? + Done *bool `json:"done,omitempty"` +} + +type Role string + +const ( + RoleAdmin Role = "ADMIN" + RoleOwner Role = "OWNER" +) + +var AllRole = []Role{ + RoleAdmin, + RoleOwner, +} + +func (e Role) IsValid() bool { + switch e { + case RoleAdmin, RoleOwner: + return true + } + return false +} + +func (e Role) String() string { + return string(e) +} + +func (e *Role) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = Role(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid Role", str) + } + return nil +} + +func (e Role) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} diff --git a/_examples/todo/readme.md b/_examples/todo/readme.md new file mode 100644 index 0000000..bc94297 --- /dev/null +++ b/_examples/todo/readme.md @@ -0,0 +1,10 @@ +### todo app + +This is the simplest example of a graphql server. + +to run this server +```bash +go run ./server/server.go +``` + +and open http://localhost:8081 in your browser diff --git a/_examples/todo/schema.graphql b/_examples/todo/schema.graphql new file mode 100644 index 0000000..8be7b29 --- /dev/null +++ b/_examples/todo/schema.graphql @@ -0,0 +1,40 @@ +schema { + query: MyQuery + mutation: MyMutation +} + +type MyQuery { + todo(id: ID!): Todo + lastTodo: Todo + todos: [Todo!]! +} + +type MyMutation { + createTodo(todo: TodoInput!): Todo! + updateTodo(id: ID!, changes: Map!): Todo +} + +type Todo { + id: ID! + text: String! + done: Boolean! @hasRole(role: OWNER) # only the owner can see if a todo is done +} + +"Passed to createTodo to create a new todo" +input TodoInput { + "The body text" + text: String! + "Is it done already?" + done: Boolean +} + +scalar Map + +"Prevents access to a field if the user doesnt have the matching role" +directive @hasRole(role: Role!) on FIELD_DEFINITION +directive @user(id: ID!) on MUTATION | QUERY | FIELD + +enum Role { + ADMIN + OWNER +} diff --git a/_examples/todo/server/server.go b/_examples/todo/server/server.go new file mode 100644 index 0000000..e270c37 --- /dev/null +++ b/_examples/todo/server/server.go @@ -0,0 +1,27 @@ +package main + +import ( + "context" + "errors" + "log" + "net/http" + "runtime/debug" + + "github.com/niko0xdev/gqlgen/_examples/todo" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/playground" +) + +func main() { + srv := handler.NewDefaultServer(todo.NewExecutableSchema(todo.New())) + srv.SetRecoverFunc(func(ctx context.Context, err interface{}) (userMessage error) { + // send this panic somewhere + log.Print(err) + debug.PrintStack() + return errors.New("user message on panic") + }) + + http.Handle("/", playground.Handler("Todo", "/query")) + http.Handle("/query", srv) + log.Fatal(http.ListenAndServe(":8081", nil)) +} diff --git a/_examples/todo/todo.go b/_examples/todo/todo.go new file mode 100644 index 0000000..a0c586c --- /dev/null +++ b/_examples/todo/todo.go @@ -0,0 +1,152 @@ +//go:generate go run ../../testdata/gqlgen.go + +package todo + +import ( + "context" + "errors" + "fmt" + "time" + + "github.com/mitchellh/mapstructure" + + "github.com/niko0xdev/gqlgen/graphql" +) + +var ( + you = &User{ID: 1, Name: "You"} + them = &User{ID: 2, Name: "Them"} +) + +type ckey string + +func getUserId(ctx context.Context) int { + if id, ok := ctx.Value(ckey("userId")).(int); ok { + return id + } + return you.ID +} + +func New() Config { + c := Config{ + Resolvers: &resolvers{ + todos: []*Todo{ + {ID: 1, Text: "A todo not to forget", Done: false, owner: you}, + {ID: 2, Text: "This is the most important", Done: false, owner: you}, + {ID: 3, Text: "Somebody else's todo", Done: true, owner: them}, + {ID: 4, Text: "Please do this or else", Done: false, owner: you}, + }, + lastID: 4, + }, + } + c.Directives.HasRole = func(ctx context.Context, obj interface{}, next graphql.Resolver, role Role) (interface{}, error) { + switch role { + case RoleAdmin: + // No admin for you! + return nil, nil + case RoleOwner: + ownable, isOwnable := obj.(Ownable) + if !isOwnable { + return nil, fmt.Errorf("obj cant be owned") + } + + if ownable.Owner().ID != getUserId(ctx) { + return nil, fmt.Errorf("you don't own that") + } + } + + return next(ctx) + } + c.Directives.User = func(ctx context.Context, obj interface{}, next graphql.Resolver, id int) (interface{}, error) { + return next(context.WithValue(ctx, ckey("userId"), id)) + } + return c +} + +type resolvers struct { + todos []*Todo + lastID int +} + +func (r *resolvers) MyQuery() MyQueryResolver { + return (*QueryResolver)(r) +} + +func (r *resolvers) MyMutation() MyMutationResolver { + return (*MutationResolver)(r) +} + +type QueryResolver resolvers + +func (r *QueryResolver) Todo(ctx context.Context, id int) (*Todo, error) { + time.Sleep(220 * time.Millisecond) + + if id == 666 { + panic("critical failure") + } + + for _, todo := range r.todos { + if todo.ID == id { + return todo, nil + } + } + return nil, errors.New("not found") +} + +func (r *QueryResolver) LastTodo(ctx context.Context) (*Todo, error) { + if len(r.todos) == 0 { + return nil, errors.New("not found") + } + return r.todos[len(r.todos)-1], nil +} + +func (r *QueryResolver) Todos(ctx context.Context) ([]*Todo, error) { + return r.todos, nil +} + +type MutationResolver resolvers + +func (r *MutationResolver) CreateTodo(ctx context.Context, todo TodoInput) (*Todo, error) { + newID := r.id() + + newTodo := &Todo{ + ID: newID, + Text: todo.Text, + owner: you, + } + + if todo.Done != nil { + newTodo.Done = *todo.Done + } + + r.todos = append(r.todos, newTodo) + + return newTodo, nil +} + +func (r *MutationResolver) UpdateTodo(ctx context.Context, id int, changes map[string]interface{}) (*Todo, error) { + var affectedTodo *Todo + + for i := 0; i < len(r.todos); i++ { + if r.todos[i].ID == id { + affectedTodo = r.todos[i] + break + } + } + + if affectedTodo == nil { + return nil, nil + } + + err := mapstructure.Decode(changes, affectedTodo) + if err != nil { + panic(err) + } + + return affectedTodo, nil +} + +func (r *MutationResolver) id() int { + r.lastID++ + return r.lastID +} diff --git a/_examples/todo/todo_test.go b/_examples/todo/todo_test.go new file mode 100644 index 0000000..be54dff --- /dev/null +++ b/_examples/todo/todo_test.go @@ -0,0 +1,280 @@ +package todo + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/introspection" +) + +func TestTodo(t *testing.T) { + c := client.New(handler.NewDefaultServer(NewExecutableSchema(New()))) + + var resp struct { + CreateTodo struct{ ID string } + } + c.MustPost(`mutation { createTodo(todo:{text:"Fery important"}) { id } }`, &resp) + + require.Equal(t, "5", resp.CreateTodo.ID) + + t.Run("update the todo text", func(t *testing.T) { + var resp struct { + UpdateTodo struct{ Text string } + } + c.MustPost( + `mutation($id: ID!, $text: String!) { updateTodo(id: $id, changes:{text:$text}) { text } }`, + &resp, + client.Var("id", 5), + client.Var("text", "Very important"), + ) + + require.Equal(t, "Very important", resp.UpdateTodo.Text) + }) + + t.Run("get __typename", func(t *testing.T) { + var resp struct { + Todo struct { + Typename string `json:"__typename"` + } + } + c.MustPost(`{ todo(id: 5) { __typename } }`, &resp) + + require.Equal(t, "Todo", resp.Todo.Typename) + }) + + t.Run("update the todo status", func(t *testing.T) { + var resp struct { + UpdateTodo struct{ Text string } + } + c.MustPost(`mutation { updateTodo(id: 5, changes:{done:true}) { text } }`, &resp) + + require.Equal(t, "Very important", resp.UpdateTodo.Text) + }) + + t.Run("update the todo status by user id in mutation", func(t *testing.T) { + var resp struct { + UpdateTodo struct { + Text string + Done bool + } + } + c.MustPost(`mutation @user(id:2){ updateTodo(id: 3, changes:{done:true}) { text, done } }`, &resp) + + require.Equal(t, "Somebody else's todo", resp.UpdateTodo.Text) + }) + + t.Run("update the todo status by user id in field", func(t *testing.T) { + var resp struct { + UpdateTodo struct { + Text string + Done bool + } + } + c.MustPost(`mutation { updateTodo(id: 3, changes:{done:true})@user(id:2) { text, done } }`, &resp) + + require.Equal(t, "Somebody else's todo", resp.UpdateTodo.Text) + }) + + t.Run("failed update the todo status by user id in field", func(t *testing.T) { + var resp struct { + UpdateTodo *struct { + Text string + Done bool + } + } + err := c.Post(`mutation { updateTodo(id: 3, changes:{done:true}) { text, done } }`, &resp) + require.EqualError(t, err, "[{\"message\":\"you don't own that\",\"path\":[\"updateTodo\",\"done\"]}]") + + require.Nil(t, resp.UpdateTodo) + }) + + t.Run("select with alias", func(t *testing.T) { + var resp struct { + A struct{ Text string } + B struct{ ID string } + } + c.MustPost(`{ a: todo(id:1) { text } b: todo(id:2) { id } }`, &resp) + + require.Equal(t, "A todo not to forget", resp.A.Text) + require.Equal(t, "2", resp.B.ID) + }) + + t.Run("find a missing todo", func(t *testing.T) { + var resp struct { + Todo *struct{ Text string } + } + err := c.Post(`{ todo(id:99) { text } }`, &resp) + + require.Error(t, err) + require.Nil(t, resp.Todo) + }) + + t.Run("get done status of unowned todo", func(t *testing.T) { + var resp struct { + Todo *struct { + Text string + Done bool + } + } + err := c.Post(`{ todo(id:3) { text, done } }`, &resp) + + require.EqualError(t, err, `[{"message":"you don't own that","path":["todo","done"]}]`) + require.Nil(t, resp.Todo) + }) + + t.Run("test panic", func(t *testing.T) { + var resp struct { + Todo *struct{ Text string } + } + err := c.Post(`{ todo(id:666) { text } }`, &resp) + + require.EqualError(t, err, `[{"message":"internal system error","path":["todo"]}]`) + }) + + t.Run("select all", func(t *testing.T) { + var resp struct { + Todo struct { + ID string + Text string + Done bool + } + LastTodo struct { + ID string + Text string + Done bool + } + Todos []struct { + ID string + Text string + } + } + c.MustPost(`{ + todo(id:1) { id done text } + lastTodo { id text done } + todos { id text } + }`, &resp) + + require.Equal(t, "1", resp.Todo.ID) + require.Equal(t, "5", resp.LastTodo.ID) + require.Len(t, resp.Todos, 5) + require.Equal(t, "Very important", resp.LastTodo.Text) + require.Equal(t, "5", resp.LastTodo.ID) + }) + + t.Run("introspection", func(t *testing.T) { + // Make sure we can run the graphiql introspection query without errors + var resp interface{} + c.MustPost(introspection.Query, &resp) + }) + + t.Run("null optional field", func(t *testing.T) { + var resp struct { + CreateTodo struct{ Text string } + } + c.MustPost(`mutation { createTodo(todo:{text:"Completed todo", done: null}) { text } }`, &resp) + + require.Equal(t, "Completed todo", resp.CreateTodo.Text) + }) +} + +func TestSkipAndIncludeDirectives(t *testing.T) { + c := client.New(handler.NewDefaultServer(NewExecutableSchema(New()))) + + t.Run("skip on field", func(t *testing.T) { + var resp map[string]interface{} + c.MustPost(`{ todo(id: 1) @skip(if:true) { __typename } }`, &resp) + _, ok := resp["todo"] + require.False(t, ok) + }) + + t.Run("skip on variable", func(t *testing.T) { + q := `query Test($cond: Boolean!) { todo(id: 1) @skip(if: $cond) { __typename } }` + var resp map[string]interface{} + + c.MustPost(q, &resp, client.Var("cond", true)) + _, ok := resp["todo"] + require.False(t, ok) + + c.MustPost(q, &resp, client.Var("cond", false)) + _, ok = resp["todo"] + require.True(t, ok) + }) + + t.Run("skip on inline fragment", func(t *testing.T) { + var resp struct { + Todo struct { + Typename string `json:"__typename"` + } + } + c.MustPost(`{ todo(id: 1) { + ...@skip(if:true) { + __typename + } + } + }`, &resp) + require.Empty(t, resp.Todo.Typename) + }) + + t.Run("skip on fragment", func(t *testing.T) { + var resp struct { + Todo struct { + Typename string `json:"__typename"` + } + } + c.MustPost(` + { + todo(id: 1) { + ...todoFragment @skip(if:true) + } + } + fragment todoFragment on Todo { + __typename + } + `, &resp) + require.Empty(t, resp.Todo.Typename) + }) + + t.Run("include on field", func(t *testing.T) { + q := `query Test($cond: Boolean!) { todo(id: 1) @include(if: $cond) { __typename } }` + var resp map[string]interface{} + + c.MustPost(q, &resp, client.Var("cond", true)) + _, ok := resp["todo"] + require.True(t, ok) + + c.MustPost(q, &resp, client.Var("cond", false)) + _, ok = resp["todo"] + require.False(t, ok) + }) + + t.Run("both skip and include defined", func(t *testing.T) { + type TestCase struct { + Skip bool + Include bool + Expected bool + } + table := []TestCase{ + {Skip: true, Include: true, Expected: false}, + {Skip: true, Include: false, Expected: false}, + {Skip: false, Include: true, Expected: true}, + {Skip: false, Include: false, Expected: false}, + } + q := `query Test($skip: Boolean!, $include: Boolean!) { todo(id: 1) @skip(if: $skip) @include(if: $include) { __typename } }` + for _, tc := range table { + var resp map[string]interface{} + c.MustPost(q, &resp, client.Var("skip", tc.Skip), client.Var("include", tc.Include)) + _, ok := resp["todo"] + require.Equal(t, tc.Expected, ok) + } + }) + + t.Run("skip with default query argument", func(t *testing.T) { + var resp map[string]interface{} + c.MustPost(`query Test($skip: Boolean = true) { todo(id: 1) @skip(if: $skip) { __typename } }`, &resp) + _, ok := resp["todo"] + require.False(t, ok) + }) +} diff --git a/_examples/tools.go b/_examples/tools.go new file mode 100644 index 0000000..c3c64c2 --- /dev/null +++ b/_examples/tools.go @@ -0,0 +1,9 @@ +//go:build tools +// +build tools + +package main + +import ( + _ "github.com/vektah/dataloaden" + _ "golang.org/x/text" +) diff --git a/_examples/type-system-extension/README.md b/_examples/type-system-extension/README.md new file mode 100644 index 0000000..3d65df6 --- /dev/null +++ b/_examples/type-system-extension/README.md @@ -0,0 +1,11 @@ +# Type System Extension example + +https://graphql.github.io/graphql-spec/draft/#sec-Type-System-Extensions + +``` +$ go run ./server/server.go +2018/10/25 12:46:45 connect to http://localhost:8080/ for GraphQL playground + +$ curl -X POST 'http://localhost:8080/query' --data-binary '{"query":"{ todos { id text state verified } }"}' +{"data":{"todos":[{"id":"Todo:1","text":"Buy a cat food","state":"NOT_YET","verified":false},{"id":"Todo:2","text":"Check cat water","state":"DONE","verified":true},{"id":"Todo:3","text":"Check cat meal","state":"DONE","verified":true}]}} +``` diff --git a/_examples/type-system-extension/directive.go b/_examples/type-system-extension/directive.go new file mode 100644 index 0000000..6e2ca22 --- /dev/null +++ b/_examples/type-system-extension/directive.go @@ -0,0 +1,44 @@ +package type_system_extension + +import ( + "context" + "log" + + "github.com/niko0xdev/gqlgen/graphql" +) + +func EnumLogging(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) { + rc := graphql.GetFieldContext(ctx) + log.Printf("enum logging: %v, %s, %T, %+v", rc.Path(), rc.Field.Name, obj, obj) + return next(ctx) +} + +func FieldLogging(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) { + rc := graphql.GetFieldContext(ctx) + log.Printf("field logging: %v, %s, %T, %+v", rc.Path(), rc.Field.Name, obj, obj) + return next(ctx) +} + +func InputLogging(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) { + rc := graphql.GetFieldContext(ctx) + log.Printf("input object logging: %v, %s, %T, %+v", rc.Path(), rc.Field.Name, obj, obj) + return next(ctx) +} + +func ObjectLogging(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) { + rc := graphql.GetFieldContext(ctx) + log.Printf("object logging: %v, %s, %T, %+v", rc.Path(), rc.Field.Name, obj, obj) + return next(ctx) +} + +func ScalarLogging(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) { + rc := graphql.GetFieldContext(ctx) + log.Printf("scalar logging: %v, %s, %T, %+v", rc.Path(), rc.Field.Name, obj, obj) + return next(ctx) +} + +func UnionLogging(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) { + rc := graphql.GetFieldContext(ctx) + log.Printf("union logging: %v, %s, %T, %+v", rc.Path(), rc.Field.Name, obj, obj) + return next(ctx) +} diff --git a/_examples/type-system-extension/generated.go b/_examples/type-system-extension/generated.go new file mode 100644 index 0000000..03ea25b --- /dev/null +++ b/_examples/type-system-extension/generated.go @@ -0,0 +1,3936 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package type_system_extension + +import ( + "bytes" + "context" + "embed" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + MyMutation() MyMutationResolver + MyQuery() MyQueryResolver +} + +type DirectiveRoot struct { + EnumLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + FieldLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + InputLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + InterfaceLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + ObjectLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + ScalarLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + UnionLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) +} + +type ComplexityRoot struct { + MyMutation struct { + CreateTodo func(childComplexity int, todo TodoInput) int + } + + MyQuery struct { + Todo func(childComplexity int, id string) int + Todos func(childComplexity int) int + } + + Todo struct { + ID func(childComplexity int) int + State func(childComplexity int) int + Text func(childComplexity int) int + Verified func(childComplexity int) int + } +} + +type MyMutationResolver interface { + CreateTodo(ctx context.Context, todo TodoInput) (*Todo, error) +} +type MyQueryResolver interface { + Todos(ctx context.Context) ([]*Todo, error) + Todo(ctx context.Context, id string) (*Todo, error) +} + +type executableSchema struct { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = ec + switch typeName + "." + field { + + case "MyMutation.createTodo": + if e.complexity.MyMutation.CreateTodo == nil { + break + } + + args, err := ec.field_MyMutation_createTodo_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.MyMutation.CreateTodo(childComplexity, args["todo"].(TodoInput)), true + + case "MyQuery.todo": + if e.complexity.MyQuery.Todo == nil { + break + } + + args, err := ec.field_MyQuery_todo_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.MyQuery.Todo(childComplexity, args["id"].(string)), true + + case "MyQuery.todos": + if e.complexity.MyQuery.Todos == nil { + break + } + + return e.complexity.MyQuery.Todos(childComplexity), true + + case "Todo.id": + if e.complexity.Todo.ID == nil { + break + } + + return e.complexity.Todo.ID(childComplexity), true + + case "Todo.state": + if e.complexity.Todo.State == nil { + break + } + + return e.complexity.Todo.State(childComplexity), true + + case "Todo.text": + if e.complexity.Todo.Text == nil { + break + } + + return e.complexity.Todo.Text(childComplexity), true + + case "Todo.verified": + if e.complexity.Todo.Verified == nil { + break + } + + return e.complexity.Todo.Verified(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap( + ec.unmarshalInputTodoInput, + ) + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._MyQuery(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + case ast.Mutation: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data := ec._MyMutation(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + 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 + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + +//go:embed "schemas/enum-extension.graphql" "schemas/input-object-extension.graphql" "schemas/interface-extension.graphql" "schemas/object-extension.graphql" "schemas/scalar-extension.graphql" "schemas/schema-extension.graphql" "schemas/schema.graphql" "schemas/type-extension.graphql" "schemas/union-extension.graphql" +var sourcesFS embed.FS + +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) +} + +var sources = []*ast.Source{ + {Name: "schemas/enum-extension.graphql", Input: sourceData("schemas/enum-extension.graphql"), BuiltIn: false}, + {Name: "schemas/input-object-extension.graphql", Input: sourceData("schemas/input-object-extension.graphql"), BuiltIn: false}, + {Name: "schemas/interface-extension.graphql", Input: sourceData("schemas/interface-extension.graphql"), BuiltIn: false}, + {Name: "schemas/object-extension.graphql", Input: sourceData("schemas/object-extension.graphql"), BuiltIn: false}, + {Name: "schemas/scalar-extension.graphql", Input: sourceData("schemas/scalar-extension.graphql"), BuiltIn: false}, + {Name: "schemas/schema-extension.graphql", Input: sourceData("schemas/schema-extension.graphql"), BuiltIn: false}, + {Name: "schemas/schema.graphql", Input: sourceData("schemas/schema.graphql"), BuiltIn: false}, + {Name: "schemas/type-extension.graphql", Input: sourceData("schemas/type-extension.graphql"), BuiltIn: false}, + {Name: "schemas/union-extension.graphql", Input: sourceData("schemas/union-extension.graphql"), BuiltIn: false}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (ec *executionContext) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 TodoInput + if tmp, ok := rawArgs["todo"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("todo")) + arg0, err = ec.unmarshalNTodoInput2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐTodoInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["todo"] = arg0 + return args, nil +} + +func (ec *executionContext) field_MyQuery___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_MyQuery_todo_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.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil +} + +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) _MyMutation_createTodo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MyMutation_createTodo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, 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.MyMutation().CreateTodo(rctx, fc.Args["todo"].(TodoInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.ObjectLogging == nil { + return nil, errors.New("directive objectLogging is not implemented") + } + return ec.directives.ObjectLogging(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.(*Todo); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/niko0xdev/gqlgen/_examples/type-system-extension.Todo`, tmp) + }) + 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.(*Todo) + fc.Result = res + return ec.marshalNTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐTodo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MyMutation_createTodo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MyMutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Todo_id(ctx, field) + case "text": + return ec.fieldContext_Todo_text(ctx, field) + case "state": + return ec.fieldContext_Todo_state(ctx, field) + case "verified": + return ec.fieldContext_Todo_verified(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_MyMutation_createTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MyQuery_todos(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, 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.MyQuery().Todos(rctx) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.ObjectLogging == nil { + return nil, errors.New("directive objectLogging is not implemented") + } + return ec.directives.ObjectLogging(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.([]*Todo); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/niko0xdev/gqlgen/_examples/type-system-extension.Todo`, tmp) + }) + 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.([]*Todo) + fc.Result = res + return ec.marshalNTodo2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐTodoᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MyQuery_todos(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MyQuery", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Todo_id(ctx, field) + case "text": + return ec.fieldContext_Todo_text(ctx, field) + case "state": + return ec.fieldContext_Todo_state(ctx, field) + case "verified": + return ec.fieldContext_Todo_verified(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MyQuery_todo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, 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.MyQuery().Todo(rctx, fc.Args["id"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.ObjectLogging == nil { + return nil, errors.New("directive objectLogging is not implemented") + } + return ec.directives.ObjectLogging(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.(*Todo); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/niko0xdev/gqlgen/_examples/type-system-extension.Todo`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Todo) + fc.Result = res + return ec.marshalOTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐTodo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MyQuery_todo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MyQuery", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Todo_id(ctx, field) + case "text": + return ec.fieldContext_Todo_text(ctx, field) + case "state": + return ec.fieldContext_Todo_state(ctx, field) + case "verified": + return ec.fieldContext_Todo_verified(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_MyQuery_todo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MyQuery___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MyQuery___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MyQuery", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_MyQuery___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MyQuery___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MyQuery___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MyQuery", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Todo_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_text(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Text, 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) fieldContext_Todo_text(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_state(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_state(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.State, 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.(State) + fc.Result = res + return ec.marshalNState2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐState(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Todo_state(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type State does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_verified(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_verified(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Verified, nil + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.FieldLogging == nil { + return nil, errors.New("directive fieldLogging is not implemented") + } + return ec.directives.FieldLogging(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.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) + }) + 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) fieldContext_Todo_verified(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), 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.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), 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.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), 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.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputTodoInput(ctx context.Context, obj interface{}) (TodoInput, error) { + var it TodoInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"text"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "text": + 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.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, 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) + } + } + } + + return it, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +func (ec *executionContext) _Data(ctx context.Context, sel ast.SelectionSet, obj Data) graphql.Marshaler { + switch obj := (obj).(type) { + case nil: + return graphql.Null + case Todo: + return ec._Todo(ctx, sel, &obj) + case *Todo: + if obj == nil { + return graphql.Null + } + return ec._Todo(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 Todo: + return ec._Todo(ctx, sel, &obj) + case *Todo: + if obj == nil { + return graphql.Null + } + return ec._Todo(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +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", + }) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + 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.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._MyMutation_createTodo(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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", + }) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + 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 + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._MyQuery_todos(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "todo": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._MyQuery_todo(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._MyQuery___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._MyQuery___schema(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Todo") + case "id": + out.Values[i] = ec._Todo_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "text": + out.Values[i] = ec._Todo_text(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "state": + out.Values[i] = ec._Todo_state(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "verified": + out.Values[i] = ec._Todo_verified(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNState2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐState(ctx context.Context, v interface{}) (State, error) { + var res State + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNState2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐState(ctx context.Context, sel ast.SelectionSet, v State) graphql.Marshaler { + return v +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNTodo2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { + return ec._Todo(ctx, sel, &v) +} + +func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐTodoᚄ(ctx context.Context, sel ast.SelectionSet, v []*Todo) 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.marshalNTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐTodo(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) marshalNTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Todo(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNTodoInput2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐTodoInput(ctx context.Context, v interface{}) (TodoInput, error) { + res, err := ec.unmarshalInputTodoInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + 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) 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) marshalOTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Todo(ctx, sel, v) +} + +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/_examples/type-system-extension/gqlgen.yml b/_examples/type-system-extension/gqlgen.yml new file mode 100644 index 0000000..bc7a31d --- /dev/null +++ b/_examples/type-system-extension/gqlgen.yml @@ -0,0 +1,15 @@ +# .gqlgen.yml example +# +# Refer to https://gqlgen.com/config/ +# for detailed .gqlgen.yml documentation. + +schema: +- ./schemas/*.graphql + +exec: + filename: generated.go +model: + filename: models_gen.go +resolver: + filename: resolver.go + type: Resolver diff --git a/_examples/type-system-extension/models_gen.go b/_examples/type-system-extension/models_gen.go new file mode 100644 index 0000000..6fb61de --- /dev/null +++ b/_examples/type-system-extension/models_gen.go @@ -0,0 +1,81 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package type_system_extension + +import ( + "fmt" + "io" + "strconv" +) + +type Data interface { + IsData() +} + +type Node interface { + IsNode() + GetID() string +} + +type MyMutation struct { +} + +type MyQuery struct { +} + +type Todo struct { + ID string `json:"id"` + Text string `json:"text"` + State State `json:"state"` + Verified bool `json:"verified"` +} + +func (Todo) IsNode() {} +func (this Todo) GetID() string { return this.ID } + +func (Todo) IsData() {} + +type TodoInput struct { + Text string `json:"text"` +} + +type State string + +const ( + StateNotYet State = "NOT_YET" + StateDone State = "DONE" +) + +var AllState = []State{ + StateNotYet, + StateDone, +} + +func (e State) IsValid() bool { + switch e { + case StateNotYet, StateDone: + return true + } + return false +} + +func (e State) String() string { + return string(e) +} + +func (e *State) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = State(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid State", str) + } + return nil +} + +func (e State) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} diff --git a/_examples/type-system-extension/resolver.go b/_examples/type-system-extension/resolver.go new file mode 100644 index 0000000..0539f26 --- /dev/null +++ b/_examples/type-system-extension/resolver.go @@ -0,0 +1,74 @@ +//go:generate go run ../../testdata/gqlgen.go + +package type_system_extension + +import ( + "context" + "fmt" +) + +func NewRootResolver() ResolverRoot { + return &resolver{ + todos: []*Todo{ + { + ID: "Todo:1", + Text: "Buy a cat food", + State: StateNotYet, + Verified: false, + }, + { + ID: "Todo:2", + Text: "Check cat water", + State: StateDone, + Verified: true, + }, + { + ID: "Todo:3", + Text: "Check cat meal", + State: StateDone, + Verified: true, + }, + }, + } +} + +type resolver struct { + todos []*Todo +} + +func (r *resolver) MyQuery() MyQueryResolver { + return &queryResolver{r} +} + +func (r *resolver) MyMutation() MyMutationResolver { + return &mutationResolver{r} +} + +type queryResolver struct{ *resolver } + +func (r *queryResolver) Todos(ctx context.Context) ([]*Todo, error) { + return r.todos, nil +} + +func (r *queryResolver) Todo(ctx context.Context, id string) (*Todo, error) { + for _, todo := range r.todos { + if todo.ID == id { + return todo, nil + } + } + return nil, nil +} + +type mutationResolver struct{ *resolver } + +func (r *mutationResolver) CreateTodo(ctx context.Context, todoInput TodoInput) (*Todo, error) { + newID := fmt.Sprintf("Todo:%d", len(r.todos)+1) + newTodo := &Todo{ + ID: newID, + Text: todoInput.Text, + State: StateNotYet, + } + r.todos = append(r.todos, newTodo) + + return newTodo, nil +} diff --git a/_examples/type-system-extension/schemas/enum-extension.graphql b/_examples/type-system-extension/schemas/enum-extension.graphql new file mode 100644 index 0000000..c2bb28f --- /dev/null +++ b/_examples/type-system-extension/schemas/enum-extension.graphql @@ -0,0 +1,3 @@ +directive @enumLogging on ENUM + +extend enum State @enumLogging diff --git a/_examples/type-system-extension/schemas/input-object-extension.graphql b/_examples/type-system-extension/schemas/input-object-extension.graphql new file mode 100644 index 0000000..b7c65e3 --- /dev/null +++ b/_examples/type-system-extension/schemas/input-object-extension.graphql @@ -0,0 +1,3 @@ +directive @inputLogging on INPUT_OBJECT + +extend input TodoInput @inputLogging diff --git a/_examples/type-system-extension/schemas/interface-extension.graphql b/_examples/type-system-extension/schemas/interface-extension.graphql new file mode 100644 index 0000000..7d9dc3f --- /dev/null +++ b/_examples/type-system-extension/schemas/interface-extension.graphql @@ -0,0 +1,3 @@ +directive @interfaceLogging on INTERFACE + +extend interface Node @interfaceLogging diff --git a/_examples/type-system-extension/schemas/object-extension.graphql b/_examples/type-system-extension/schemas/object-extension.graphql new file mode 100644 index 0000000..396b6eb --- /dev/null +++ b/_examples/type-system-extension/schemas/object-extension.graphql @@ -0,0 +1,3 @@ +directive @objectLogging on OBJECT + +extend type Todo @objectLogging diff --git a/_examples/type-system-extension/schemas/scalar-extension.graphql b/_examples/type-system-extension/schemas/scalar-extension.graphql new file mode 100644 index 0000000..0e22513 --- /dev/null +++ b/_examples/type-system-extension/schemas/scalar-extension.graphql @@ -0,0 +1,3 @@ +directive @scalarLogging on SCALAR + +extend scalar ID @scalarLogging diff --git a/_examples/type-system-extension/schemas/schema-extension.graphql b/_examples/type-system-extension/schemas/schema-extension.graphql new file mode 100644 index 0000000..9874a64 --- /dev/null +++ b/_examples/type-system-extension/schemas/schema-extension.graphql @@ -0,0 +1,15 @@ +extend schema { + mutation: MyMutation +} + +extend type MyQuery { + todo(id: ID!): Todo +} + +type MyMutation { + createTodo(todo: TodoInput!): Todo! +} + +input TodoInput { + text: String! +} diff --git a/_examples/type-system-extension/schemas/schema.graphql b/_examples/type-system-extension/schemas/schema.graphql new file mode 100644 index 0000000..4efccda --- /dev/null +++ b/_examples/type-system-extension/schemas/schema.graphql @@ -0,0 +1,28 @@ +# GraphQL schema example +# +# https://gqlgen.com/getting-started/ + +schema { + query: MyQuery +} + +interface Node { + id: ID! +} + +type Todo implements Node { + id: ID! + text: String! + state: State! +} + +type MyQuery { + todos: [Todo!]! +} + +union Data = Todo + +enum State { + NOT_YET + DONE +} diff --git a/_examples/type-system-extension/schemas/type-extension.graphql b/_examples/type-system-extension/schemas/type-extension.graphql new file mode 100644 index 0000000..61ac7ec --- /dev/null +++ b/_examples/type-system-extension/schemas/type-extension.graphql @@ -0,0 +1,5 @@ +directive @fieldLogging on FIELD_DEFINITION + +extend type Todo { + verified: Boolean! @fieldLogging +} diff --git a/_examples/type-system-extension/schemas/union-extension.graphql b/_examples/type-system-extension/schemas/union-extension.graphql new file mode 100644 index 0000000..d5b40f6 --- /dev/null +++ b/_examples/type-system-extension/schemas/union-extension.graphql @@ -0,0 +1,3 @@ +directive @unionLogging on UNION + +extend union Data @unionLogging diff --git a/_examples/type-system-extension/server/server.go b/_examples/type-system-extension/server/server.go new file mode 100644 index 0000000..3e1d4c9 --- /dev/null +++ b/_examples/type-system-extension/server/server.go @@ -0,0 +1,40 @@ +package main + +import ( + "log" + "net/http" + "os" + + extension "github.com/niko0xdev/gqlgen/_examples/type-system-extension" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/playground" +) + +const defaultPort = "8080" + +func main() { + port := os.Getenv("PORT") + if port == "" { + port = defaultPort + } + + http.Handle("/", playground.Handler("GraphQL playground", "/query")) + http.Handle("/query", handler.NewDefaultServer( + extension.NewExecutableSchema( + extension.Config{ + Resolvers: extension.NewRootResolver(), + Directives: extension.DirectiveRoot{ + EnumLogging: extension.EnumLogging, + FieldLogging: extension.FieldLogging, + InputLogging: extension.InputLogging, + ObjectLogging: extension.ObjectLogging, + ScalarLogging: extension.ScalarLogging, + UnionLogging: extension.UnionLogging, + }, + }, + ), + )) + + log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) + log.Fatal(http.ListenAndServe(":"+port, nil)) +} diff --git a/_examples/uuid/gqlgen.yml b/_examples/uuid/gqlgen.yml new file mode 100644 index 0000000..4699a04 --- /dev/null +++ b/_examples/uuid/gqlgen.yml @@ -0,0 +1,90 @@ +# Where are all the schema files located? globs are supported eg src/**/*.graphqls +schema: + - graph/*.graphqls + +# Where should the generated server code go? +exec: + filename: graph/generated.go + package: graph + +# Uncomment to enable federation +# federation: +# filename: graph/federation.go +# package: graph + +# Where should any generated models go? +model: + filename: graph/model/models_gen.go + package: model + +# Where should the resolver implementations go? +resolver: + layout: follow-schema + dir: graph + package: graph + filename_template: "{name}.resolvers.go" + # Optional: turn on to not generate template comments above resolvers + # omit_template_comment: false + +# Optional: turn on use ` + "`" + `gqlgen:"fieldName"` + "`" + ` tags in your models +# struct_tag: json + +# Optional: turn on to use []Thing instead of []*Thing +# omit_slice_element_pointers: false + +# Optional: turn on to omit Is() methods to interface and unions +# omit_interface_checks : true + +# Optional: turn on to skip generation of ComplexityRoot struct content and Complexity function +# omit_complexity: false + +# Optional: turn on to not generate any file notice comments in generated files +# omit_gqlgen_file_notice: false + +# Optional: turn on to exclude the gqlgen version in the generated file notice. No effect if `omit_gqlgen_file_notice` is true. +# omit_gqlgen_version_in_file_notice: false + +# Optional: turn off to make struct-type struct fields not use pointers +# e.g. type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing } +# struct_fields_always_pointers: true + +# Optional: turn off to make resolvers return values instead of pointers for structs +# resolvers_always_return_pointers: true + +# Optional: turn on to return pointers instead of values in unmarshalInput +# return_pointers_in_unmarshalinput: false + +# Optional: wrap nullable input fields with Omittable +# nullable_input_omittable: true + +# 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: +# - "github.com/niko0xdev/gqlgen/_examples/uuid/graph/model" + +# This section declares type mapping between the GraphQL and go type systems +# +# The first line in each type will be used as defaults for resolver arguments and +# modelgen, the others will be allowed when binding to fields. Configure them to +# your liking +models: + ID: + model: + - github.com/niko0xdev/gqlgen/graphql.ID + - github.com/niko0xdev/gqlgen/graphql.Int + - github.com/niko0xdev/gqlgen/graphql.Int64 + - github.com/niko0xdev/gqlgen/graphql.Int32 + Int: + model: + - github.com/niko0xdev/gqlgen/graphql.Int + - github.com/niko0xdev/gqlgen/graphql.Int64 + - github.com/niko0xdev/gqlgen/graphql.Int32 + UUID: + model: + - github.com/niko0xdev/gqlgen/graphql.UUID diff --git a/_examples/uuid/graph/generated.go b/_examples/uuid/graph/generated.go new file mode 100644 index 0000000..74e7e69 --- /dev/null +++ b/_examples/uuid/graph/generated.go @@ -0,0 +1,3700 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package graph + +import ( + "bytes" + "context" + "embed" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/_examples/uuid/graph/model" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + "github.com/google/uuid" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// 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 { + Mutation() MutationResolver + Query() QueryResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + Mutation struct { + CreateTodo func(childComplexity int, input model.NewTodo) int + } + + Query struct { + Todos func(childComplexity int) int + } + + Todo struct { + Done func(childComplexity int) int + ID func(childComplexity int) int + Text func(childComplexity int) int + UID func(childComplexity int) int + } +} + +type MutationResolver interface { + CreateTodo(ctx context.Context, input model.NewTodo) (*model.Todo, error) +} +type QueryResolver interface { + Todos(ctx context.Context) ([]*model.Todo, error) +} + +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, 0, 0, nil} + _ = ec + switch typeName + "." + field { + + case "Mutation.createTodo": + if e.complexity.Mutation.CreateTodo == nil { + break + } + + args, err := ec.field_Mutation_createTodo_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.CreateTodo(childComplexity, args["input"].(model.NewTodo)), true + + case "Query.todos": + if e.complexity.Query.Todos == nil { + break + } + + return e.complexity.Query.Todos(childComplexity), true + + case "Todo.done": + if e.complexity.Todo.Done == nil { + break + } + + return e.complexity.Todo.Done(childComplexity), true + + case "Todo.id": + if e.complexity.Todo.ID == nil { + break + } + + return e.complexity.Todo.ID(childComplexity), true + + case "Todo.text": + if e.complexity.Todo.Text == nil { + break + } + + return e.complexity.Todo.Text(childComplexity), true + + case "Todo.uid": + if e.complexity.Todo.UID == nil { + break + } + + return e.complexity.Todo.UID(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap( + ec.unmarshalInputNewTodo, + ) + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + case ast.Mutation: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data := ec._Mutation(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + 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 + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +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 +} + +//go:embed "schema.graphqls" +var sourcesFS embed.FS + +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) +} + +var sources = []*ast.Source{ + {Name: "schema.graphqls", Input: sourceData("schema.graphqls"), BuiltIn: false}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (ec *executionContext) field_Mutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.NewTodo + if tmp, ok := rawArgs["input"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) + arg0, err = ec.unmarshalNNewTodo2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋuuidᚋgraphᚋmodelᚐNewTodo(ctx, tmp) + if err != nil { + return nil, err + } + } + args["input"] = arg0 + return args, nil +} + +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___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) _Mutation_createTodo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createTodo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateTodo(rctx, fc.Args["input"].(model.NewTodo)) + }) + 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.Todo) + fc.Result = res + return ec.marshalNTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋuuidᚋgraphᚋmodelᚐTodo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_createTodo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Todo_id(ctx, field) + case "text": + return ec.fieldContext_Todo_text(ctx, field) + case "done": + return ec.fieldContext_Todo_done(ctx, field) + case "uid": + return ec.fieldContext_Todo_uid(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_createTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_todos(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Todos(rctx) + }) + 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.Todo) + fc.Result = res + return ec.marshalNTodo2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋuuidᚋgraphᚋmodelᚐTodoᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_todos(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Todo_id(ctx, field) + case "text": + return ec.fieldContext_Todo_text(ctx, field) + case "done": + return ec.fieldContext_Todo_done(ctx, field) + case "uid": + return ec.fieldContext_Todo_uid(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Todo_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_text(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Text, 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) fieldContext_Todo_text(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_done(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Done, 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) fieldContext_Todo_done(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_uid(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_uid(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.UID, 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.(uuid.UUID) + fc.Result = res + return ec.marshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Todo_uid(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type UUID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), 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.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), 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.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), 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.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputNewTodo(ctx context.Context, obj interface{}) (model.NewTodo, error) { + var it model.NewTodo + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"text", "userId", "uid"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "text": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Text = data + case "userId": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userId")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.UserID = data + case "uid": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("uid")) + data, err := ec.unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + if err != nil { + return it, err + } + it.UID = data + } + } + + return it, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +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) + deferred := make(map[string]*graphql.FieldSet) + 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.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_createTodo(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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 + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_todos(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var todoImplementors = []string{"Todo"} + +func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *model.Todo) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, todoImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Todo") + case "id": + out.Values[i] = ec._Todo_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "text": + out.Values[i] = ec._Todo_text(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "done": + out.Values[i] = ec._Todo_done(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "uid": + out.Values[i] = ec._Todo_uid(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNNewTodo2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋuuidᚋgraphᚋmodelᚐNewTodo(ctx context.Context, v interface{}) (model.NewTodo, error) { + res, err := ec.unmarshalInputNewTodo(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNTodo2githubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋuuidᚋgraphᚋmodelᚐTodo(ctx context.Context, sel ast.SelectionSet, v model.Todo) graphql.Marshaler { + return ec._Todo(ctx, sel, &v) +} + +func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋuuidᚋgraphᚋmodelᚐTodoᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Todo) 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.marshalNTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋuuidᚋgraphᚋmodelᚐTodo(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) marshalNTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋ_examplesᚋuuidᚋgraphᚋmodelᚐTodo(ctx context.Context, sel ast.SelectionSet, v *model.Todo) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Todo(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx context.Context, v interface{}) (uuid.UUID, error) { + res, err := graphql.UnmarshalUUID(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx context.Context, sel ast.SelectionSet, v uuid.UUID) graphql.Marshaler { + res := graphql.MarshalUUID(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + 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) 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) marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/_examples/uuid/graph/model/models_gen.go b/_examples/uuid/graph/model/models_gen.go new file mode 100644 index 0000000..35ed471 --- /dev/null +++ b/_examples/uuid/graph/model/models_gen.go @@ -0,0 +1,20 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package model + +import ( + "github.com/google/uuid" +) + +type NewTodo struct { + Text string `json:"text"` + UserID string `json:"userId"` + UID uuid.UUID `json:"uid"` +} + +type Todo struct { + ID string `json:"id"` + Text string `json:"text"` + Done bool `json:"done"` + UID uuid.UUID `json:"uid"` +} diff --git a/_examples/uuid/graph/resolver.go b/_examples/uuid/graph/resolver.go new file mode 100644 index 0000000..a25c09c --- /dev/null +++ b/_examples/uuid/graph/resolver.go @@ -0,0 +1,7 @@ +package graph + +// This file will not be regenerated automatically. +// +// It serves as dependency injection for your app, add any dependencies you require here. + +type Resolver struct{} diff --git a/_examples/uuid/graph/schema.graphqls b/_examples/uuid/graph/schema.graphqls new file mode 100644 index 0000000..0742825 --- /dev/null +++ b/_examples/uuid/graph/schema.graphqls @@ -0,0 +1,27 @@ +# GraphQL schema example +# +# https://gqlgen.com/getting-started/ + +type Todo { + id: ID! + text: String! + done: Boolean! + uid: UUID! +} + + +type Query { + todos: [Todo!]! +} + +input NewTodo { + text: String! + userId: String! + uid: UUID! +} + +type Mutation { + createTodo(input: NewTodo!): Todo! +} + +scalar UUID diff --git a/_examples/uuid/graph/schema.resolvers.go b/_examples/uuid/graph/schema.resolvers.go new file mode 100644 index 0000000..c251a7f --- /dev/null +++ b/_examples/uuid/graph/schema.resolvers.go @@ -0,0 +1,39 @@ +package graph + +// 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. +// Code generated by github.com/niko0xdev/gqlgen version v0.17.36 + +import ( + "context" + + "github.com/niko0xdev/gqlgen/_examples/uuid/graph/model" + "github.com/google/uuid" +) + +// CreateTodo is the resolver for the createTodo field. +func (r *mutationResolver) CreateTodo(ctx context.Context, input model.NewTodo) (*model.Todo, error) { + return &model.Todo{ + ID: input.UserID, + Text: input.Text, + Done: true, + UID: input.UID, + }, nil +} + +// Todos is the resolver for the todos field. +func (r *queryResolver) Todos(ctx context.Context) ([]*model.Todo, error) { + return []*model.Todo{ + {ID: "1", Text: "hello", Done: true, UID: uuid.New()}, + {ID: "2", Text: "world", Done: false, UID: uuid.New()}, + }, nil +} + +// Mutation returns MutationResolver implementation. +func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } + +// Query returns QueryResolver implementation. +func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } + +type mutationResolver struct{ *Resolver } +type queryResolver struct{ *Resolver } diff --git a/_examples/uuid/server.go b/_examples/uuid/server.go new file mode 100644 index 0000000..cb6f334 --- /dev/null +++ b/_examples/uuid/server.go @@ -0,0 +1,28 @@ +package main + +import ( + "log" + "net/http" + "os" + + "github.com/niko0xdev/gqlgen/_examples/uuid/graph" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/playground" +) + +const defaultPort = "8080" + +func main() { + port := os.Getenv("PORT") + if port == "" { + port = defaultPort + } + + srv := handler.NewDefaultServer(graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}})) + + http.Handle("/", playground.Handler("GraphQL playground", "/query")) + http.Handle("/query", srv) + + log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) + log.Fatal(http.ListenAndServe(":"+port, nil)) +} diff --git a/_examples/websocket-initfunc/server/Makefile b/_examples/websocket-initfunc/server/Makefile new file mode 100644 index 0000000..7a3aec6 --- /dev/null +++ b/_examples/websocket-initfunc/server/Makefile @@ -0,0 +1,9 @@ +bin_name=server + +build: + @echo "building binary..." +# go generate gives missing go sum entry for module errors +# https://github.com/niko0xdev/gqlgen/issues/1483 +# you will need to first do a go get -u github.com/niko0xdev/gqlgen + go run -mod=mod github.com/niko0xdev/gqlgen generate . + go build -o ${bin_name} server.go diff --git a/_examples/websocket-initfunc/server/go.mod b/_examples/websocket-initfunc/server/go.mod new file mode 100644 index 0000000..d866d17 --- /dev/null +++ b/_examples/websocket-initfunc/server/go.mod @@ -0,0 +1,17 @@ +module github.com/gqlgen/_examples/websocket-initfunc/server + +go 1.18 + +require ( + github.com/niko0xdev/gqlgen v0.17.34 + github.com/go-chi/chi v1.5.4 + github.com/gorilla/websocket v1.5.0 + github.com/rs/cors v1.9.0 + github.com/vektah/gqlparser/v2 v2.5.10 +) + +require ( + github.com/agnivade/levenshtein v1.1.1 // indirect + github.com/hashicorp/golang-lru/v2 v2.0.3 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect +) diff --git a/_examples/websocket-initfunc/server/go.sum b/_examples/websocket-initfunc/server/go.sum new file mode 100644 index 0000000..f4f0640 --- /dev/null +++ b/_examples/websocket-initfunc/server/go.sum @@ -0,0 +1,27 @@ +github.com/niko0xdev/gqlgen v0.17.34 h1:5cS5/OKFguQt+Ws56uj9FlG2xm1IlcJWNF2jrMIKYFQ= +github.com/niko0xdev/gqlgen v0.17.34/go.mod h1:Axcd3jIFHBVcqzixujJQr1wGqE+lGTpz6u4iZBZg1G8= +github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8= +github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo= +github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= +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/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +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/go-chi/chi v1.5.4 h1:QHdzF2szwjqVV4wmByUnTcsbIg7UGaQ0tPF2t5GcAIs= +github.com/go-chi/chi v1.5.4/go.mod h1:uaf8YgoFazUOkPBG7fxPftUylNumIev9awIWOENIuEg= +github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/hashicorp/golang-lru/v2 v2.0.3 h1:kmRrRLlInXvng0SmLxmQpQkpbYAvcXm7NPDrgxJa9mE= +github.com/hashicorp/golang-lru/v2 v2.0.3/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/rs/cors v1.9.0 h1:l9HGsTsHJcvW14Nk7J9KFz8bzeAWXn3CG6bgt7LsrAE= +github.com/rs/cors v1.9.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= +github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/vektah/gqlparser/v2 v2.5.10 h1:6zSM4azXC9u4Nxy5YmdmGu4uKamfwsdKTwp5zsEealU= +github.com/vektah/gqlparser/v2 v2.5.10/go.mod h1:1rCcfwB2ekJofmluGWXMSEnPMZgbxzwj6FaZ/4OT8Cc= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/_examples/websocket-initfunc/server/gqlgen.yml b/_examples/websocket-initfunc/server/gqlgen.yml new file mode 100644 index 0000000..a357dac --- /dev/null +++ b/_examples/websocket-initfunc/server/gqlgen.yml @@ -0,0 +1,69 @@ +# Where are all the schema files located? globs are supported eg src/**/*.graphqls +schema: + - graph/*.graphqls + +# Where should the generated server code go? +exec: + filename: graph/generated.go + package: graph + +# Uncomment to enable federation +# federation: +# filename: graph/federation.go +# package: graph + +# Where should any generated models go? +model: + filename: graph/model/models_gen.go + package: model + +# Where should the resolver implementations go? +resolver: + layout: follow-schema + dir: graph + package: graph + +# Optional: turn on use `gqlgen:"fieldName"` tags in your models +# struct_tag: json + +# Optional: turn on to use []Thing instead of []*Thing +# omit_slice_element_pointers: false + +# Optional: turn off to make struct-type struct fields not use pointers +# e.g. type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing } +# struct_fields_always_pointers: true + +# Optional: turn off to make resolvers return values instead of pointers for structs +# resolvers_always_return_pointers: true + +# Optional: turn on to return pointers instead of values in unmarshalInput +# return_pointers_in_unmarshalinput: false + +# Optional: wrap nullable input fields with Omittable +# nullable_input_omittable: true + +# Optional: set to speed up generation time by not performing a final validation pass. +# skip_validation: 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: +# - "github.com/gqlgen/_examples/websocket-initfunc/server/graph/model" + +# This section declares type mapping between the GraphQL and go type systems +# +# The first line in each type will be used as defaults for resolver arguments and +# modelgen, the others will be allowed when binding to fields. Configure them to +# your liking +models: + ID: + model: + - github.com/niko0xdev/gqlgen/graphql.ID + - github.com/niko0xdev/gqlgen/graphql.Int + - github.com/niko0xdev/gqlgen/graphql.Int64 + - github.com/niko0xdev/gqlgen/graphql.Int32 + Int: + model: + - github.com/niko0xdev/gqlgen/graphql.Int + - github.com/niko0xdev/gqlgen/graphql.Int64 + - github.com/niko0xdev/gqlgen/graphql.Int32 diff --git a/_examples/websocket-initfunc/server/graph/generated.go b/_examples/websocket-initfunc/server/graph/generated.go new file mode 100644 index 0000000..472c5c2 --- /dev/null +++ b/_examples/websocket-initfunc/server/graph/generated.go @@ -0,0 +1,3497 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package graph + +import ( + "bytes" + "context" + "embed" + "errors" + "fmt" + "io" + "strconv" + "sync" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + "github.com/gqlgen/_examples/websocket-initfunc/server/graph/model" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// 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 { + Mutation() MutationResolver + Subscription() SubscriptionResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + Dummy struct { + Done func(childComplexity int) int + ID func(childComplexity int) int + Text func(childComplexity int) int + } + + Mutation struct { + PostMessageTo func(childComplexity int, subscriber string, content string) int + } + + Query struct { + } + + Subscription struct { + Subscribe func(childComplexity int, subscriber string) int + } +} + +type MutationResolver interface { + PostMessageTo(ctx context.Context, subscriber string, content string) (string, error) +} +type SubscriptionResolver interface { + Subscribe(ctx context.Context, subscriber string) (<-chan string, error) +} + +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 "Dummy.done": + if e.complexity.Dummy.Done == nil { + break + } + + return e.complexity.Dummy.Done(childComplexity), true + + case "Dummy.id": + if e.complexity.Dummy.ID == nil { + break + } + + return e.complexity.Dummy.ID(childComplexity), true + + case "Dummy.text": + if e.complexity.Dummy.Text == nil { + break + } + + return e.complexity.Dummy.Text(childComplexity), true + + case "Mutation.postMessageTo": + if e.complexity.Mutation.PostMessageTo == nil { + break + } + + args, err := ec.field_Mutation_postMessageTo_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.PostMessageTo(childComplexity, args["subscriber"].(string), args["content"].(string)), true + + case "Subscription.subscribe": + if e.complexity.Subscription.Subscribe == nil { + break + } + + args, err := ec.field_Subscription_subscribe_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Subscription.Subscribe(childComplexity, args["subscriber"].(string)), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e} + inputUnmarshalMap := graphql.BuildUnmarshalerMap() + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + 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 + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + 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(ctx) + + 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 +} + +//go:embed "schema.graphqls" +var sourcesFS embed.FS + +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) +} + +var sources = []*ast.Source{ + {Name: "schema.graphqls", Input: sourceData("schema.graphqls"), BuiltIn: false}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (ec *executionContext) field_Mutation_postMessageTo_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["subscriber"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("subscriber")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["subscriber"] = arg0 + var arg1 string + if tmp, ok := rawArgs["content"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("content")) + arg1, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["content"] = arg1 + return args, nil +} + +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_Subscription_subscribe_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["subscriber"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("subscriber")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["subscriber"] = arg0 + return args, nil +} + +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) _Dummy_id(ctx context.Context, field graphql.CollectedField, obj *model.Dummy) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Dummy_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Dummy_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Dummy", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Dummy_text(ctx context.Context, field graphql.CollectedField, obj *model.Dummy) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Dummy_text(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Text, 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) fieldContext_Dummy_text(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Dummy", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Dummy_done(ctx context.Context, field graphql.CollectedField, obj *model.Dummy) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Dummy_done(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Done, 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) fieldContext_Dummy_done(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Dummy", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Mutation_postMessageTo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_postMessageTo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().PostMessageTo(rctx, fc.Args["subscriber"].(string), fc.Args["content"].(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.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_postMessageTo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_postMessageTo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Subscription_subscribe(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { + fc, err := ec.fieldContext_Subscription_subscribe(ctx, field) + if err != nil { + return nil + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Subscription().Subscribe(rctx, fc.Args["subscriber"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return nil + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return nil + } + return func(ctx context.Context) graphql.Marshaler { + select { + case 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{'}'}) + }) + case <-ctx.Done(): + return nil + } + } +} + +func (ec *executionContext) fieldContext_Subscription_subscribe(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Subscription", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Subscription_subscribe_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), 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.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), 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.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), 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.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var dummyImplementors = []string{"Dummy"} + +func (ec *executionContext) _Dummy(ctx context.Context, sel ast.SelectionSet, obj *model.Dummy) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, dummyImplementors) + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Dummy") + case "id": + + out.Values[i] = ec._Dummy_id(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "text": + + out.Values[i] = ec._Dummy_text(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "done": + + out.Values[i] = ec._Dummy_done(ctx, field, obj) + + 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 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 "postMessageTo": + + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_postMessageTo(ctx, field) + }) + + 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 "__type": + + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + + case "__schema": + + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + + 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(ctx context.Context) 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 "subscribe": + return ec._Subscription_subscribe(ctx, fields[0]) + default: + panic("unknown field " + strconv.Quote(fields[0].Name)) + } +} + +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": + + out.Values[i] = ec.___Directive_name(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "description": + + out.Values[i] = ec.___Directive_description(ctx, field, obj) + + case "locations": + + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "args": + + out.Values[i] = ec.___Directive_args(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "isRepeatable": + + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + + 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": + + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "description": + + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + + case "isDeprecated": + + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "deprecationReason": + + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + + 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": + + out.Values[i] = ec.___Field_name(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "description": + + out.Values[i] = ec.___Field_description(ctx, field, obj) + + case "args": + + out.Values[i] = ec.___Field_args(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "type": + + out.Values[i] = ec.___Field_type(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "isDeprecated": + + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "deprecationReason": + + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + + 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": + + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "description": + + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + + case "type": + + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "defaultValue": + + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + + 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 "description": + + out.Values[i] = ec.___Schema_description(ctx, field, obj) + + case "types": + + out.Values[i] = ec.___Schema_types(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "queryType": + + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "mutationType": + + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + + case "subscriptionType": + + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + + case "directives": + + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + + 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": + + out.Values[i] = ec.___Type_kind(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "name": + + out.Values[i] = ec.___Type_name(ctx, field, obj) + + case "description": + + out.Values[i] = ec.___Type_description(ctx, field, obj) + + case "fields": + + out.Values[i] = ec.___Type_fields(ctx, field, obj) + + case "interfaces": + + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + + case "possibleTypes": + + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + + case "enumValues": + + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + + case "inputFields": + + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + + case "ofType": + + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + + case "specifiedByURL": + + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + + 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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + 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) 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) marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/_examples/websocket-initfunc/server/graph/model/models_gen.go b/_examples/websocket-initfunc/server/graph/model/models_gen.go new file mode 100644 index 0000000..4fea15b --- /dev/null +++ b/_examples/websocket-initfunc/server/graph/model/models_gen.go @@ -0,0 +1,9 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package model + +type Dummy struct { + ID string `json:"id"` + Text string `json:"text"` + Done bool `json:"done"` +} diff --git a/_examples/websocket-initfunc/server/graph/resolver.go b/_examples/websocket-initfunc/server/graph/resolver.go new file mode 100644 index 0000000..a25c09c --- /dev/null +++ b/_examples/websocket-initfunc/server/graph/resolver.go @@ -0,0 +1,7 @@ +package graph + +// This file will not be regenerated automatically. +// +// It serves as dependency injection for your app, add any dependencies you require here. + +type Resolver struct{} diff --git a/_examples/websocket-initfunc/server/graph/schema.graphqls b/_examples/websocket-initfunc/server/graph/schema.graphqls new file mode 100644 index 0000000..3d323d5 --- /dev/null +++ b/_examples/websocket-initfunc/server/graph/schema.graphqls @@ -0,0 +1,16 @@ +# GraphQL schema example +# + +type Dummy { + id: ID! + text: String! + done: Boolean! +} + +type Mutation { + postMessageTo(subscriber: String!, content: String!): ID! +} + +type Subscription { + subscribe(subscriber: String!): String! +} diff --git a/_examples/websocket-initfunc/server/graph/schema.resolvers.go b/_examples/websocket-initfunc/server/graph/schema.resolvers.go new file mode 100644 index 0000000..df92d81 --- /dev/null +++ b/_examples/websocket-initfunc/server/graph/schema.resolvers.go @@ -0,0 +1,29 @@ +package graph + +// 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. +// Code generated by github.com/niko0xdev/gqlgen version v0.17.25 + +import ( + "context" + "fmt" +) + +// PostMessageTo is the resolver for the postMessageTo field. +func (r *mutationResolver) PostMessageTo(ctx context.Context, subscriber string, content string) (string, error) { + panic(fmt.Errorf("not implemented")) +} + +// Subscribe is the resolver for the subscribe field. +func (r *subscriptionResolver) Subscribe(ctx context.Context, subscriber string) (<-chan string, error) { + panic(fmt.Errorf("not implemented")) +} + +// Mutation returns MutationResolver implementation. +func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } + +// Subscription returns SubscriptionResolver implementation. +func (r *Resolver) Subscription() SubscriptionResolver { return &subscriptionResolver{r} } + +type mutationResolver struct{ *Resolver } +type subscriptionResolver struct{ *Resolver } diff --git a/_examples/websocket-initfunc/server/readme.md b/_examples/websocket-initfunc/server/readme.md new file mode 100644 index 0000000..c798e30 --- /dev/null +++ b/_examples/websocket-initfunc/server/readme.md @@ -0,0 +1,24 @@ +# WebSocket Init App + +Example server app using websocket `InitFunc`. + +## Build and Run the server app + +First get an update from gqlgen: +```bash +go mod tidy +go get -u github.com/niko0xdev/gqlgen +``` + +Next just make the build: +```bash +make build +``` + +Run the server: +```bash +./server +2022/07/07 16:49:46 connect to http://localhost:8080/ for GraphQL playground +``` + +You may now implement a websocket client to subscribe for websocket messages. \ No newline at end of file diff --git a/_examples/websocket-initfunc/server/server.go b/_examples/websocket-initfunc/server/server.go new file mode 100644 index 0000000..6263d32 --- /dev/null +++ b/_examples/websocket-initfunc/server/server.go @@ -0,0 +1,78 @@ +package main + +import ( + "context" + "errors" + "log" + "net/http" + "os" + "time" + + "github.com/go-chi/chi" + "github.com/gorilla/websocket" + "github.com/gqlgen/_examples/websocket-initfunc/server/graph" + "github.com/rs/cors" + + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/handler/extension" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" + "github.com/niko0xdev/gqlgen/graphql/playground" +) + +func webSocketInit(ctx context.Context, initPayload transport.InitPayload) (context.Context, *transport.InitPayload, error) { + // Get the token from payload + payload := initPayload["authToken"] + token, ok := payload.(string) + if !ok || token == "" { + return nil, nil, errors.New("authToken not found in transport payload") + } + + // Perform token verification and authentication... + userId := "john.doe" // e.g. userId, err := GetUserFromAuthentication(token) + + // put it in context + ctxNew := context.WithValue(ctx, "username", userId) + + return ctxNew, nil, nil +} + +const defaultPort = "8080" + +func main() { + port := os.Getenv("PORT") + if port == "" { + port = defaultPort + } + + router := chi.NewRouter() + + // CORS setup, allow any for now + // https://gqlgen.com/recipes/cors/ + c := cors.New(cors.Options{ + AllowedOrigins: []string{"*"}, + AllowCredentials: true, + Debug: false, + }) + + srv := handler.New(graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}})) + srv.AddTransport(transport.POST{}) + srv.AddTransport(transport.Websocket{ + KeepAlivePingInterval: 10 * time.Second, + Upgrader: websocket.Upgrader{ + CheckOrigin: func(r *http.Request) bool { + return true + }, + }, + InitFunc: func(ctx context.Context, initPayload transport.InitPayload) (*transport.InitPayload, context.Context, error) { + return webSocketInit(ctx, initPayload) + }, + }) + srv.Use(extension.Introspection{}) + + router.Handle("/", playground.Handler("My GraphQL App", "/app")) + router.Handle("/app", c.Handler(srv)) + + log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) + log.Fatal(http.ListenAndServe(":"+port, router)) + +} diff --git a/api/generate.go b/api/generate.go new file mode 100644 index 0000000..6e2dd1a --- /dev/null +++ b/api/generate.go @@ -0,0 +1,143 @@ +package api + +import ( + "fmt" + "regexp" + "syscall" + + "github.com/niko0xdev/gqlgen/codegen" + "github.com/niko0xdev/gqlgen/codegen/config" + "github.com/niko0xdev/gqlgen/plugin" + "github.com/niko0xdev/gqlgen/plugin/federation" + "github.com/niko0xdev/gqlgen/plugin/modelgen" + "github.com/niko0xdev/gqlgen/plugin/resolvergen" +) + +func Generate(cfg *config.Config, option ...Option) error { + _ = syscall.Unlink(cfg.Exec.Filename) + if cfg.Model.IsDefined() { + _ = syscall.Unlink(cfg.Model.Filename) + } + + plugins := []plugin.Plugin{} + if cfg.Model.IsDefined() { + plugins = append(plugins, modelgen.New()) + } + plugins = append(plugins, resolvergen.New()) + if cfg.Federation.IsDefined() { + if cfg.Federation.Version == 0 { // default to using the user's choice of version, but if unset, try to sort out which federation version to use + urlRegex := regexp.MustCompile(`(?s)@link.*\(.*url:.*?"(.*?)"[^)]+\)`) // regex to grab the url of a link directive, should it exist + + // check the sources, and if one is marked as federation v2, we mark the entirety to be generated using that format + for _, v := range cfg.Sources { + cfg.Federation.Version = 1 + urlString := urlRegex.FindStringSubmatch(v.Input) + if urlString != nil && urlString[1] == "https://specs.apollo.dev/federation/v2.0" { + cfg.Federation.Version = 2 + break + } + } + } + plugins = append([]plugin.Plugin{federation.New(cfg.Federation.Version)}, plugins...) + } + + for _, o := range option { + o(cfg, &plugins) + } + + for _, p := range plugins { + if inj, ok := p.(plugin.EarlySourceInjector); ok { + if s := inj.InjectSourceEarly(); s != nil { + cfg.Sources = append(cfg.Sources, s) + } + } + } + + if err := cfg.LoadSchema(); err != nil { + return fmt.Errorf("failed to load schema: %w", err) + } + + for _, p := range plugins { + if inj, ok := p.(plugin.LateSourceInjector); ok { + if s := inj.InjectSourceLate(cfg.Schema); s != nil { + cfg.Sources = append(cfg.Sources, s) + } + } + } + + // LoadSchema again now we have everything + if err := cfg.LoadSchema(); err != nil { + return fmt.Errorf("failed to load schema: %w", err) + } + + if err := cfg.Init(); err != nil { + 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 fmt.Errorf("%s: %w", p.Name(), err) + } + } + } + // Merge again now that the generated models have been injected into the typemap + data_plugins := make([]interface{}, len(plugins)) + for index := range plugins { + data_plugins[index] = plugins[index] + } + data, err := codegen.BuildData(cfg, data_plugins...) + if err != nil { + return fmt.Errorf("merging type systems failed: %w", err) + } + + if err = codegen.GenerateCode(data); err != nil { + 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 fmt.Errorf("%s: %w", p.Name(), err) + } + } + } + + if err = codegen.GenerateCode(data); err != nil { + return fmt.Errorf("generating core failed: %w", err) + } + + if !cfg.SkipValidation { + if err := validate(cfg); err != nil { + return fmt.Errorf("validation failed: %w", err) + } + } + + return nil +} + +func validate(cfg *config.Config) error { + roots := []string{cfg.Exec.ImportPath()} + if cfg.Model.IsDefined() { + roots = append(roots, cfg.Model.ImportPath()) + } + + if cfg.Resolver.IsDefined() { + roots = append(roots, cfg.Resolver.ImportPath()) + } + + cfg.Packages.LoadAll(roots...) + errs := cfg.Packages.Errors() + if len(errs) > 0 { + return errs + } + return nil +} diff --git a/api/generate_test.go b/api/generate_test.go new file mode 100644 index 0000000..e4b2058 --- /dev/null +++ b/api/generate_test.go @@ -0,0 +1,60 @@ +package api + +import ( + "os" + "path" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/codegen/config" +) + +func cleanup(workDir string) { + _ = os.Remove(path.Join(workDir, "server.go")) + _ = os.RemoveAll(path.Join(workDir, "graph", "generated")) + _ = os.Remove(path.Join(workDir, "graph", "resolver.go")) + _ = os.Remove(path.Join(workDir, "graph", "schema.resolvers.go")) + _ = os.Remove(path.Join(workDir, "graph", "model", "models_gen.go")) +} + +func TestGenerate(t *testing.T) { + wd, _ := os.Getwd() + type args struct { + workDir string + } + tests := []struct { + name string + args args + wantErr bool + }{ + { + name: "default", + args: args{ + workDir: path.Join(wd, "testdata", "default"), + }, + wantErr: false, + }, + { + name: "federation2", + args: args{ + workDir: path.Join(wd, "testdata", "federation2"), + }, + wantErr: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + defer func() { + cleanup(tt.args.workDir) + _ = os.Chdir(wd) + }() + _ = os.Chdir(tt.args.workDir) + cfg, err := config.LoadConfigFromDefaultLocations() + require.Nil(t, err, "failed to load config") + if err := Generate(cfg); (err != nil) != tt.wantErr { + t.Errorf("Generate() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} diff --git a/api/option.go b/api/option.go new file mode 100644 index 0000000..33b3a60 --- /dev/null +++ b/api/option.go @@ -0,0 +1,47 @@ +package api + +import ( + "github.com/niko0xdev/gqlgen/codegen/config" + "github.com/niko0xdev/gqlgen/plugin" +) + +type Option func(cfg *config.Config, plugins *[]plugin.Plugin) + +func NoPlugins() Option { + return func(cfg *config.Config, plugins *[]plugin.Plugin) { + *plugins = nil + } +} + +func AddPlugin(p plugin.Plugin) Option { + return func(cfg *config.Config, plugins *[]plugin.Plugin) { + *plugins = append(*plugins, p) + } +} + +// PrependPlugin prepends plugin any existing plugins +func PrependPlugin(p plugin.Plugin) Option { + return func(cfg *config.Config, plugins *[]plugin.Plugin) { + *plugins = append([]plugin.Plugin{p}, *plugins...) + } +} + +// 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 0000000..b55064b --- /dev/null +++ b/api/option_test.go @@ -0,0 +1,69 @@ +package api + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/codegen/config" + "github.com/niko0xdev/gqlgen/plugin" + "github.com/niko0xdev/gqlgen/plugin/federation" + "github.com/niko0xdev/gqlgen/plugin/modelgen" + "github.com/niko0xdev/gqlgen/plugin/resolvergen" +) + +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(1), + modelgen.New(), + resolvergen.New(), + } + + expectedPlugin := &testPlugin{} + ReplacePlugin(expectedPlugin)(config.DefaultConfig(), &pg) + + require.EqualValues(t, federation.New(1), 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(1), + resolvergen.New(), + } + + expectedPlugin := &testPlugin{} + ReplacePlugin(expectedPlugin)(config.DefaultConfig(), &pg) + + require.EqualValues(t, federation.New(1), pg[0]) + require.EqualValues(t, resolvergen.New(), pg[1]) + require.EqualValues(t, expectedPlugin, pg[2]) + }) +} + +func TestPrependPlugin(t *testing.T) { + modelgenPlugin := modelgen.New() + pg := []plugin.Plugin{ + modelgenPlugin, + } + + expectedPlugin := &testPlugin{} + PrependPlugin(expectedPlugin)(config.DefaultConfig(), &pg) + + require.EqualValues(t, expectedPlugin, pg[0]) + require.EqualValues(t, modelgenPlugin, pg[1]) +} diff --git a/api/testdata/default/gqlgen.yml b/api/testdata/default/gqlgen.yml new file mode 100644 index 0000000..586eb79 --- /dev/null +++ b/api/testdata/default/gqlgen.yml @@ -0,0 +1,69 @@ +# Where are all the schema files located? globs are supported eg src/**/*.graphqls +schema: + - graph/*.graphqls + +# Where should the generated server code go? +exec: + filename: graph/generated.go + package: graph + +# Uncomment to enable federation +# federation: +# filename: graph/federation.go +# package: graph + +# Where should any generated models go? +model: + filename: graph/model/models_gen.go + package: model + +# Where should the resolver implementations go? +resolver: + layout: follow-schema + dir: graph + package: graph + +# Optional: turn on use `gqlgen:"fieldName"` tags in your models +# struct_tag: json + +# Optional: turn on to use []Thing instead of []*Thing +# omit_slice_element_pointers: false + +# Optional: turn off to make struct-type struct fields not use pointers +# e.g. type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing } +# struct_fields_always_pointers: true + +# Optional: turn off to make resolvers return values instead of pointers for structs +# resolvers_always_return_pointers: true + +# Optional: turn on to return pointers instead of values in unmarshalInput +# return_pointers_in_unmarshalinput: false + +# Optional: wrap nullable input fields with Omittable +# nullable_input_omittable: true + +# Optional: set to speed up generation time by not performing a final validation pass. +# skip_validation: 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: + - "github.com/niko0xdev/gqlgen/api/testdata/default/graph/model" + +# This section declares type mapping between the GraphQL and go type systems +# +# The first line in each type will be used as defaults for resolver arguments and +# modelgen, the others will be allowed when binding to fields. Configure them to +# your liking +models: + ID: + model: + - github.com/niko0xdev/gqlgen/graphql.ID + - github.com/niko0xdev/gqlgen/graphql.Int + - github.com/niko0xdev/gqlgen/graphql.Int64 + - github.com/niko0xdev/gqlgen/graphql.Int32 + Int: + model: + - github.com/niko0xdev/gqlgen/graphql.Int + - github.com/niko0xdev/gqlgen/graphql.Int64 + - github.com/niko0xdev/gqlgen/graphql.Int32 diff --git a/api/testdata/default/graph/generated.go b/api/testdata/default/graph/generated.go new file mode 100644 index 0000000..e0e8a8c --- /dev/null +++ b/api/testdata/default/graph/generated.go @@ -0,0 +1,3844 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package graph + +import ( + "bytes" + "context" + "embed" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/api/testdata/default/graph/model" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Mutation() MutationResolver + Query() QueryResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + Mutation struct { + CreateTodo func(childComplexity int, input model.NewTodo) int + } + + Query struct { + Todos func(childComplexity int) int + } + + Todo struct { + Done func(childComplexity int) int + ID func(childComplexity int) int + Text func(childComplexity int) int + User func(childComplexity int) int + } + + User struct { + ID func(childComplexity int) int + Name func(childComplexity int) int + } +} + +type MutationResolver interface { + CreateTodo(ctx context.Context, input model.NewTodo) (*model.Todo, error) +} +type QueryResolver interface { + Todos(ctx context.Context) ([]*model.Todo, error) +} + +type executableSchema struct { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = ec + switch typeName + "." + field { + + case "Mutation.createTodo": + if e.complexity.Mutation.CreateTodo == nil { + break + } + + args, err := ec.field_Mutation_createTodo_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.CreateTodo(childComplexity, args["input"].(model.NewTodo)), true + + case "Query.todos": + if e.complexity.Query.Todos == nil { + break + } + + return e.complexity.Query.Todos(childComplexity), true + + case "Todo.done": + if e.complexity.Todo.Done == nil { + break + } + + return e.complexity.Todo.Done(childComplexity), true + + case "Todo.id": + if e.complexity.Todo.ID == nil { + break + } + + return e.complexity.Todo.ID(childComplexity), true + + case "Todo.text": + if e.complexity.Todo.Text == nil { + break + } + + return e.complexity.Todo.Text(childComplexity), true + + case "Todo.user": + if e.complexity.Todo.User == nil { + break + } + + return e.complexity.Todo.User(childComplexity), true + + case "User.id": + if e.complexity.User.ID == nil { + break + } + + return e.complexity.User.ID(childComplexity), true + + case "User.name": + if e.complexity.User.Name == nil { + break + } + + return e.complexity.User.Name(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap( + ec.unmarshalInputNewTodo, + ) + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + case ast.Mutation: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data := ec._Mutation(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + 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 + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + +//go:embed "schema.graphqls" +var sourcesFS embed.FS + +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) +} + +var sources = []*ast.Source{ + {Name: "schema.graphqls", Input: sourceData("schema.graphqls"), BuiltIn: false}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (ec *executionContext) field_Mutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.NewTodo + if tmp, ok := rawArgs["input"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) + arg0, err = ec.unmarshalNNewTodo2githubᚗcomᚋniko0xdevᚋgqlgenᚋapiᚋtestdataᚋdefaultᚋgraphᚋmodelᚐNewTodo(ctx, tmp) + if err != nil { + return nil, err + } + } + args["input"] = arg0 + return args, nil +} + +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___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) _Mutation_createTodo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createTodo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateTodo(rctx, fc.Args["input"].(model.NewTodo)) + }) + 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.Todo) + fc.Result = res + return ec.marshalNTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋapiᚋtestdataᚋdefaultᚋgraphᚋmodelᚐTodo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_createTodo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Todo_id(ctx, field) + case "text": + return ec.fieldContext_Todo_text(ctx, field) + case "done": + return ec.fieldContext_Todo_done(ctx, field) + case "user": + return ec.fieldContext_Todo_user(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_createTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_todos(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Todos(rctx) + }) + 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.Todo) + fc.Result = res + return ec.marshalNTodo2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋapiᚋtestdataᚋdefaultᚋgraphᚋmodelᚐTodoᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_todos(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Todo_id(ctx, field) + case "text": + return ec.fieldContext_Todo_text(ctx, field) + case "done": + return ec.fieldContext_Todo_done(ctx, field) + case "user": + return ec.fieldContext_Todo_user(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Todo_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_text(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Text, 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) fieldContext_Todo_text(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_done(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Done, 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) fieldContext_Todo_done(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_user(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.User, 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.User) + fc.Result = res + return ec.marshalNUser2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋapiᚋtestdataᚋdefaultᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Todo_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_User_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), 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.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), 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.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), 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.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputNewTodo(ctx context.Context, obj interface{}) (model.NewTodo, error) { + var it model.NewTodo + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"text", "userId"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "text": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Text = data + case "userId": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userId")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.UserID = data + } + } + + return it, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +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) + deferred := make(map[string]*graphql.FieldSet) + 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.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_createTodo(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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 + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_todos(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var todoImplementors = []string{"Todo"} + +func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *model.Todo) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, todoImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Todo") + case "id": + out.Values[i] = ec._Todo_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "text": + out.Values[i] = ec._Todo_text(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "done": + out.Values[i] = ec._Todo_done(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "user": + out.Values[i] = ec._Todo_user(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("User") + case "id": + out.Values[i] = ec._User_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec._User_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNNewTodo2githubᚗcomᚋniko0xdevᚋgqlgenᚋapiᚋtestdataᚋdefaultᚋgraphᚋmodelᚐNewTodo(ctx context.Context, v interface{}) (model.NewTodo, error) { + res, err := ec.unmarshalInputNewTodo(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNTodo2githubᚗcomᚋniko0xdevᚋgqlgenᚋapiᚋtestdataᚋdefaultᚋgraphᚋmodelᚐTodo(ctx context.Context, sel ast.SelectionSet, v model.Todo) graphql.Marshaler { + return ec._Todo(ctx, sel, &v) +} + +func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋapiᚋtestdataᚋdefaultᚋgraphᚋmodelᚐTodoᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Todo) 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.marshalNTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋapiᚋtestdataᚋdefaultᚋgraphᚋmodelᚐTodo(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) marshalNTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋapiᚋtestdataᚋdefaultᚋgraphᚋmodelᚐTodo(ctx context.Context, sel ast.SelectionSet, v *model.Todo) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Todo(ctx, sel, v) +} + +func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋapiᚋtestdataᚋdefaultᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._User(ctx, sel, v) +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + 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) 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) marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/api/testdata/default/graph/model/doc.go b/api/testdata/default/graph/model/doc.go new file mode 100644 index 0000000..8b53790 --- /dev/null +++ b/api/testdata/default/graph/model/doc.go @@ -0,0 +1 @@ +package model diff --git a/api/testdata/default/graph/schema.graphqls b/api/testdata/default/graph/schema.graphqls new file mode 100644 index 0000000..c6a91bb --- /dev/null +++ b/api/testdata/default/graph/schema.graphqls @@ -0,0 +1,28 @@ +# GraphQL schema example +# +# https://gqlgen.com/getting-started/ + +type Todo { + id: ID! + text: String! + done: Boolean! + user: User! +} + +type User { + id: ID! + name: String! +} + +type Query { + todos: [Todo!]! +} + +input NewTodo { + text: String! + userId: String! +} + +type Mutation { + createTodo(input: NewTodo!): Todo! +} diff --git a/api/testdata/federation2/gqlgen.yml b/api/testdata/federation2/gqlgen.yml new file mode 100644 index 0000000..cde1e68 --- /dev/null +++ b/api/testdata/federation2/gqlgen.yml @@ -0,0 +1,69 @@ +# Where are all the schema files located? globs are supported eg src/**/*.graphqls +schema: + - graph/*.graphqls + +# Where should the generated server code go? +exec: + filename: graph/generated.go + package: graph + +# Uncomment to enable federation +federation: + filename: graph/federation.go + package: graph + +# Where should any generated models go? +model: + filename: graph/model/models_gen.go + package: model + +# Where should the resolver implementations go? +resolver: + layout: follow-schema + dir: graph + package: graph + +# Optional: turn on use `gqlgen:"fieldName"` tags in your models +# struct_tag: json + +# Optional: turn on to use []Thing instead of []*Thing +# omit_slice_element_pointers: false + +# Optional: turn off to make struct-type struct fields not use pointers +# e.g. type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing } +# struct_fields_always_pointers: true + +# Optional: turn off to make resolvers return values instead of pointers for structs +# resolvers_always_return_pointers: true + +# Optional: turn on to return pointers instead of values in unmarshalInput +# return_pointers_in_unmarshalinput: false + +# Optional: wrap nullable input fields with Omittable +# nullable_input_omittable: true + +# Optional: set to speed up generation time by not performing a final validation pass. +# skip_validation: 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: + - "github.com/niko0xdev/gqlgen/api/testdata/default/graph/model" + +# This section declares type mapping between the GraphQL and go type systems +# +# The first line in each type will be used as defaults for resolver arguments and +# modelgen, the others will be allowed when binding to fields. Configure them to +# your liking +models: + ID: + model: + - github.com/niko0xdev/gqlgen/graphql.ID + - github.com/niko0xdev/gqlgen/graphql.Int + - github.com/niko0xdev/gqlgen/graphql.Int64 + - github.com/niko0xdev/gqlgen/graphql.Int32 + Int: + model: + - github.com/niko0xdev/gqlgen/graphql.Int + - github.com/niko0xdev/gqlgen/graphql.Int64 + - github.com/niko0xdev/gqlgen/graphql.Int32 diff --git a/api/testdata/federation2/graph/federation.go b/api/testdata/federation2/graph/federation.go new file mode 100644 index 0000000..c52c0a8 --- /dev/null +++ b/api/testdata/federation2/graph/federation.go @@ -0,0 +1,35 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package graph + +import ( + "context" + "errors" + "strings" + + "github.com/niko0xdev/gqlgen/plugin/federation/fedruntime" +) + +var ( + ErrUnknownType = errors.New("unknown type") + ErrTypeNotFound = errors.New("type not found") +) + +func (ec *executionContext) __resolve__service(ctx context.Context) (fedruntime.Service, error) { + if ec.DisableIntrospection { + return fedruntime.Service{}, errors.New("federated introspection disabled") + } + + var sdl []string + + for _, src := range sources { + if src.BuiltIn { + continue + } + sdl = append(sdl, src.Input) + } + + return fedruntime.Service{ + SDL: strings.Join(sdl, "\n"), + }, nil +} diff --git a/api/testdata/federation2/graph/generated.go b/api/testdata/federation2/graph/generated.go new file mode 100644 index 0000000..f43579c --- /dev/null +++ b/api/testdata/federation2/graph/generated.go @@ -0,0 +1,4210 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package graph + +import ( + "bytes" + "context" + "embed" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/api/testdata/federation2/graph/model" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + "github.com/niko0xdev/gqlgen/plugin/federation/fedruntime" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Mutation() MutationResolver + Query() QueryResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + Mutation struct { + CreateTodo func(childComplexity int, input model.NewTodo) int + } + + Query struct { + Todos func(childComplexity int) int + __resolve__service func(childComplexity int) int + } + + Todo struct { + Done func(childComplexity int) int + ID func(childComplexity int) int + Text func(childComplexity int) int + User func(childComplexity int) int + } + + User struct { + ID func(childComplexity int) int + Name func(childComplexity int) int + } + + _Service struct { + SDL func(childComplexity int) int + } +} + +type MutationResolver interface { + CreateTodo(ctx context.Context, input model.NewTodo) (*model.Todo, error) +} +type QueryResolver interface { + Todos(ctx context.Context) ([]*model.Todo, error) +} + +type executableSchema struct { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = ec + switch typeName + "." + field { + + case "Mutation.createTodo": + if e.complexity.Mutation.CreateTodo == nil { + break + } + + args, err := ec.field_Mutation_createTodo_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.CreateTodo(childComplexity, args["input"].(model.NewTodo)), true + + case "Query.todos": + if e.complexity.Query.Todos == nil { + break + } + + return e.complexity.Query.Todos(childComplexity), true + + case "Query._service": + if e.complexity.Query.__resolve__service == nil { + break + } + + return e.complexity.Query.__resolve__service(childComplexity), true + + case "Todo.done": + if e.complexity.Todo.Done == nil { + break + } + + return e.complexity.Todo.Done(childComplexity), true + + case "Todo.id": + if e.complexity.Todo.ID == nil { + break + } + + return e.complexity.Todo.ID(childComplexity), true + + case "Todo.text": + if e.complexity.Todo.Text == nil { + break + } + + return e.complexity.Todo.Text(childComplexity), true + + case "Todo.user": + if e.complexity.Todo.User == nil { + break + } + + return e.complexity.Todo.User(childComplexity), true + + case "User.id": + if e.complexity.User.ID == nil { + break + } + + return e.complexity.User.ID(childComplexity), true + + case "User.name": + if e.complexity.User.Name == nil { + break + } + + return e.complexity.User.Name(childComplexity), true + + case "_Service.sdl": + if e.complexity._Service.SDL == nil { + break + } + + return e.complexity._Service.SDL(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap( + ec.unmarshalInputNewTodo, + ) + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + case ast.Mutation: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data := ec._Mutation(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + 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 + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + +//go:embed "schema.graphqls" +var sourcesFS embed.FS + +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) +} + +var sources = []*ast.Source{ + {Name: "schema.graphqls", Input: sourceData("schema.graphqls"), BuiltIn: false}, + {Name: "../federation/directives.graphql", Input: ` + directive @authenticated on FIELD_DEFINITION | OBJECT | INTERFACE | SCALAR | ENUM + directive @composeDirective(name: String!) repeatable on SCHEMA + directive @extends on OBJECT | INTERFACE + directive @external on OBJECT | FIELD_DEFINITION + directive @key(fields: FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE + directive @inaccessible on + | ARGUMENT_DEFINITION + | ENUM + | ENUM_VALUE + | FIELD_DEFINITION + | INPUT_FIELD_DEFINITION + | INPUT_OBJECT + | INTERFACE + | OBJECT + | SCALAR + | UNION + directive @interfaceObject on OBJECT + directive @link(import: [String!], url: String!) repeatable on SCHEMA + directive @override(from: String!) on FIELD_DEFINITION + directive @provides(fields: FieldSet!) on FIELD_DEFINITION + directive @requires(fields: FieldSet!) on FIELD_DEFINITION + directive @requiresScopes(scopes: [[federation__Scope!]!]!) on + | FIELD_DEFINITION + | OBJECT + | INTERFACE + | SCALAR + | ENUM + directive @shareable repeatable on FIELD_DEFINITION | OBJECT + directive @tag(name: String!) repeatable on + | ARGUMENT_DEFINITION + | ENUM + | ENUM_VALUE + | FIELD_DEFINITION + | INPUT_FIELD_DEFINITION + | INPUT_OBJECT + | INTERFACE + | OBJECT + | SCALAR + | UNION + scalar _Any + scalar FieldSet + scalar federation__Scope +`, BuiltIn: true}, + {Name: "../federation/entity.graphql", Input: ` +type _Service { + sdl: String +} + +extend type Query { + _service: _Service! +} +`, BuiltIn: true}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (ec *executionContext) field_Mutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.NewTodo + if tmp, ok := rawArgs["input"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) + arg0, err = ec.unmarshalNNewTodo2githubᚗcomᚋniko0xdevᚋgqlgenᚋapiᚋtestdataᚋfederation2ᚋgraphᚋmodelᚐNewTodo(ctx, tmp) + if err != nil { + return nil, err + } + } + args["input"] = arg0 + return args, nil +} + +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___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) _Mutation_createTodo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createTodo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateTodo(rctx, fc.Args["input"].(model.NewTodo)) + }) + 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.Todo) + fc.Result = res + return ec.marshalNTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋapiᚋtestdataᚋfederation2ᚋgraphᚋmodelᚐTodo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_createTodo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Todo_id(ctx, field) + case "text": + return ec.fieldContext_Todo_text(ctx, field) + case "done": + return ec.fieldContext_Todo_done(ctx, field) + case "user": + return ec.fieldContext_Todo_user(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_createTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_todos(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Todos(rctx) + }) + 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.Todo) + fc.Result = res + return ec.marshalNTodo2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋapiᚋtestdataᚋfederation2ᚋgraphᚋmodelᚐTodoᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_todos(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Todo_id(ctx, field) + case "text": + return ec.fieldContext_Todo_text(ctx, field) + case "done": + return ec.fieldContext_Todo_done(ctx, field) + case "user": + return ec.fieldContext_Todo_user(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query__service(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query__service(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.__resolve__service(ctx) + }) + 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.(fedruntime.Service) + fc.Result = res + return ec.marshalN_Service2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query__service(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "sdl": + return ec.fieldContext__Service_sdl(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type _Service", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Todo_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_text(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Text, 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) fieldContext_Todo_text(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_done(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Done, 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) fieldContext_Todo_done(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Todo_user(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.User, 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.User) + fc.Result = res + return ec.marshalNUser2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋapiᚋtestdataᚋfederation2ᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Todo_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Todo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_User_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) __Service_sdl(ctx context.Context, field graphql.CollectedField, obj *fedruntime.Service) (ret graphql.Marshaler) { + fc, err := ec.fieldContext__Service_sdl(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SDL, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalOString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext__Service_sdl(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "_Service", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), 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.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), 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.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), 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.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputNewTodo(ctx context.Context, obj interface{}) (model.NewTodo, error) { + var it model.NewTodo + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"text", "userId"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "text": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Text = data + case "userId": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userId")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.UserID = data + } + } + + return it, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +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) + deferred := make(map[string]*graphql.FieldSet) + 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.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_createTodo(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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 + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_todos(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "_service": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query__service(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var todoImplementors = []string{"Todo"} + +func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *model.Todo) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, todoImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Todo") + case "id": + out.Values[i] = ec._Todo_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "text": + out.Values[i] = ec._Todo_text(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "done": + out.Values[i] = ec._Todo_done(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "user": + out.Values[i] = ec._Todo_user(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("User") + case "id": + out.Values[i] = ec._User_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec._User_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("_Service") + case "sdl": + out.Values[i] = ec.__Service_sdl(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNFieldSet2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNFieldSet2string(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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNNewTodo2githubᚗcomᚋniko0xdevᚋgqlgenᚋapiᚋtestdataᚋfederation2ᚋgraphᚋmodelᚐNewTodo(ctx context.Context, v interface{}) (model.NewTodo, error) { + res, err := ec.unmarshalInputNewTodo(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNTodo2githubᚗcomᚋniko0xdevᚋgqlgenᚋapiᚋtestdataᚋfederation2ᚋgraphᚋmodelᚐTodo(ctx context.Context, sel ast.SelectionSet, v model.Todo) graphql.Marshaler { + return ec._Todo(ctx, sel, &v) +} + +func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋapiᚋtestdataᚋfederation2ᚋgraphᚋmodelᚐTodoᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Todo) 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.marshalNTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋapiᚋtestdataᚋfederation2ᚋgraphᚋmodelᚐTodo(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) marshalNTodo2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋapiᚋtestdataᚋfederation2ᚋgraphᚋmodelᚐTodo(ctx context.Context, sel ast.SelectionSet, v *model.Todo) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Todo(ctx, sel, v) +} + +func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋapiᚋtestdataᚋfederation2ᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._User(ctx, sel, v) +} + +func (ec *executionContext) marshalN_Service2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx context.Context, sel ast.SelectionSet, v fedruntime.Service) graphql.Marshaler { + return ec.__Service(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNfederation__Scope2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNfederation__Scope2string(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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNfederation__Scope2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNfederation__Scope2string(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalNfederation__Scope2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNfederation__Scope2string(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) unmarshalNfederation__Scope2ᚕᚕstringᚄ(ctx context.Context, v interface{}) ([][]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([][]string, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNfederation__Scope2ᚕstringᚄ(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalNfederation__Scope2ᚕᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v [][]string) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNfederation__Scope2ᚕstringᚄ(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +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) 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 { + vSlice = graphql.CoerceList(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 + } + 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) marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/api/testdata/federation2/graph/model/doc.go b/api/testdata/federation2/graph/model/doc.go new file mode 100644 index 0000000..8b53790 --- /dev/null +++ b/api/testdata/federation2/graph/model/doc.go @@ -0,0 +1 @@ +package model diff --git a/api/testdata/federation2/graph/schema.graphqls b/api/testdata/federation2/graph/schema.graphqls new file mode 100644 index 0000000..8ecdde8 --- /dev/null +++ b/api/testdata/federation2/graph/schema.graphqls @@ -0,0 +1,31 @@ +# GraphQL schema example +# +# https://gqlgen.com/getting-started/ +extend schema + @link(url: "https://specs.apollo.dev/federation/v2.0", + import: ["@key", "@shareable", "@provides", "@external", "@tag", "@extends", "@override", "@inaccessible"]) + +type Todo { + id: ID! + text: String! + done: Boolean! + user: User! +} + +type User { + id: ID! + name: String! +} + +type Query { + todos: [Todo!]! +} + +input NewTodo { + text: String! + userId: String! +} + +type Mutation { + createTodo(input: NewTodo!): Todo! +} diff --git a/bin/release b/bin/release new file mode 100755 index 0000000..69b8b07 --- /dev/null +++ b/bin/release @@ -0,0 +1,51 @@ +#!/bin/bash + +set -eu + +if ! [ $# -eq 1 ] ; then + echo "usage: ./bin/release [version]" + exit 1 +fi + +VERSION=$1 + +if ! git diff-index --quiet HEAD -- ; then + echo "uncommited changes on HEAD, aborting" + exit 1 +fi + +if [[ ${VERSION:0:1} != "v" ]] ; then + echo "version strings must start with v" + exit 1 +fi + +git fetch origin +git checkout origin/master + +cat > graphql/version.go < graphql/version.go <= http.StatusBadRequest { + return nil, fmt.Errorf("http %d: %s", w.Code, w.Body.String()) + } + + // decode it into map string first, let mapstructure do the final decode + // because it can be much stricter about unknown fields. + respDataRaw := &Response{} + err = json.Unmarshal(w.Body.Bytes(), &respDataRaw) + if err != nil { + return nil, fmt.Errorf("decode: %w", err) + } + + return respDataRaw, nil +} + +func (p *Client) newRequest(query string, options ...Option) (*http.Request, error) { + bd := &Request{ + Query: query, + HTTP: httptest.NewRequest(http.MethodPost, "/", nil), + } + bd.HTTP.Header.Set("Content-Type", "application/json") + + // per client options from client.New apply first + for _, option := range p.opts { + option(bd) + } + // per request options + for _, option := range options { + option(bd) + } + + 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: %w", err) + } + bd.HTTP.Body = io.NopCloser(bytes.NewBuffer(requestBody)) + default: + panic("unsupported encoding " + bd.HTTP.Header.Get("Content-Type")) + } + + return bd.HTTP, nil +} + +// SetCustomDecodeConfig sets a custom decode hook for the client +func (p *Client) SetCustomDecodeConfig(dc *mapstructure.DecoderConfig) { + p.dc = dc +} + +func unpack(data interface{}, into interface{}, customDc *mapstructure.DecoderConfig) error { + dc := &mapstructure.DecoderConfig{ + TagName: "json", + ErrorUnused: true, + ZeroFields: true, + } + if customDc != nil { + dc = customDc + } + dc.Result = into + + d, err := mapstructure.NewDecoder(dc) + if err != nil { + return fmt.Errorf("mapstructure: %w", err) + } + + return d.Decode(data) +} diff --git a/client/client_test.go b/client/client_test.go new file mode 100644 index 0000000..4ef59fc --- /dev/null +++ b/client/client_test.go @@ -0,0 +1,218 @@ +package client_test + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "mime/multipart" + "net/http" + "net/textproto" + "reflect" + "testing" + "time" + + "github.com/mitchellh/mapstructure" + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" +) + +func TestClient(t *testing.T) { + h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + b, err := io.ReadAll(r.Body) + if err != nil { + panic(err) + } + require.Equal(t, `{"query":"user(id:$id){name}","variables":{"id":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:$id){name}", &resp, client.Var("id", 1)) + + require.Equal(t, "bob", resp.Name) +} + +func TestClientMultipartFormData(t *testing.T) { + h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + bodyBytes, err := io.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 = io.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")) + + w.Write([]byte(`{}`)) + }) + + c := client.New(h) + + var resp struct{} + c.MustPost("{ id }", &resp, + client.AddHeader("Test-Key", "ASDF"), + ) +} + +func TestAddClientHeader(t *testing.T) { + h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + require.Equal(t, "ASDF", r.Header.Get("Test-Key")) + + w.Write([]byte(`{}`)) + }) + + c := client.New(h, client.AddHeader("Test-Key", "ASDF")) + + var resp struct{} + c.MustPost("{ id }", &resp) +} + +func TestBasicAuth(t *testing.T) { + h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + user, pass, ok := r.BasicAuth() + require.True(t, ok) + require.Equal(t, "user", user) + require.Equal(t, "pass", pass) + + w.Write([]byte(`{}`)) + }) + + c := client.New(h) + + var resp struct{} + c.MustPost("{ id }", &resp, + client.BasicAuth("user", "pass"), + ) +} + +func TestAddCookie(t *testing.T) { + h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + c, err := r.Cookie("foo") + require.NoError(t, err) + require.Equal(t, "value", c.Value) + + w.Write([]byte(`{}`)) + }) + + c := client.New(h) + + var resp struct{} + c.MustPost("{ id }", &resp, + 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 := io.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"}}), + ) +} + +func TestSetCustomDecodeConfig(t *testing.T) { + now := time.Now() + + h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + w.Header().Set("Content-Type", "application/json") + w.Write([]byte(fmt.Sprintf(`{"data": {"created_at":"%s"}}`, now.Format(time.RFC3339)))) + }) + + dc := &mapstructure.DecoderConfig{ + TagName: "json", + ErrorUnused: true, + ZeroFields: true, + DecodeHook: func(f reflect.Type, t reflect.Type, data interface{}) (interface{}, error) { + if t != reflect.TypeOf(time.Time{}) { + return data, nil + } + + switch f.Kind() { + case reflect.String: + return time.Parse(time.RFC3339, data.(string)) + default: + return data, nil + } + }, + } + + c := client.New(h) + + var resp struct { + CreatedAt time.Time `json:"created_at"` + } + + err := c.Post("user(id: 1) {created_at}", &resp) + require.Error(t, err) + + c.SetCustomDecodeConfig(dc) + + c.MustPost("user(id: 1) {created_at}", &resp) + require.WithinDuration(t, now, resp.CreatedAt, time.Second) +} diff --git a/client/errors.go b/client/errors.go new file mode 100644 index 0000000..7bbdd41 --- /dev/null +++ b/client/errors.go @@ -0,0 +1,12 @@ +package client + +import "encoding/json" + +// RawJsonError is a json formatted error from a GraphQL server. +type RawJsonError struct { + json.RawMessage +} + +func (r RawJsonError) Error() string { + return string(r.RawMessage) +} diff --git a/client/options.go b/client/options.go new file mode 100644 index 0000000..bf4280a --- /dev/null +++ b/client/options.go @@ -0,0 +1,57 @@ +package client + +import "net/http" + +// Var adds a variable into the outgoing request +func Var(name string, value interface{}) Option { + return func(bd *Request) { + if bd.Variables == nil { + bd.Variables = map[string]interface{}{} + } + + bd.Variables[name] = value + } +} + +// Operation sets the operation name for the outgoing request +func Operation(name string) Option { + return func(bd *Request) { + bd.OperationName = name + } +} + +// 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 { + return func(bd *Request) { + bd.HTTP.URL.Path = url + } +} + +// AddHeader adds a header to the outgoing request. This is useful for setting expected Authentication headers for example. +func AddHeader(key string, value string) Option { + return func(bd *Request) { + bd.HTTP.Header.Add(key, value) + } +} + +// BasicAuth authenticates the request using http basic auth. +func BasicAuth(username, password string) Option { + return func(bd *Request) { + bd.HTTP.SetBasicAuth(username, password) + } +} + +// AddCookie adds a cookie to the outgoing request +func AddCookie(cookie *http.Cookie) Option { + return func(bd *Request) { + bd.HTTP.AddCookie(cookie) + } +} diff --git a/client/readme.md b/client/readme.md new file mode 100644 index 0000000..755a143 --- /dev/null +++ b/client/readme.md @@ -0,0 +1,5 @@ +This client is used internally for testing. I wanted a simple graphql client sent user specified queries. + +You might want to look at: + - https://github.com/shurcooL/graphql: Uses reflection to build queries from structs. + - https://github.com/machinebox/graphql: Probably would have been a perfect fit, but it uses form encoding instead of json... diff --git a/client/sse.go b/client/sse.go new file mode 100644 index 0000000..a26c631 --- /dev/null +++ b/client/sse.go @@ -0,0 +1,105 @@ +package client + +import ( + "bufio" + "context" + "encoding/json" + "fmt" + "net/http/httptest" + "net/textproto" + "strings" +) + +type SSE struct { + Close func() error + Next func(response interface{}) error +} + +type SSEResponse struct { + Data interface{} `json:"data"` + Label string `json:"label"` + Path []interface{} `json:"path"` + HasNext bool `json:"hasNext"` + Errors json.RawMessage `json:"errors"` + Extensions map[string]interface{} `json:"extensions"` +} + +func errorSSE(err error) *SSE { + return &SSE{ + Close: func() error { return nil }, + Next: func(response interface{}) error { + return err + }, + } +} + +func (p *Client) SSE(ctx context.Context, query string, options ...Option) *SSE { + r, err := p.newRequest(query, options...) + if err != nil { + return errorSSE(fmt.Errorf("request: %w", err)) + } + r = r.WithContext(ctx) + + r.Header.Set("Accept", "text/event-stream") + r.Header.Set("Cache-Control", "no-cache") + r.Header.Set("Connection", "keep-alive") + + srv := httptest.NewServer(p.h) + w := httptest.NewRecorder() + p.h.ServeHTTP(w, r) + + reader := textproto.NewReader(bufio.NewReader(w.Body)) + line, err := reader.ReadLine() + if err != nil { + return errorSSE(fmt.Errorf("response: %w", err)) + } + if line != ":" { + return errorSSE(fmt.Errorf("expected :, got %s", line)) + } + + return &SSE{ + Close: func() error { + srv.Close() + return nil + }, + Next: func(response interface{}) error { + for { + line, err := reader.ReadLine() + if err != nil { + return err + } + kv := strings.SplitN(line, ": ", 2) + + switch kv[0] { + case "": + continue + case "event": + switch kv[1] { + case "next": + continue + case "complete": + return nil + default: + return fmt.Errorf("expected event type: %#v", kv[1]) + } + case "data": + var respDataRaw SSEResponse + if err = json.Unmarshal([]byte(kv[1]), &respDataRaw); err != nil { + return fmt.Errorf("decode: %w", err) + } + + // we want to unpack even if there is an error, so we can see partial responses + unpackErr := unpack(respDataRaw, response, p.dc) + + if respDataRaw.Errors != nil { + return RawJsonError{respDataRaw.Errors} + } + + return unpackErr + default: + return fmt.Errorf("unexpected sse field %s", kv[0]) + } + } + }, + } +} diff --git a/client/websocket.go b/client/websocket.go new file mode 100644 index 0000000..a54916b --- /dev/null +++ b/client/websocket.go @@ -0,0 +1,151 @@ +package client + +import ( + "encoding/json" + "fmt" + "io" + "net/http/httptest" + "reflect" + "strings" + + "github.com/gorilla/websocket" +) + +const ( + connectionInitMsg = "connection_init" // Client -> Server + startMsg = "start" // Client -> Server + connectionAckMsg = "connection_ack" // Server -> Client + connectionKaMsg = "ka" // Server -> Client + dataMsg = "data" // Server -> Client + errorMsg = "error" // Server -> Client +) + +type operationMessage struct { + Payload json.RawMessage `json:"payload,omitempty"` + ID string `json:"id,omitempty"` + Type string `json:"type"` +} + +type Subscription struct { + Close func() error + Next func(response interface{}) error +} + +func errorSubscription(err error) *Subscription { + return &Subscription{ + Close: func() error { return nil }, + Next: func(response interface{}) error { + return err + }, + } +} + +func (p *Client) Websocket(query string, options ...Option) *Subscription { + return p.WebsocketWithPayload(query, nil, options...) +} + +// Grab a single response from a websocket based query +func (p *Client) WebsocketOnce(query string, resp interface{}, options ...Option) error { + sock := p.Websocket(query, options...) + defer sock.Close() + if reflect.ValueOf(resp).Kind() == reflect.Ptr { + return sock.Next(resp) + } + // TODO: verify this is never called and remove it + return sock.Next(&resp) +} + +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: %w", err)) + } + + requestBody, err := io.ReadAll(r.Body) + if err != nil { + return errorSubscription(fmt.Errorf("parse body: %w", err)) + } + + srv := httptest.NewServer(p.h) + host := strings.ReplaceAll(srv.URL, "http://", "ws://") + c, resp, err := websocket.DefaultDialer.Dial(host+r.URL.Path, r.Header) + if err != nil { + return errorSubscription(fmt.Errorf("dial: %w", err)) + } + defer resp.Body.Close() + + initMessage := operationMessage{Type: connectionInitMsg} + if initPayload != nil { + initMessage.Payload, err = json.Marshal(initPayload) + if err != nil { + return errorSubscription(fmt.Errorf("parse payload: %w", err)) + } + } + + if err = c.WriteJSON(initMessage); err != nil { + return errorSubscription(fmt.Errorf("init: %w", err)) + } + + var ack operationMessage + if err = c.ReadJSON(&ack); err != nil { + return errorSubscription(fmt.Errorf("ack: %w", err)) + } + + if ack.Type != connectionAckMsg { + return errorSubscription(fmt.Errorf("expected ack message, got %#v", ack)) + } + + var ka operationMessage + if err = c.ReadJSON(&ka); err != nil { + return errorSubscription(fmt.Errorf("ack: %w", err)) + } + + if ka.Type != connectionKaMsg { + return errorSubscription(fmt.Errorf("expected ack message, got %#v", ack)) + } + + if err = c.WriteJSON(operationMessage{Type: startMsg, ID: "1", Payload: requestBody}); err != nil { + return errorSubscription(fmt.Errorf("start: %w", err)) + } + + return &Subscription{ + Close: func() error { + srv.Close() + return c.Close() + }, + Next: func(response interface{}) error { + for { + var op operationMessage + err := c.ReadJSON(&op) + if err != nil { + return err + } + + switch op.Type { + case dataMsg: + break + case connectionKaMsg: + continue + case errorMsg: + return fmt.Errorf(string(op.Payload)) + default: + return fmt.Errorf("expected data message, got %#v", op) + } + + var respDataRaw Response + err = json.Unmarshal(op.Payload, &respDataRaw) + if err != nil { + return fmt.Errorf("decode: %w", err) + } + + // we want to unpack even if there is an error, so we can see partial responses + unpackErr := unpack(respDataRaw.Data, response, p.dc) + + if respDataRaw.Errors != nil { + return RawJsonError{respDataRaw.Errors} + } + return unpackErr + } + }, + } +} diff --git a/client/withfilesoption.go b/client/withfilesoption.go new file mode 100644 index 0000000..55742b0 --- /dev/null +++ b/client/withfilesoption.go @@ -0,0 +1,133 @@ +package client + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "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, _ := os.ReadFile(fileData[0].file.Name()) + h.Set("Content-Type", http.DetectContentType(b)) + ff, _ := bodyWriter.CreatePart(h) + ff.Write(b) + } + bodyWriter.Close() + + bd.HTTP.Body = io.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 0000000..bfab66f --- /dev/null +++ b/client/withfilesoption_test.go @@ -0,0 +1,237 @@ +package client_test + +import ( + "io" + "mime" + "mime/multipart" + "net/http" + "os" + "regexp" + "strings" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" +) + +func TestWithFiles(t *testing.T) { + tempFile1, _ := os.CreateTemp(os.TempDir(), "tempFile1") + tempFile2, _ := os.CreateTemp(os.TempDir(), "tempFile2") + tempFile3, _ := os.CreateTemp(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 := io.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 := io.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 := io.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 := io.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/codegen/args.go b/codegen/args.go new file mode 100644 index 0000000..56c7199 --- /dev/null +++ b/codegen/args.go @@ -0,0 +1,123 @@ +package codegen + +import ( + "fmt" + "go/types" + "strings" + + "github.com/vektah/gqlparser/v2/ast" + + "github.com/niko0xdev/gqlgen/codegen/config" + "github.com/niko0xdev/gqlgen/codegen/templates" +) + +type ArgSet struct { + Args []*FieldArgument + FuncDecl string +} + +type FieldArgument struct { + *ast.ArgumentDefinition + TypeReference *config.TypeReference + VarName string // The name of the var in go + Object *Object // A link back to the parent object + Default interface{} // The default value + Directives []*Directive + Value interface{} // value set in Data +} + +// ImplDirectives get not Builtin and location ARGUMENT_DEFINITION directive +func (f *FieldArgument) ImplDirectives() []*Directive { + d := make([]*Directive, 0) + for i := range f.Directives { + if !f.Directives[i].Builtin && f.Directives[i].IsLocation(ast.LocationArgumentDefinition) { + d = append(d, f.Directives[i]) + } + } + + return d +} + +func (f *FieldArgument) DirectiveObjName() string { + return "rawArgs" +} + +func (f *FieldArgument) Stream() bool { + return f.Object != nil && f.Object.Stream +} + +func (b *builder) buildArg(obj *Object, arg *ast.ArgumentDefinition) (*FieldArgument, error) { + tr, err := b.Binder.TypeReference(arg.Type, nil) + if err != nil { + return nil, err + } + + argDirs, err := b.getDirectives(arg.Directives) + if err != nil { + return nil, err + } + newArg := FieldArgument{ + ArgumentDefinition: arg, + TypeReference: tr, + Object: obj, + VarName: templates.ToGoPrivate(arg.Name), + Directives: argDirs, + } + + if arg.DefaultValue != nil { + newArg.Default, err = arg.DefaultValue.Value(nil) + if err != nil { + return nil, fmt.Errorf("default value is not valid: %w", err) + } + } + + return &newArg, nil +} + +func (b *builder) bindArgs(field *Field, sig *types.Signature, params *types.Tuple) ([]*FieldArgument, error) { + n := params.Len() + newArgs := make([]*FieldArgument, 0, len(field.Args)) + // Accept variadic methods (i.e. have optional parameters). + if params.Len() > len(field.Args) && sig.Variadic() { + n = len(field.Args) + } +nextArg: + for j := 0; j < n; j++ { + param := params.At(j) + for _, oldArg := range field.Args { + if strings.EqualFold(oldArg.Name, param.Name()) { + tr, err := b.Binder.TypeReference(oldArg.Type, param.Type()) + if err != nil { + return nil, err + } + oldArg.TypeReference = tr + + newArgs = append(newArgs, oldArg) + continue nextArg + } + } + + // no matching arg found, abort + return nil, fmt.Errorf("arg %s not in schema", param.Name()) + } + + return newArgs, nil +} + +func (d *Data) Args() map[string][]*FieldArgument { + ret := map[string][]*FieldArgument{} + for _, o := range d.Objects { + for _, f := range o.Fields { + if len(f.Args) > 0 { + ret[f.ArgsFunc()] = f.Args + } + } + } + + for _, directive := range d.Directives() { + if len(directive.Args) > 0 { + ret[directive.ArgsFunc()] = directive.Args + } + } + return ret +} diff --git a/codegen/args.gotpl b/codegen/args.gotpl new file mode 100644 index 0000000..7b541ae --- /dev/null +++ b/codegen/args.gotpl @@ -0,0 +1,36 @@ +{{ range $name, $args := .Args }} +func (ec *executionContext) {{ $name }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + {{- range $i, $arg := . }} + var arg{{$i}} {{ $arg.TypeReference.GO | ref}} + if tmp, ok := rawArgs[{{$arg.Name|quote}}]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField({{$arg.Name|quote}})) + {{- if $arg.ImplDirectives }} + directive0 := func(ctx context.Context) (interface{}, error) { return ec.{{ $arg.TypeReference.UnmarshalFunc }}(ctx, tmp) } + {{ template "implDirectives" $arg }} + tmp, err = directive{{$arg.ImplDirectives|len}}(ctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.({{ $arg.TypeReference.GO | ref }}) ; ok { + arg{{$i}} = data + {{- if $arg.TypeReference.IsNilable }} + } else if tmp == nil { + arg{{$i}} = nil + {{- end }} + } else { + return nil, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be {{ $arg.TypeReference.GO }}`, tmp)) + } + {{- else }} + arg{{$i}}, err = ec.{{ $arg.TypeReference.UnmarshalFunc }}(ctx, tmp) + if err != nil { + return nil, err + } + {{- end }} + } + args[{{$arg.Name|quote}}] = arg{{$i}} + {{- end }} + return args, nil +} +{{ end }} diff --git a/codegen/complexity.go b/codegen/complexity.go new file mode 100644 index 0000000..e9c6a20 --- /dev/null +++ b/codegen/complexity.go @@ -0,0 +1,11 @@ +package codegen + +func (o *Object) UniqueFields() map[string][]*Field { + m := map[string][]*Field{} + + for _, f := range o.Fields { + m[f.GoFieldName] = append(m[f.GoFieldName], f) + } + + return m +} diff --git a/codegen/config/binder.go b/codegen/config/binder.go new file mode 100644 index 0000000..80806d5 --- /dev/null +++ b/codegen/config/binder.go @@ -0,0 +1,550 @@ +package config + +import ( + "errors" + "fmt" + "go/token" + "go/types" + + "github.com/vektah/gqlparser/v2/ast" + "golang.org/x/tools/go/packages" + + "github.com/niko0xdev/gqlgen/codegen/templates" + "github.com/niko0xdev/gqlgen/internal/code" +) + +var ErrTypeNotFound = errors.New("unable to find type") + +// Binder connects graphql types to golang types using static analysis +type Binder struct { + pkgs *code.Packages + schema *ast.Schema + cfg *Config + tctx *types.Context + References []*TypeReference + SawInvalid bool + objectCache map[string]map[string]types.Object +} + +func (c *Config) NewBinder() *Binder { + return &Binder{ + pkgs: c.Packages, + schema: c.Schema, + cfg: c, + } +} + +func (b *Binder) TypePosition(typ types.Type) token.Position { + named, isNamed := typ.(*types.Named) + if !isNamed { + return token.Position{ + Filename: "unknown", + } + } + + return b.ObjectPosition(named.Obj()) +} + +func (b *Binder) ObjectPosition(typ types.Object) token.Position { + if typ == nil { + return token.Position{ + Filename: "unknown", + } + } + pkg := b.pkgs.Load(typ.Pkg().Path()) + return pkg.Fset.Position(typ.Pos()) +} + +func (b *Binder) FindTypeFromName(name string) (types.Type, error) { + pkgName, typeName := code.PkgAndType(name) + return b.FindType(pkgName, typeName) +} + +func (b *Binder) FindType(pkgName string, typeName string) (types.Type, error) { + if pkgName == "" { + if typeName == "map[string]interface{}" { + return MapType, nil + } + + if typeName == "interface{}" { + return InterfaceType, nil + } + } + + obj, err := b.FindObject(pkgName, typeName) + if err != nil { + return nil, err + } + + if fun, isFunc := obj.(*types.Func); isFunc { + return fun.Type().(*types.Signature).Params().At(0).Type(), nil + } + return obj.Type(), nil +} + +func (b *Binder) InstantiateType(orig types.Type, targs []types.Type) (types.Type, error) { + if b.tctx == nil { + b.tctx = types.NewContext() + } + + return types.Instantiate(b.tctx, orig, targs, false) +} + +var ( + MapType = types.NewMap(types.Typ[types.String], types.NewInterfaceType(nil, nil).Complete()) + InterfaceType = types.NewInterfaceType(nil, nil) +) + +func (b *Binder) DefaultUserObject(name string) (types.Type, error) { + models := b.cfg.Models[name].Model + if len(models) == 0 { + return nil, fmt.Errorf(name + " not found in typemap") + } + + if models[0] == "map[string]interface{}" { + return MapType, nil + } + + if models[0] == "interface{}" { + return InterfaceType, nil + } + + pkgName, typeName := code.PkgAndType(models[0]) + if pkgName == "" { + return nil, fmt.Errorf("missing package name for %s", name) + } + + obj, err := b.FindObject(pkgName, typeName) + if err != nil { + return nil, err + } + + return obj.Type(), nil +} + +func (b *Binder) FindObject(pkgName string, typeName string) (types.Object, error) { + if pkgName == "" { + return nil, fmt.Errorf("package cannot be nil") + } + + pkg := b.pkgs.LoadWithTypes(pkgName) + if pkg == nil { + err := b.pkgs.Errors() + if err != nil { + return nil, fmt.Errorf("package could not be loaded: %s.%s: %w", pkgName, typeName, err) + } + return nil, fmt.Errorf("required package was not loaded: %s.%s", pkgName, typeName) + } + + if b.objectCache == nil { + b.objectCache = make(map[string]map[string]types.Object, b.pkgs.Count()) + } + + defsIndex, ok := b.objectCache[pkgName] + if !ok { + defsIndex = indexDefs(pkg) + b.objectCache[pkgName] = defsIndex + } + + // function based marshalers take precedence + if val, ok := defsIndex["Marshal"+typeName]; ok { + return val, nil + } + + if val, ok := defsIndex[typeName]; ok { + return val, nil + } + + return nil, fmt.Errorf("%w: %s.%s", ErrTypeNotFound, pkgName, typeName) +} + +func indexDefs(pkg *packages.Package) map[string]types.Object { + res := make(map[string]types.Object) + + scope := pkg.Types.Scope() + for astNode, def := range pkg.TypesInfo.Defs { + // only look at defs in the top scope + if def == nil { + continue + } + parent := def.Parent() + if parent == nil || parent != scope { + continue + } + + if _, ok := res[astNode.Name]; !ok { + // The above check may not be really needed, it is only here to have a consistent behavior with + // previous implementation of FindObject() function which only honored the first inclusion of a def. + // If this is still needed, we can consider something like sync.Map.LoadOrStore() to avoid two lookups. + res[astNode.Name] = def + } + } + + return res +} + +func (b *Binder) PointerTo(ref *TypeReference) *TypeReference { + 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. +type TypeReference struct { + Definition *ast.Definition + GQL *ast.Type + GO types.Type // Type of the field being bound. Could be a pointer or a value type of Target. + Target types.Type // The actual type that we know how to bind to. May require pointer juggling when traversing to fields. + CastType types.Type // Before calling marshalling functions cast from/to this base type + 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 + IsOmittable bool // Is the type wrapped with Omittable + IsContext bool // Is the Marshaler/Unmarshaller the context version; applies to either the method or interface variety. + PointersInUmarshalInput bool // Inverse values and pointers in return. + IsRoot bool // Is the type a root level definition such as Query, Mutation or Subscription +} + +func (ref *TypeReference) Elem() *TypeReference { + if p, isPtr := ref.GO.(*types.Pointer); isPtr { + newRef := *ref + newRef.GO = p.Elem() + return &newRef + } + + if ref.IsSlice() { + newRef := *ref + newRef.GO = ref.GO.(*types.Slice).Elem() + newRef.GQL = ref.GQL.Elem + return &newRef + } + return nil +} + +func (ref *TypeReference) IsPtr() bool { + _, isPtr := ref.GO.(*types.Pointer) + return isPtr +} + +// fix for https://github.com/golang/go/issues/31103 may make it possible to remove this (may still be useful) +func (ref *TypeReference) IsPtrToPtr() bool { + if p, isPtr := ref.GO.(*types.Pointer); isPtr { + _, isPtr := p.Elem().(*types.Pointer) + return isPtr + } + return false +} + +func (ref *TypeReference) IsNilable() bool { + return IsNilable(ref.GO) +} + +func (ref *TypeReference) IsSlice() bool { + _, isSlice := ref.GO.(*types.Slice) + return ref.GQL.Elem != nil && isSlice +} + +func (ref *TypeReference) IsPtrToSlice() bool { + if ref.IsPtr() { + _, isPointerToSlice := ref.GO.(*types.Pointer).Elem().(*types.Slice) + return isPointerToSlice + } + return false +} + +func (ref *TypeReference) IsPtrToIntf() bool { + if ref.IsPtr() { + _, isPointerToInterface := ref.GO.(*types.Pointer).Elem().(*types.Interface) + return isPointerToInterface + } + return false +} + +func (ref *TypeReference) IsNamed() bool { + _, isSlice := ref.GO.(*types.Named) + return isSlice +} + +func (ref *TypeReference) IsStruct() bool { + _, isStruct := ref.GO.Underlying().(*types.Struct) + return isStruct +} + +func (ref *TypeReference) IsScalar() bool { + return ref.Definition.Kind == ast.Scalar +} + +func (ref *TypeReference) IsMap() bool { + return ref.GO == MapType +} + +func (ref *TypeReference) UniquenessKey() string { + nullability := "O" + if ref.GQL.NonNull { + nullability = "N" + } + + elemNullability := "" + if ref.GQL.Elem != nil && ref.GQL.Elem.NonNull { + // Fix for #896 + elemNullability = "ᚄ" + } + return nullability + ref.Definition.Name + "2" + templates.TypeIdentifier(ref.GO) + elemNullability +} + +func (ref *TypeReference) MarshalFunc() string { + if ref.Definition == nil { + panic(errors.New("Definition missing for " + ref.GQL.Name())) + } + + if ref.Definition.Kind == ast.InputObject { + return "" + } + + return "marshal" + ref.UniquenessKey() +} + +func (ref *TypeReference) UnmarshalFunc() string { + if ref.Definition == nil { + panic(errors.New("Definition missing for " + ref.GQL.Name())) + } + + if !ref.Definition.IsInputType() { + return "" + } + + return "unmarshal" + ref.UniquenessKey() +} + +func (ref *TypeReference) IsTargetNilable() bool { + return IsNilable(ref.Target) +} + +func (b *Binder) PushRef(ret *TypeReference) { + b.References = append(b.References, ret) +} + +func isMap(t types.Type) bool { + if t == nil { + return true + } + _, ok := t.(*types.Map) + return ok +} + +func isIntf(t types.Type) bool { + if t == nil { + return true + } + _, ok := t.(*types.Interface) + return ok +} + +func unwrapOmittable(t types.Type) (types.Type, bool) { + if t == nil { + return t, false + } + named, ok := t.(*types.Named) + if !ok { + return t, false + } + if named.Origin().String() != "github.com/niko0xdev/gqlgen/graphql.Omittable[T any]" { + return t, false + } + return named.TypeArgs().At(0), true +} + +func (b *Binder) TypeReference(schemaType *ast.Type, bindTarget types.Type) (ret *TypeReference, err error) { + if innerType, ok := unwrapOmittable(bindTarget); ok { + if schemaType.NonNull { + return nil, fmt.Errorf("%s is wrapped with Omittable but non-null", schemaType.Name()) + } + + ref, err := b.TypeReference(schemaType, innerType) + if err != nil { + return nil, err + } + + ref.IsOmittable = true + return ref, err + } + + if !isValid(bindTarget) { + b.SawInvalid = true + return nil, fmt.Errorf("%s has an invalid type", schemaType.Name()) + } + + var pkgName, typeName string + def := b.schema.Types[schemaType.Name()] + defer func() { + if err == nil && ret != nil { + b.PushRef(ret) + } + }() + + if len(b.cfg.Models[schemaType.Name()].Model) == 0 { + return nil, fmt.Errorf("%s was not found", schemaType.Name()) + } + + for _, model := range b.cfg.Models[schemaType.Name()].Model { + if model == "map[string]interface{}" { + if !isMap(bindTarget) { + continue + } + return &TypeReference{ + Definition: def, + GQL: schemaType, + GO: MapType, + IsRoot: b.cfg.IsRoot(def), + }, nil + } + + if model == "interface{}" { + if !isIntf(bindTarget) { + continue + } + return &TypeReference{ + Definition: def, + GQL: schemaType, + GO: InterfaceType, + IsRoot: b.cfg.IsRoot(def), + }, nil + } + + pkgName, typeName = code.PkgAndType(model) + if pkgName == "" { + return nil, fmt.Errorf("missing package name for %s", schemaType.Name()) + } + + ref := &TypeReference{ + Definition: def, + GQL: schemaType, + IsRoot: b.cfg.IsRoot(def), + } + + obj, err := b.FindObject(pkgName, typeName) + if err != nil { + return nil, err + } + + 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/niko0xdev/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 + } else if underlying := basicUnderlying(obj.Type()); def.IsLeafType() && underlying != nil && underlying.Kind() == types.String { + // TODO delete before v1. Backwards compatibility case for named types wrapping strings (see #595) + + ref.GO = obj.Type() + ref.CastType = underlying + + underlyingRef, err := b.TypeReference(&ast.Type{NamedType: "String"}, nil) + if err != nil { + return nil, err + } + + ref.Marshaler = underlyingRef.Marshaler + ref.Unmarshaler = underlyingRef.Unmarshaler + } else { + ref.GO = obj.Type() + } + + ref.Target = ref.GO + ref.GO = b.CopyModifiersFromAst(schemaType, ref.GO) + + if bindTarget != nil { + if err = code.CompatibleTypes(ref.GO, bindTarget); err != nil { + continue + } + ref.GO = bindTarget + } + + ref.PointersInUmarshalInput = b.cfg.ReturnPointersInUmarshalInput + + return ref, nil + } + + return nil, fmt.Errorf("%s is incompatible with %s", schemaType.Name(), bindTarget.String()) +} + +func isValid(t types.Type) bool { + basic, isBasic := t.(*types.Basic) + if !isBasic { + return true + } + return basic.Kind() != types.Invalid +} + +func (b *Binder) CopyModifiersFromAst(t *ast.Type, base types.Type) types.Type { + if t.Elem != nil { + child := b.CopyModifiersFromAst(t.Elem, base) + if _, isStruct := child.Underlying().(*types.Struct); isStruct && !b.cfg.OmitSliceElementPointers { + child = types.NewPointer(child) + } + return types.NewSlice(child) + } + + var isInterface bool + if named, ok := base.(*types.Named); ok { + _, isInterface = named.Underlying().(*types.Interface) + } + + if !isInterface && !IsNilable(base) && !t.NonNull { + return types.NewPointer(base) + } + + return base +} + +func IsNilable(t types.Type) bool { + if namedType, isNamed := t.(*types.Named); isNamed { + return IsNilable(namedType.Underlying()) + } + _, isPtr := t.(*types.Pointer) + _, isMap := t.(*types.Map) + _, isInterface := t.(*types.Interface) + _, isSlice := t.(*types.Slice) + _, isChan := t.(*types.Chan) + return isPtr || isMap || isInterface || isSlice || isChan +} + +func hasMethod(it types.Type, name string) bool { + if ptr, isPtr := it.(*types.Pointer); isPtr { + it = ptr.Elem() + } + namedType, ok := it.(*types.Named) + if !ok { + return false + } + + for i := 0; i < namedType.NumMethods(); i++ { + if namedType.Method(i).Name() == name { + return true + } + } + return false +} + +func basicUnderlying(it types.Type) *types.Basic { + if ptr, isPtr := it.(*types.Pointer); isPtr { + it = ptr.Elem() + } + namedType, ok := it.(*types.Named) + if !ok { + return nil + } + + if basic, ok := namedType.Underlying().(*types.Basic); ok { + return basic + } + + return nil +} diff --git a/codegen/config/binder_test.go b/codegen/config/binder_test.go new file mode 100644 index 0000000..7ee9dfb --- /dev/null +++ b/codegen/config/binder_test.go @@ -0,0 +1,214 @@ +package config + +import ( + "go/types" + "testing" + + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" + + "github.com/niko0xdev/gqlgen/internal/code" +) + +func TestBindingToInvalid(t *testing.T) { + binder, schema := createBinder(Config{}) + _, err := binder.TypeReference(schema.Query.Fields.ForName("messages").Type, &types.Basic{}) + require.EqualError(t, err, "Message has an invalid type") +} + +func TestSlicePointerBinding(t *testing.T) { + t.Run("without OmitSliceElementPointers", func(t *testing.T) { + binder, schema := createBinder(Config{ + OmitSliceElementPointers: false, + }) + + ta, err := binder.TypeReference(schema.Query.Fields.ForName("messages").Type, nil) + if err != nil { + panic(err) + } + + require.Equal(t, ta.GO.String(), "[]*github.com/niko0xdev/gqlgen/codegen/config/testdata/autobinding/chat.Message") + }) + + t.Run("with OmitSliceElementPointers", func(t *testing.T) { + binder, schema := createBinder(Config{ + OmitSliceElementPointers: true, + }) + + ta, err := binder.TypeReference(schema.Query.Fields.ForName("messages").Type, nil) + if err != nil { + panic(err) + } + + require.Equal(t, ta.GO.String(), "[]github.com/niko0xdev/gqlgen/codegen/config/testdata/autobinding/chat.Message") + }) +} + +func TestOmittableBinding(t *testing.T) { + t.Run("bind nullable string with Omittable[string]", func(t *testing.T) { + binder, schema := createBinder(Config{}) + + ot, err := binder.FindType("github.com/niko0xdev/gqlgen/graphql", "Omittable") + if err != nil { + panic(err) + } + + it, err := binder.InstantiateType(ot, []types.Type{types.Universe.Lookup("string").Type()}) + if err != nil { + panic(err) + } + + ta, err := binder.TypeReference(schema.Types["FooInput"].Fields.ForName("nullableString").Type, it) + if err != nil { + panic(err) + } + + require.True(t, ta.IsOmittable) + }) + + t.Run("bind nullable string with Omittable[*string]", func(t *testing.T) { + binder, schema := createBinder(Config{}) + + ot, err := binder.FindType("github.com/niko0xdev/gqlgen/graphql", "Omittable") + if err != nil { + panic(err) + } + + it, err := binder.InstantiateType(ot, []types.Type{types.NewPointer(types.Universe.Lookup("string").Type())}) + if err != nil { + panic(err) + } + + ta, err := binder.TypeReference(schema.Types["FooInput"].Fields.ForName("nullableString").Type, it) + if err != nil { + panic(err) + } + + require.True(t, ta.IsOmittable) + }) + + t.Run("fail binding non-nullable string with Omittable[string]", func(t *testing.T) { + binder, schema := createBinder(Config{}) + + ot, err := binder.FindType("github.com/niko0xdev/gqlgen/graphql", "Omittable") + if err != nil { + panic(err) + } + + it, err := binder.InstantiateType(ot, []types.Type{types.Universe.Lookup("string").Type()}) + if err != nil { + panic(err) + } + + _, err = binder.TypeReference(schema.Types["FooInput"].Fields.ForName("nonNullableString").Type, it) + require.Error(t, err) + }) + + t.Run("fail binding non-nullable string with Omittable[*string]", func(t *testing.T) { + binder, schema := createBinder(Config{}) + + ot, err := binder.FindType("github.com/niko0xdev/gqlgen/graphql", "Omittable") + if err != nil { + panic(err) + } + + it, err := binder.InstantiateType(ot, []types.Type{types.NewPointer(types.Universe.Lookup("string").Type())}) + if err != nil { + panic(err) + } + + _, err = binder.TypeReference(schema.Types["FooInput"].Fields.ForName("nonNullableString").Type, it) + require.Error(t, err) + }) + + t.Run("bind nullable object with Omittable[T]", func(t *testing.T) { + binder, schema := createBinder(Config{}) + + typ, err := binder.FindType("github.com/niko0xdev/gqlgen/codegen/config/testdata/autobinding/chat", "Message") + if err != nil { + panic(err) + } + + ot, err := binder.FindType("github.com/niko0xdev/gqlgen/graphql", "Omittable") + if err != nil { + panic(err) + } + + it, err := binder.InstantiateType(ot, []types.Type{typ}) + if err != nil { + panic(err) + } + + ta, err := binder.TypeReference(schema.Types["FooInput"].Fields.ForName("nullableObject").Type, it) + if err != nil { + panic(err) + } + + require.True(t, ta.IsOmittable) + }) + + t.Run("bind nullable object with Omittable[*T]", func(t *testing.T) { + binder, schema := createBinder(Config{}) + + typ, err := binder.FindType("github.com/niko0xdev/gqlgen/codegen/config/testdata/autobinding/chat", "Message") + if err != nil { + panic(err) + } + + ot, err := binder.FindType("github.com/niko0xdev/gqlgen/graphql", "Omittable") + if err != nil { + panic(err) + } + + it, err := binder.InstantiateType(ot, []types.Type{types.NewPointer(typ)}) + if err != nil { + panic(err) + } + + ta, err := binder.TypeReference(schema.Types["FooInput"].Fields.ForName("nullableObject").Type, it) + if err != nil { + panic(err) + } + + require.True(t, ta.IsOmittable) + }) +} + +func createBinder(cfg Config) (*Binder, *ast.Schema) { + cfg.Models = TypeMap{ + "Message": TypeMapEntry{ + Model: []string{"github.com/niko0xdev/gqlgen/codegen/config/testdata/autobinding/chat.Message"}, + }, + "BarInput": TypeMapEntry{ + Model: []string{"github.com/niko0xdev/gqlgen/codegen/config/testdata/autobinding/chat.Message"}, + }, + "String": TypeMapEntry{ + Model: []string{"github.com/niko0xdev/gqlgen/graphql.String"}, + }, + } + cfg.Packages = code.NewPackages() + + cfg.Schema = gqlparser.MustLoadSchema(&ast.Source{Name: "TestAutobinding.schema", Input: ` + type Message { id: ID } + + input FooInput { + nullableString: String + nonNullableString: String! + nullableObject: BarInput + } + + input BarInput { + id: ID + text: String! + } + + type Query { + messages: [Message!]! + } + `}) + + b := cfg.NewBinder() + + return b, cfg.Schema +} diff --git a/codegen/config/config.go b/codegen/config/config.go new file mode 100644 index 0000000..bed9522 --- /dev/null +++ b/codegen/config/config.go @@ -0,0 +1,749 @@ +package config + +import ( + "bytes" + "fmt" + "go/types" + "io" + "os" + "path/filepath" + "regexp" + "sort" + "strings" + + "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" + "golang.org/x/tools/go/packages" + "gopkg.in/yaml.v3" + + "github.com/niko0xdev/gqlgen/codegen/templates" + "github.com/niko0xdev/gqlgen/internal/code" +) + +type Config struct { + SchemaFilename StringList `yaml:"schema,omitempty"` + Exec ExecConfig `yaml:"exec"` + Model PackageConfig `yaml:"model,omitempty"` + Federation PackageConfig `yaml:"federation,omitempty"` + Resolver ResolverConfig `yaml:"resolver,omitempty"` + AutoBind []string `yaml:"autobind"` + Models TypeMap `yaml:"models,omitempty"` + StructTag string `yaml:"struct_tag,omitempty"` + Directives map[string]DirectiveConfig `yaml:"directives,omitempty"` + GoBuildTags StringList `yaml:"go_build_tags,omitempty"` + GoInitialisms GoInitialismsConfig `yaml:"go_initialisms,omitempty"` + OmitSliceElementPointers bool `yaml:"omit_slice_element_pointers,omitempty"` + OmitGetters bool `yaml:"omit_getters,omitempty"` + OmitInterfaceChecks bool `yaml:"omit_interface_checks,omitempty"` + OmitComplexity bool `yaml:"omit_complexity,omitempty"` + OmitGQLGenFileNotice bool `yaml:"omit_gqlgen_file_notice,omitempty"` + OmitGQLGenVersionInFileNotice bool `yaml:"omit_gqlgen_version_in_file_notice,omitempty"` + OmitRootModels bool `yaml:"omit_root_models,omitempty"` + StructFieldsAlwaysPointers bool `yaml:"struct_fields_always_pointers,omitempty"` + ReturnPointersInUmarshalInput bool `yaml:"return_pointers_in_unmarshalinput,omitempty"` + ResolversAlwaysReturnPointers bool `yaml:"resolvers_always_return_pointers,omitempty"` + NullableInputOmittable bool `yaml:"nullable_input_omittable,omitempty"` + EnableModelJsonOmitemptyTag *bool `yaml:"enable_model_json_omitempty_tag,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 + Federated bool `yaml:"federated,omitempty"` +} + +var cfgFilenames = []string{".gqlgen.yml", "gqlgen.yml", "gqlgen.yaml"} + +// DefaultConfig creates a copy of the default config +func DefaultConfig() *Config { + return &Config{ + SchemaFilename: StringList{"schema.graphql"}, + Model: PackageConfig{Filename: "models_gen.go"}, + Exec: ExecConfig{Filename: "generated.go"}, + Directives: map[string]DirectiveConfig{}, + Models: TypeMap{}, + StructFieldsAlwaysPointers: true, + ReturnPointersInUmarshalInput: false, + ResolversAlwaysReturnPointers: true, + NullableInputOmittable: false, + } +} + +// LoadDefaultConfig loads the default config so that it is ready to be used +func LoadDefaultConfig() (*Config, error) { + config := DefaultConfig() + + for _, filename := range config.SchemaFilename { + filename = filepath.ToSlash(filename) + var err error + var schemaRaw []byte + schemaRaw, err = os.ReadFile(filename) + if err != nil { + return nil, fmt.Errorf("unable to open schema: %w", err) + } + + config.Sources = append(config.Sources, &ast.Source{Name: filename, Input: string(schemaRaw)}) + } + + return config, nil +} + +// LoadConfigFromDefaultLocations looks for a config file in the current directory, and all parent directories +// walking up the tree. The closest config file will be returned. +func LoadConfigFromDefaultLocations() (*Config, error) { + cfgFile, err := findCfg() + if err != nil { + return nil, err + } + + err = os.Chdir(filepath.Dir(cfgFile)) + if err != nil { + return nil, fmt.Errorf("unable to enter config dir: %w", err) + } + return LoadConfig(cfgFile) +} + +var path2regex = strings.NewReplacer( + `.`, `\.`, + `*`, `.+`, + `\`, `[\\/]`, + `/`, `[\\/]`, +) + +// LoadConfig reads the gqlgen.yml config file +func LoadConfig(filename string) (*Config, error) { + b, err := os.ReadFile(filename) + if err != nil { + return nil, fmt.Errorf("unable to read config: %w", err) + } + + return ReadConfig(bytes.NewReader(b)) +} + +func ReadConfig(cfgFile io.Reader) (*Config, error) { + config := DefaultConfig() + + dec := yaml.NewDecoder(cfgFile) + dec.KnownFields(true) + + if err := dec.Decode(config); err != nil { + 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}, + "deprecated": {SkipRuntime: true}, + "specifiedBy": {SkipRuntime: true}, + } + + for key, value := range defaultDirectives { + if _, defined := config.Directives[key]; !defined { + config.Directives[key] = value + } + } + + preGlobbing := config.SchemaFilename + config.SchemaFilename = StringList{} + for _, f := range preGlobbing { + var matches []string + + // for ** we want to override default globbing patterns and walk all + // subdirectories to match schema files. + if strings.Contains(f, "**") { + pathParts := strings.SplitN(f, "**", 2) + rest := strings.TrimPrefix(strings.TrimPrefix(pathParts[1], `\`), `/`) + // turn the rest of the glob into a regex, anchored only at the end because ** allows + // for any number of dirs in between and walk will let us match against the full path name + globRe := regexp.MustCompile(path2regex.Replace(rest) + `$`) + + if err := filepath.Walk(pathParts[0], func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + + if globRe.MatchString(strings.TrimPrefix(path, pathParts[0])) { + matches = append(matches, path) + } + + return nil + }); err != nil { + 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 fmt.Errorf("failed to glob schema filename %s: %w", f, err) + } + } + + for _, m := range matches { + if config.SchemaFilename.Has(m) { + continue + } + config.SchemaFilename = append(config.SchemaFilename, m) + } + } + + for _, filename := range config.SchemaFilename { + filename = filepath.ToSlash(filename) + var err error + var schemaRaw []byte + schemaRaw, err = os.ReadFile(filename) + if err != nil { + return fmt.Errorf("unable to open schema: %w", err) + } + + config.Sources = append(config.Sources, &ast.Source{Name: filename, Input: string(schemaRaw)}) + } + + config.GoInitialisms.setInitialisms() + + return nil +} + +func (c *Config) Init() error { + if c.Packages == nil { + c.Packages = code.NewPackages( + code.WithBuildTags(c.GoBuildTags...), + ) + } + + if c.Schema == nil { + if err := c.LoadSchema(); err != nil { + return err + } + } + + err := c.injectTypesFromSchema() + if err != nil { + return err + } + + err = c.autobind() + if err != nil { + return err + } + + c.injectBuiltins() + // prefetch all packages in one big packages.Load call + c.Packages.LoadAll(c.packageList()...) + + // check everything is valid on the way out + err = c.check() + if err != nil { + return err + } + + return nil +} + +func (c *Config) packageList() []string { + pkgs := []string{ + "github.com/niko0xdev/gqlgen/graphql", + "github.com/niko0xdev/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) IsRoot(def *ast.Definition) bool { + return def == c.Schema.Query || def == c.Schema.Mutation || def == c.Schema.Subscription +} + +func (c *Config) injectTypesFromSchema() error { + c.Directives["goModel"] = DirectiveConfig{ + SkipRuntime: true, + } + + c.Directives["goField"] = DirectiveConfig{ + SkipRuntime: true, + } + + c.Directives["goTag"] = DirectiveConfig{ + SkipRuntime: true, + } + + for _, schemaType := range c.Schema.Types { + if c.IsRoot(schemaType) { + continue + } + + if bd := schemaType.Directives.ForName("goModel"); bd != nil { + if ma := bd.Arguments.ForName("model"); ma != nil { + if mv, err := ma.Value.Value(nil); err == nil { + c.Models.Add(schemaType.Name, mv.(string)) + } + } + + if ma := bd.Arguments.ForName("models"); ma != nil { + if mvs, err := ma.Value.Value(nil); err == nil { + for _, mv := range mvs.([]interface{}) { + c.Models.Add(schemaType.Name, mv.(string)) + } + } + } + + if fg := bd.Arguments.ForName("forceGenerate"); fg != nil { + if mv, err := fg.Value.Value(nil); err == nil { + c.Models.ForceGenerate(schemaType.Name, mv.(bool)) + } + } + } + + if schemaType.Kind == ast.Object || schemaType.Kind == ast.InputObject { + for _, field := range schemaType.Fields { + 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 + + if ra := fd.Arguments.ForName("forceResolver"); ra != nil { + if fr, err := ra.Value.Value(nil); err == nil { + forceResolver = fr.(bool) + } + } + + if na := fd.Arguments.ForName("name"); na != nil { + if fr, err := na.Value.Value(nil); err == nil { + fieldName = fr.(string) + } + } + + if c.Models[schemaType.Name].Fields == nil { + c.Models[schemaType.Name] = TypeMapEntry{ + Model: c.Models[schemaType.Name].Model, + ExtraFields: c.Models[schemaType.Name].ExtraFields, + Fields: map[string]TypeMapField{}, + } + } + + c.Models[schemaType.Name].Fields[field.Name] = TypeMapField{ + FieldName: fieldName, + Resolver: forceResolver, + } + } + } + } + } + + return nil +} + +type TypeMapEntry struct { + Model StringList `yaml:"model,omitempty"` + ForceGenerate bool `yaml:"forceGenerate,omitempty"` + Fields map[string]TypeMapField `yaml:"fields,omitempty"` + + // Key is the Go name of the field. + ExtraFields map[string]ModelExtraField `yaml:"extraFields,omitempty"` +} + +type TypeMapField struct { + Resolver bool `yaml:"resolver"` + FieldName string `yaml:"fieldName"` + GeneratedMethod string `yaml:"-"` +} + +type ModelExtraField struct { + // Type is the Go type of the field. + // + // It supports the builtin basic types (like string or int64), named types + // (qualified by the full package path), pointers to those types (prefixed + // with `*`), and slices of those types (prefixed with `[]`). + // + // For example, the following are valid types: + // string + // *github.com/author/package.Type + // []string + // []*github.com/author/package.Type + // + // Note that the type will be referenced from the generated/graphql, which + // means the package it lives in must not reference the generated/graphql + // package to avoid circular imports. + // restrictions. + Type string `yaml:"type"` + + // OverrideTags is an optional override of the Go field tag. + OverrideTags string `yaml:"overrideTags"` + + // Description is an optional the Go field doc-comment. + Description string `yaml:"description"` +} + +type StringList []string + +func (a *StringList) UnmarshalYAML(unmarshal func(interface{}) error) error { + var single string + err := unmarshal(&single) + if err == nil { + *a = []string{single} + return nil + } + + var multi []string + err = unmarshal(&multi) + if err != nil { + return err + } + + *a = multi + return nil +} + +func (a StringList) Has(file string) bool { + for _, existing := range a { + if existing == file { + return true + } + } + return false +} + +func (c *Config) check() error { + if c.Models == nil { + c.Models = TypeMap{} + } + + type FilenamePackage struct { + Filename string + Package string + Declaree string + } + + fileList := map[string][]FilenamePackage{} + + if err := c.Models.Check(); err != nil { + return fmt.Errorf("config.models: %w", err) + } + if err := c.Exec.Check(); err != nil { + return fmt.Errorf("config.exec: %w", err) + } + fileList[c.Exec.ImportPath()] = append(fileList[c.Exec.ImportPath()], FilenamePackage{ + Filename: c.Exec.Filename, + Package: c.Exec.Package, + Declaree: "exec", + }) + + if c.Model.IsDefined() { + if err := c.Model.Check(); err != nil { + return fmt.Errorf("config.model: %w", err) + } + fileList[c.Model.ImportPath()] = append(fileList[c.Model.ImportPath()], FilenamePackage{ + Filename: c.Model.Filename, + Package: c.Model.Package, + Declaree: "model", + }) + } + if c.Resolver.IsDefined() { + if err := c.Resolver.Check(); err != nil { + return fmt.Errorf("config.resolver: %w", err) + } + fileList[c.Resolver.ImportPath()] = append(fileList[c.Resolver.ImportPath()], FilenamePackage{ + Filename: c.Resolver.Filename, + Package: c.Resolver.Package, + Declaree: "resolver", + }) + } + if c.Federation.IsDefined() { + if err := c.Federation.Check(); err != nil { + return fmt.Errorf("config.federation: %w", err) + } + fileList[c.Federation.ImportPath()] = append(fileList[c.Federation.ImportPath()], FilenamePackage{ + Filename: c.Federation.Filename, + Package: c.Federation.Package, + Declaree: "federation", + }) + if c.Federation.ImportPath() != c.Exec.ImportPath() { + return fmt.Errorf("federation and exec must be in the same package") + } + } + if c.Federated { + return fmt.Errorf("federated has been removed, instead use\nfederation:\n filename: path/to/federated.go") + } + + for importPath, pkg := range fileList { + for _, file1 := range pkg { + for _, file2 := range pkg { + if file1.Package != file2.Package { + return fmt.Errorf("%s and %s define the same import path (%s) with different package names (%s vs %s)", + file1.Declaree, + file2.Declaree, + importPath, + file1.Package, + file2.Package, + ) + } + } + } + } + + return nil +} + +type TypeMap map[string]TypeMapEntry + +func (tm TypeMap) Exists(typeName string) bool { + _, ok := tm[typeName] + return ok +} + +func (tm TypeMap) UserDefined(typeName string) bool { + m, ok := tm[typeName] + return ok && len(m.Model) > 0 +} + +func (tm TypeMap) Check() error { + for typeName, entry := range tm { + for _, model := range entry.Model { + if strings.LastIndex(model, ".") < strings.LastIndex(model, "/") { + return fmt.Errorf("model %s: invalid type specifier \"%s\" - you need to specify a struct to map to", typeName, entry.Model) + } + } + } + return nil +} + +func (tm TypeMap) ReferencedPackages() []string { + var pkgs []string + + for _, typ := range tm { + for _, model := range typ.Model { + if model == "map[string]interface{}" || model == "interface{}" { + continue + } + pkg, _ := code.PkgAndType(model) + if pkg == "" || inStrSlice(pkgs, pkg) { + continue + } + pkgs = append(pkgs, code.QualifyPackagePath(pkg)) + } + } + + sort.Slice(pkgs, func(i, j int) bool { + return pkgs[i] > pkgs[j] + }) + return pkgs +} + +func (tm TypeMap) Add(name string, goType string) { + modelCfg := tm[name] + modelCfg.Model = append(modelCfg.Model, goType) + tm[name] = modelCfg +} + +func (tm TypeMap) ForceGenerate(name string, forceGenerate bool) { + modelCfg := tm[name] + modelCfg.ForceGenerate = forceGenerate + tm[name] = modelCfg +} + +type DirectiveConfig struct { + SkipRuntime bool `yaml:"skip_runtime"` +} + +func inStrSlice(haystack []string, needle string) bool { + for _, v := range haystack { + if needle == v { + return true + } + } + + return false +} + +// findCfg searches for the config file in this directory and all parents up the tree +// looking for the closest match +func findCfg() (string, error) { + dir, err := os.Getwd() + if err != nil { + return "", fmt.Errorf("unable to get working dir to findCfg: %w", err) + } + + cfg := findCfgInDir(dir) + + for cfg == "" && dir != filepath.Dir(dir) { + dir = filepath.Dir(dir) + cfg = findCfgInDir(dir) + } + + if cfg == "" { + return "", os.ErrNotExist + } + + return cfg, nil +} + +func findCfgInDir(dir string) string { + for _, cfgName := range cfgFilenames { + path := filepath.Join(dir, cfgName) + if _, err := os.Stat(path); err == nil { + return path + } + } + return "" +} + +func (c *Config) autobind() error { + if len(c.AutoBind) == 0 { + return nil + } + + ps := c.Packages.LoadAll(c.AutoBind...) + + for _, t := range c.Schema.Types { + if c.Models.UserDefined(t.Name) || c.Models[t.Name].ForceGenerate { + continue + } + + for i, p := range ps { + 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]) + } + + autobindType := c.lookupAutobindType(p, t) + if autobindType != nil { + c.Models.Add(t.Name, autobindType.Pkg().Path()+"."+autobindType.Name()) + break + } + } + } + + for i, t := range c.Models { + if t.ForceGenerate { + continue + } + + for j, m := range t.Model { + pkg, typename := code.PkgAndType(m) + + // skip anything that looks like an import path + if strings.Contains(pkg, "/") { + continue + } + + for _, p := range ps { + if p.Name != pkg { + continue + } + if t := p.Types.Scope().Lookup(typename); t != nil { + c.Models[i].Model[j] = t.Pkg().Path() + "." + t.Name() + break + } + } + } + } + + return nil +} + +func (c *Config) lookupAutobindType(p *packages.Package, schemaType *ast.Definition) types.Object { + // Try binding to either the original schema type name, or the normalized go type name + for _, lookupName := range []string{schemaType.Name, templates.ToGo(schemaType.Name)} { + if t := p.Types.Scope().Lookup(lookupName); t != nil { + return t + } + } + + return nil +} + +func (c *Config) injectBuiltins() { + builtins := TypeMap{ + "__Directive": {Model: StringList{"github.com/niko0xdev/gqlgen/graphql/introspection.Directive"}}, + "__DirectiveLocation": {Model: StringList{"github.com/niko0xdev/gqlgen/graphql.String"}}, + "__Type": {Model: StringList{"github.com/niko0xdev/gqlgen/graphql/introspection.Type"}}, + "__TypeKind": {Model: StringList{"github.com/niko0xdev/gqlgen/graphql.String"}}, + "__Field": {Model: StringList{"github.com/niko0xdev/gqlgen/graphql/introspection.Field"}}, + "__EnumValue": {Model: StringList{"github.com/niko0xdev/gqlgen/graphql/introspection.EnumValue"}}, + "__InputValue": {Model: StringList{"github.com/niko0xdev/gqlgen/graphql/introspection.InputValue"}}, + "__Schema": {Model: StringList{"github.com/niko0xdev/gqlgen/graphql/introspection.Schema"}}, + "Float": {Model: StringList{"github.com/niko0xdev/gqlgen/graphql.FloatContext"}}, + "String": {Model: StringList{"github.com/niko0xdev/gqlgen/graphql.String"}}, + "Boolean": {Model: StringList{"github.com/niko0xdev/gqlgen/graphql.Boolean"}}, + "Int": {Model: StringList{ + "github.com/niko0xdev/gqlgen/graphql.Int", + "github.com/niko0xdev/gqlgen/graphql.Int32", + "github.com/niko0xdev/gqlgen/graphql.Int64", + }}, + "ID": { + Model: StringList{ + "github.com/niko0xdev/gqlgen/graphql.ID", + "github.com/niko0xdev/gqlgen/graphql.IntID", + }, + }, + } + + for typeName, entry := range builtins { + if !c.Models.Exists(typeName) { + c.Models[typeName] = entry + } + } + + // These are additional types that are injected if defined in the schema as scalars. + extraBuiltins := TypeMap{ + "Time": {Model: StringList{"github.com/niko0xdev/gqlgen/graphql.Time"}}, + "Map": {Model: StringList{"github.com/niko0xdev/gqlgen/graphql.Map"}}, + "Upload": {Model: StringList{"github.com/niko0xdev/gqlgen/graphql.Upload"}}, + "Any": {Model: StringList{"github.com/niko0xdev/gqlgen/graphql.Any"}}, + } + + for typeName, entry := range extraBuiltins { + if t, ok := c.Schema.Types[typeName]; !c.Models.Exists(typeName) && ok && t.Kind == ast.Scalar { + c.Models[typeName] = entry + } + } +} + +func (c *Config) LoadSchema() error { + if c.Packages != nil { + c.Packages = code.NewPackages( + code.WithBuildTags(c.GoBuildTags...), + ) + } + + if err := c.check(); err != nil { + return err + } + + schema, err := gqlparser.LoadSchema(c.Sources...) + if err != nil { + return err + } + + if schema.Query == nil { + schema.Query = &ast.Definition{ + Kind: ast.Object, + Name: "Query", + } + schema.Types["Query"] = schema.Query + } + + c.Schema = schema + return nil +} + +func abs(path string) string { + absPath, err := filepath.Abs(path) + if err != nil { + panic(err) + } + return filepath.ToSlash(absPath) +} diff --git a/codegen/config/config_test.go b/codegen/config/config_test.go new file mode 100644 index 0000000..31ae29f --- /dev/null +++ b/codegen/config/config_test.go @@ -0,0 +1,250 @@ +package config + +import ( + "errors" + "io/fs" + "os" + "path/filepath" + "runtime" + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" + + "github.com/niko0xdev/gqlgen/internal/code" +) + +func TestLoadConfig(t *testing.T) { + t.Run("config does not exist", func(t *testing.T) { + _, err := LoadConfig("doesnotexist.yml") + require.Error(t, err) + }) +} + +func TestReadConfig(t *testing.T) { + t.Run("empty config", func(t *testing.T) { + _, err := ReadConfig(strings.NewReader("")) + require.EqualError(t, err, "unable to parse config: EOF") + }) + + t.Run("malformed config", func(t *testing.T) { + cfgFile, _ := os.Open("testdata/cfg/malformedconfig.yml") + _, err := ReadConfig(cfgFile) + require.EqualError(t, err, "unable to parse config: yaml: unmarshal errors:\n line 1: cannot unmarshal !!str `asdf` into config.Config") + }) + + t.Run("unknown keys", func(t *testing.T) { + cfgFile, _ := os.Open("testdata/cfg/unknownkeys.yml") + _, err := ReadConfig(cfgFile) + require.EqualError(t, err, "unable to parse config: yaml: unmarshal errors:\n line 2: field unknown not found in type config.Config") + }) + + t.Run("globbed filenames", func(t *testing.T) { + cfgFile, _ := os.Open("testdata/cfg/glob.yml") + c, err := ReadConfig(cfgFile) + require.NoError(t, err) + + if runtime.GOOS == "windows" { + require.Equal(t, c.SchemaFilename[0], `testdata\cfg\glob\bar\bar with spaces.graphql`) + require.Equal(t, c.SchemaFilename[1], `testdata\cfg\glob\foo\foo.graphql`) + } else { + require.Equal(t, c.SchemaFilename[0], "testdata/cfg/glob/bar/bar with spaces.graphql") + require.Equal(t, c.SchemaFilename[1], "testdata/cfg/glob/foo/foo.graphql") + } + }) + + t.Run("unwalkable path", func(t *testing.T) { + cfgFile, _ := os.Open("testdata/cfg/unwalkable.yml") + _, err := ReadConfig(cfgFile) + if runtime.GOOS == "windows" { + require.EqualError(t, err, "failed to walk schema at root not_walkable/: CreateFile not_walkable/: The system cannot find the file specified.") + } else { + require.EqualError(t, err, "failed to walk schema at root not_walkable/: lstat not_walkable/: no such file or directory") + } + }) +} + +func TestLoadConfigFromDefaultLocation(t *testing.T) { + testDir, err := os.Getwd() + require.NoError(t, err) + var cfg *Config + + t.Run("will find closest match", func(t *testing.T) { + err = os.Chdir(filepath.Join(testDir, "testdata", "cfg", "subdir")) + require.NoError(t, err) + + cfg, err = LoadConfigFromDefaultLocations() + require.NoError(t, err) + require.Equal(t, StringList{"inner"}, cfg.SchemaFilename) + }) + + t.Run("will find config in parent dirs", func(t *testing.T) { + err = os.Chdir(filepath.Join(testDir, "testdata", "cfg", "otherdir")) + require.NoError(t, err) + + cfg, err = LoadConfigFromDefaultLocations() + require.NoError(t, err) + require.Equal(t, StringList{"outer"}, cfg.SchemaFilename) + }) + + t.Run("will return error if config doesn't exist", func(t *testing.T) { + err = os.Chdir(testDir) + require.NoError(t, err) + + cfg, err = LoadConfigFromDefaultLocations() + require.True(t, errors.Is(err, fs.ErrNotExist)) + }) +} + +func TestLoadDefaultConfig(t *testing.T) { + testDir, err := os.Getwd() + require.NoError(t, err) + var cfg *Config + + t.Run("will find the schema", func(t *testing.T) { + err = os.Chdir(filepath.Join(testDir, "testdata", "defaultconfig")) + require.NoError(t, err) + + cfg, err = LoadDefaultConfig() + require.NoError(t, err) + require.NotEmpty(t, cfg.Sources) + }) + + t.Run("will return error if schema doesn't exist", func(t *testing.T) { + err = os.Chdir(testDir) + require.NoError(t, err) + + cfg, err = LoadDefaultConfig() + require.True(t, errors.Is(err, fs.ErrNotExist)) + }) +} + +func TestReferencedPackages(t *testing.T) { + t.Run("valid", func(t *testing.T) { + tm := TypeMap{ + "Foo": {Model: StringList{"github.com/test.Foo"}}, + "Bar": {Model: StringList{"github.com/test.Bar"}}, + "Baz": {Model: StringList{"github.com/otherpkg.Baz"}}, + "Map": {Model: StringList{"map[string]interface{}"}}, + "SkipResolver": { + Fields: map[string]TypeMapField{ + "field": {Resolver: false}, + }, + }, + } + + pkgs := tm.ReferencedPackages() + + assert.Equal(t, []string{"github.com/test", "github.com/otherpkg"}, pkgs) + }) +} + +func TestConfigCheck(t *testing.T) { + 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/niko0xdev/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/niko0xdev/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) { + t.Run("valid paths", func(t *testing.T) { + cfg := Config{ + Models: TypeMap{}, + AutoBind: []string{ + "github.com/niko0xdev/gqlgen/codegen/config/testdata/autobinding/chat", + "github.com/niko0xdev/gqlgen/codegen/config/testdata/autobinding/scalars/model", + }, + Packages: code.NewPackages(), + } + + cfg.Schema = gqlparser.MustLoadSchema(&ast.Source{Name: "TestAutobinding.schema", Input: ` + scalar Banned + type Message { id: ID } + `}) + + require.NoError(t, cfg.autobind()) + + require.Equal(t, "github.com/niko0xdev/gqlgen/codegen/config/testdata/autobinding/scalars/model.Banned", cfg.Models["Banned"].Model[0]) + require.Equal(t, "github.com/niko0xdev/gqlgen/codegen/config/testdata/autobinding/chat.Message", cfg.Models["Message"].Model[0]) + }) + + t.Run("normalized type names", func(t *testing.T) { + cfg := Config{ + Models: TypeMap{}, + AutoBind: []string{ + "github.com/niko0xdev/gqlgen/codegen/config/testdata/autobinding/chat", + "github.com/niko0xdev/gqlgen/codegen/config/testdata/autobinding/scalars/model", + }, + Packages: code.NewPackages(), + } + + cfg.Schema = gqlparser.MustLoadSchema(&ast.Source{Name: "TestAutobinding.schema", Input: ` + scalar Banned + type Message { id: ID } + enum ProductSKU { ProductSkuTrial } + type ChatAPI { id: ID } + `}) + + require.NoError(t, cfg.autobind()) + + require.Equal(t, "github.com/niko0xdev/gqlgen/codegen/config/testdata/autobinding/scalars/model.Banned", cfg.Models["Banned"].Model[0]) + require.Equal(t, "github.com/niko0xdev/gqlgen/codegen/config/testdata/autobinding/chat.Message", cfg.Models["Message"].Model[0]) + require.Equal(t, "github.com/niko0xdev/gqlgen/codegen/config/testdata/autobinding/chat.ProductSku", cfg.Models["ProductSKU"].Model[0]) + require.Equal(t, "github.com/niko0xdev/gqlgen/codegen/config/testdata/autobinding/chat.ChatAPI", cfg.Models["ChatAPI"].Model[0]) + }) + + t.Run("with file path", func(t *testing.T) { + cfg := Config{ + Models: TypeMap{}, + AutoBind: []string{ + "../chat", + }, + Packages: code.NewPackages(), + } + + cfg.Schema = gqlparser.MustLoadSchema(&ast.Source{Name: "TestAutobinding.schema", Input: ` + scalar Banned + type Message { id: ID } + `}) + + require.EqualError(t, cfg.autobind(), "unable to load ../chat - make sure you're using an import path to a package that exists") + }) +} diff --git a/codegen/config/exec.go b/codegen/config/exec.go new file mode 100644 index 0000000..2058e5d --- /dev/null +++ b/codegen/config/exec.go @@ -0,0 +1,97 @@ +package config + +import ( + "fmt" + "go/types" + "path/filepath" + "strings" + + "github.com/niko0xdev/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/initialisms.go b/codegen/config/initialisms.go new file mode 100644 index 0000000..dd75cab --- /dev/null +++ b/codegen/config/initialisms.go @@ -0,0 +1,42 @@ +package config + +import ( + "strings" + + "github.com/niko0xdev/gqlgen/codegen/templates" +) + +// GoInitialismsConfig allows to modify the default behavior of naming Go methods, types and properties +type GoInitialismsConfig struct { + // If true, the Initialisms won't get appended to the default ones but replace them + ReplaceDefaults bool `yaml:"replace_defaults"` + // Custom initialisms to be added or to replace the default ones + Initialisms []string `yaml:"initialisms"` +} + +// setInitialisms adjustes GetInitialisms based on its settings. +func (i GoInitialismsConfig) setInitialisms() { + toUse := i.determineGoInitialisms() + templates.GetInitialisms = func() map[string]bool { + return toUse + } +} + +// determineGoInitialisms returns the Go initialims to be used, based on its settings. +func (i GoInitialismsConfig) determineGoInitialisms() (initialismsToUse map[string]bool) { + if i.ReplaceDefaults { + initialismsToUse = make(map[string]bool, len(i.Initialisms)) + for _, initialism := range i.Initialisms { + initialismsToUse[strings.ToUpper(initialism)] = true + } + } else { + initialismsToUse = make(map[string]bool, len(templates.CommonInitialisms)+len(i.Initialisms)) + for initialism, value := range templates.CommonInitialisms { + initialismsToUse[strings.ToUpper(initialism)] = value + } + for _, initialism := range i.Initialisms { + initialismsToUse[strings.ToUpper(initialism)] = true + } + } + return initialismsToUse +} diff --git a/codegen/config/initialisms_test.go b/codegen/config/initialisms_test.go new file mode 100644 index 0000000..aa70e2a --- /dev/null +++ b/codegen/config/initialisms_test.go @@ -0,0 +1,41 @@ +package config + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/codegen/templates" +) + +func TestGoInitialismsConfig(t *testing.T) { + t.Run("load go initialisms config", func(t *testing.T) { + config, err := LoadConfig("testdata/cfg/goInitialisms.yml") + require.NoError(t, err) + require.True(t, config.GoInitialisms.ReplaceDefaults) + require.Len(t, config.GoInitialisms.Initialisms, 2) + }) + t.Run("empty initialism config doesn't change anything", func(t *testing.T) { + tt := GoInitialismsConfig{} + result := tt.determineGoInitialisms() + assert.Equal(t, len(templates.CommonInitialisms), len(result)) + }) + t.Run("initialism config appends if desired", func(t *testing.T) { + tt := GoInitialismsConfig{ReplaceDefaults: false, Initialisms: []string{"ASDF"}} + result := tt.determineGoInitialisms() + assert.Equal(t, len(templates.CommonInitialisms)+1, len(result)) + assert.True(t, result["ASDF"]) + }) + t.Run("initialism config replaces if desired", func(t *testing.T) { + tt := GoInitialismsConfig{ReplaceDefaults: true, Initialisms: []string{"ASDF"}} + result := tt.determineGoInitialisms() + assert.Equal(t, 1, len(result)) + assert.True(t, result["ASDF"]) + }) + t.Run("initialism config uppercases the initialsms", func(t *testing.T) { + tt := GoInitialismsConfig{Initialisms: []string{"asdf"}} + result := tt.determineGoInitialisms() + assert.True(t, result["ASDF"]) + }) +} diff --git a/codegen/config/package.go b/codegen/config/package.go new file mode 100644 index 0000000..d055efc --- /dev/null +++ b/codegen/config/package.go @@ -0,0 +1,64 @@ +package config + +import ( + "fmt" + "go/types" + "path/filepath" + "strings" + + "github.com/niko0xdev/gqlgen/internal/code" +) + +type PackageConfig struct { + Filename string `yaml:"filename,omitempty"` + Package string `yaml:"package,omitempty"` + Version int `yaml:"version,omitempty"` + ModelTemplate string `yaml:"model_template,omitempty"` +} + +func (c *PackageConfig) ImportPath() string { + if !c.IsDefined() { + return "" + } + return code.ImportPathForDir(c.Dir()) +} + +func (c *PackageConfig) Dir() string { + if !c.IsDefined() { + return "" + } + return filepath.Dir(c.Filename) +} + +func (c *PackageConfig) Pkg() *types.Package { + if !c.IsDefined() { + return nil + } + return types.NewPackage(c.ImportPath(), c.Package) +} + +func (c *PackageConfig) IsDefined() bool { + return c.Filename != "" +} + +func (c *PackageConfig) Check() error { + if strings.ContainsAny(c.Package, "./\\") { + return fmt.Errorf("package should be the output package name only, do not include the output filename") + } + if c.Filename == "" { + return fmt.Errorf("filename must be specified") + } + if !strings.HasSuffix(c.Filename, ".go") { + return fmt.Errorf("filename should be path to a go source file") + } + + c.Filename = abs(c.Filename) + + // If Package is not set, first attempt to load the package at the output dir. If that fails + // fallback to just the base dir name of the output filename. + if c.Package == "" { + c.Package = code.NameForDir(c.Dir()) + } + + return nil +} diff --git a/codegen/config/package_test.go b/codegen/config/package_test.go new file mode 100644 index 0000000..f10975a --- /dev/null +++ b/codegen/config/package_test.go @@ -0,0 +1,71 @@ +package config + +import ( + "path/filepath" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestPackageConfig(t *testing.T) { + t.Run("when given just a filename", func(t *testing.T) { + p := PackageConfig{Filename: "testdata/example.go"} + require.True(t, p.IsDefined()) + + require.NoError(t, p.Check()) + + require.Equal(t, p.Package, "config_test_data") + require.Equal(t, "github.com/niko0xdev/gqlgen/codegen/config/testdata", p.ImportPath()) + + require.Equal(t, "config_test_data", p.Pkg().Name()) + require.Equal(t, "github.com/niko0xdev/gqlgen/codegen/config/testdata", p.Pkg().Path()) + + require.Contains(t, filepath.ToSlash(p.Filename), "codegen/config/testdata/example.go") + require.Contains(t, filepath.ToSlash(p.Dir()), "codegen/config/testdata") + }) + + t.Run("when given both", func(t *testing.T) { + p := PackageConfig{Filename: "testdata/example.go", Package: "wololo"} + require.True(t, p.IsDefined()) + + require.NoError(t, p.Check()) + + require.Equal(t, p.Package, "wololo") + require.Equal(t, "github.com/niko0xdev/gqlgen/codegen/config/testdata", p.ImportPath()) + + require.Equal(t, "wololo", p.Pkg().Name()) + require.Equal(t, "github.com/niko0xdev/gqlgen/codegen/config/testdata", p.Pkg().Path()) + + require.Contains(t, filepath.ToSlash(p.Filename), "codegen/config/testdata/example.go") + require.Contains(t, filepath.ToSlash(p.Dir()), "codegen/config/testdata") + }) + + t.Run("when given nothing", func(t *testing.T) { + p := PackageConfig{} + require.False(t, p.IsDefined()) + + require.EqualError(t, p.Check(), "filename must be specified") + + require.Equal(t, "", p.Package) + require.Equal(t, "", p.ImportPath()) + + require.Nil(t, p.Pkg()) + + require.Equal(t, "", p.Filename) + require.Equal(t, "", p.Dir()) + }) + + t.Run("when given invalid filename", func(t *testing.T) { + p := PackageConfig{Filename: "wololo.sql"} + require.True(t, p.IsDefined()) + + require.EqualError(t, p.Check(), "filename should be path to a go source file") + }) + + t.Run("when package includes a filename", func(t *testing.T) { + p := PackageConfig{Filename: "foo.go", Package: "foo/foo.go"} + require.True(t, p.IsDefined()) + + require.EqualError(t, p.Check(), "package should be the output package name only, do not include the output filename") + }) +} diff --git a/codegen/config/resolver.go b/codegen/config/resolver.go new file mode 100644 index 0000000..1e678cc --- /dev/null +++ b/codegen/config/resolver.go @@ -0,0 +1,102 @@ +package config + +import ( + "fmt" + "go/types" + "path/filepath" + "strings" + + "github.com/niko0xdev/gqlgen/internal/code" +) + +type ResolverConfig struct { + Filename string `yaml:"filename,omitempty"` + FilenameTemplate string `yaml:"filename_template,omitempty"` + Package string `yaml:"package,omitempty"` + Type string `yaml:"type,omitempty"` + Layout ResolverLayout `yaml:"layout,omitempty"` + DirName string `yaml:"dir"` + OmitTemplateComment bool `yaml:"omit_template_comment,omitempty"` + ResolverTemplate string `yaml:"resolver_template,omitempty"` +} + +type ResolverLayout string + +var ( + LayoutSingleFile ResolverLayout = "single-file" + LayoutFollowSchema ResolverLayout = "follow-schema" +) + +func (r *ResolverConfig) Check() error { + if r.Layout == "" { + r.Layout = LayoutSingleFile + } + if r.Type == "" { + r.Type = "Resolver" + } + + switch r.Layout { + case LayoutSingleFile: + if r.Filename == "" { + return fmt.Errorf("filename must be specified with layout=%s", r.Layout) + } + if !strings.HasSuffix(r.Filename, ".go") { + return fmt.Errorf("filename should be path to a go source file with layout=%s", r.Layout) + } + r.Filename = abs(r.Filename) + case LayoutFollowSchema: + if r.DirName == "" { + return fmt.Errorf("dirname must be specified with layout=%s", r.Layout) + } + r.DirName = abs(r.DirName) + if r.Filename == "" { + r.Filename = filepath.Join(r.DirName, "resolver.go") + } else { + r.Filename = abs(r.Filename) + } + default: + return fmt.Errorf("invalid layout %s. must be %s or %s", r.Layout, LayoutSingleFile, LayoutFollowSchema) + } + + 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 *ResolverConfig) ImportPath() string { + if r.Dir() == "" { + return "" + } + return code.ImportPathForDir(r.Dir()) +} + +func (r *ResolverConfig) Dir() string { + switch r.Layout { + case LayoutSingleFile: + if r.Filename == "" { + return "" + } + return filepath.Dir(r.Filename) + case LayoutFollowSchema: + return r.DirName + default: + panic("invalid layout " + r.Layout) + } +} + +func (r *ResolverConfig) Pkg() *types.Package { + if r.Dir() == "" { + return nil + } + return types.NewPackage(r.ImportPath(), r.Package) +} + +func (r *ResolverConfig) IsDefined() bool { + return r.Filename != "" || r.DirName != "" +} diff --git a/codegen/config/resolver_test.go b/codegen/config/resolver_test.go new file mode 100644 index 0000000..8d45958 --- /dev/null +++ b/codegen/config/resolver_test.go @@ -0,0 +1,150 @@ +package config + +import ( + "path/filepath" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestResolverConfig(t *testing.T) { + t.Run("single-file", func(t *testing.T) { + t.Run("when given just a filename", func(t *testing.T) { + p := ResolverConfig{Filename: "testdata/example.go"} + require.True(t, p.IsDefined()) + + require.NoError(t, p.Check()) + require.NoError(t, p.Check()) + + require.Equal(t, p.Package, "config_test_data") + require.Equal(t, "github.com/niko0xdev/gqlgen/codegen/config/testdata", p.ImportPath()) + + require.Equal(t, "config_test_data", p.Pkg().Name()) + require.Equal(t, "github.com/niko0xdev/gqlgen/codegen/config/testdata", p.Pkg().Path()) + + require.Contains(t, filepath.ToSlash(p.Filename), "codegen/config/testdata/example.go") + require.Contains(t, filepath.ToSlash(p.Dir()), "codegen/config/testdata") + }) + + t.Run("when given both", func(t *testing.T) { + p := ResolverConfig{Filename: "testdata/example.go", Package: "wololo"} + require.True(t, p.IsDefined()) + + require.NoError(t, p.Check()) + require.NoError(t, p.Check()) + + require.Equal(t, p.Package, "wololo") + require.Equal(t, "github.com/niko0xdev/gqlgen/codegen/config/testdata", p.ImportPath()) + + require.Equal(t, "wololo", p.Pkg().Name()) + require.Equal(t, "github.com/niko0xdev/gqlgen/codegen/config/testdata", p.Pkg().Path()) + + require.Contains(t, filepath.ToSlash(p.Filename), "codegen/config/testdata/example.go") + require.Contains(t, filepath.ToSlash(p.Dir()), "codegen/config/testdata") + }) + + t.Run("when given nothing", func(t *testing.T) { + p := ResolverConfig{} + require.False(t, p.IsDefined()) + + require.EqualError(t, p.Check(), "filename must be specified with layout=single-file") + + require.Equal(t, "", p.Package) + require.Equal(t, "", p.ImportPath()) + + require.Nil(t, p.Pkg()) + + require.Equal(t, "", p.Filename) + require.Equal(t, "", p.Dir()) + }) + + t.Run("when given invalid filename", func(t *testing.T) { + p := ResolverConfig{Filename: "wololo.sql"} + require.True(t, p.IsDefined()) + + require.EqualError(t, p.Check(), "filename should be path to a go source file with layout=single-file") + }) + + t.Run("when package includes a filename", func(t *testing.T) { + p := ResolverConfig{Filename: "foo.go", Package: "foo/foo.go"} + require.True(t, p.IsDefined()) + + require.EqualError(t, p.Check(), "package should be the output package name only, do not include the output filename") + }) + }) + + t.Run("follow-schema", func(t *testing.T) { + t.Run("when given just a dir", func(t *testing.T) { + p := ResolverConfig{Layout: LayoutFollowSchema, DirName: "testdata"} + require.True(t, p.IsDefined()) + + require.NoError(t, p.Check()) + require.NoError(t, p.Check()) + + require.Equal(t, p.Package, "config_test_data") + require.Equal(t, "github.com/niko0xdev/gqlgen/codegen/config/testdata", p.ImportPath()) + + require.Equal(t, "config_test_data", p.Pkg().Name()) + require.Equal(t, "github.com/niko0xdev/gqlgen/codegen/config/testdata", p.Pkg().Path()) + + require.Contains(t, filepath.ToSlash(p.Filename), "codegen/config/testdata/resolver.go") + require.Contains(t, p.Dir(), "codegen/config/testdata") + }) + + t.Run("when given dir and package name", func(t *testing.T) { + p := ResolverConfig{Layout: LayoutFollowSchema, DirName: "testdata", Package: "wololo"} + require.True(t, p.IsDefined()) + + require.NoError(t, p.Check()) + require.NoError(t, p.Check()) + + require.Equal(t, p.Package, "wololo") + require.Equal(t, "github.com/niko0xdev/gqlgen/codegen/config/testdata", p.ImportPath()) + + require.Equal(t, "wololo", p.Pkg().Name()) + require.Equal(t, "github.com/niko0xdev/gqlgen/codegen/config/testdata", p.Pkg().Path()) + + require.Contains(t, filepath.ToSlash(p.Filename), "codegen/config/testdata/resolver.go") + require.Contains(t, p.Dir(), "codegen/config/testdata") + }) + + t.Run("when given a filename", func(t *testing.T) { + p := ResolverConfig{Layout: LayoutFollowSchema, DirName: "testdata", Filename: "testdata/asdf.go"} + require.True(t, p.IsDefined()) + + require.NoError(t, p.Check()) + require.NoError(t, p.Check()) + + require.Equal(t, p.Package, "config_test_data") + require.Equal(t, "github.com/niko0xdev/gqlgen/codegen/config/testdata", p.ImportPath()) + + require.Equal(t, "config_test_data", p.Pkg().Name()) + require.Equal(t, "github.com/niko0xdev/gqlgen/codegen/config/testdata", p.Pkg().Path()) + + require.Contains(t, filepath.ToSlash(p.Filename), "codegen/config/testdata/asdf.go") + require.Contains(t, p.Dir(), "codegen/config/testdata") + }) + + t.Run("when given nothing", func(t *testing.T) { + p := ResolverConfig{Layout: LayoutFollowSchema} + require.False(t, p.IsDefined()) + + require.EqualError(t, p.Check(), "dirname must be specified with layout=follow-schema") + + require.Equal(t, "", p.Package) + require.Equal(t, "", p.ImportPath()) + + require.Nil(t, p.Pkg()) + + require.Equal(t, "", p.Filename) + require.Equal(t, "", p.Dir()) + }) + }) + + t.Run("invalid layout", func(t *testing.T) { + p := ResolverConfig{Layout: "pies", Filename: "asdf.go"} + require.True(t, p.IsDefined()) + + require.EqualError(t, p.Check(), "invalid layout pies. must be single-file or follow-schema") + }) +} diff --git a/codegen/config/testdata/autobinding/chat/model.go b/codegen/config/testdata/autobinding/chat/model.go new file mode 100644 index 0000000..fa621ee --- /dev/null +++ b/codegen/config/testdata/autobinding/chat/model.go @@ -0,0 +1,22 @@ +package chat + +import ( + "time" +) + +type Message struct { + ID string `json:"id"` + Text string `json:"text"` + CreatedBy string `json:"createdBy"` + CreatedAt time.Time `json:"createdAt"` +} + +type ProductSku string + +const ( + ProductSkuTrial ProductSku = "Trial" +) + +type ChatAPI struct { + ID string `json:"id"` +} 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 0000000..944a48b --- /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/config/testdata/cfg/glob.yml b/codegen/config/testdata/cfg/glob.yml new file mode 100644 index 0000000..87edd2c --- /dev/null +++ b/codegen/config/testdata/cfg/glob.yml @@ -0,0 +1,9 @@ +schema: +- testdata/cfg/glob/**/*.graphql +exec: + filename: generated.go +model: + filename: models_gen.go +resolver: + filename: resolver.go + type: Resolver diff --git a/codegen/config/testdata/cfg/glob/bar/bar with spaces.graphql b/codegen/config/testdata/cfg/glob/bar/bar with spaces.graphql new file mode 100644 index 0000000..b01bcc4 --- /dev/null +++ b/codegen/config/testdata/cfg/glob/bar/bar with spaces.graphql @@ -0,0 +1,12 @@ +type Query { + todos: [Todo!]! +} + +input NewTodo { + text: String! + userId: String! +} + +type Mutation { + createTodo(input: NewTodo!): Todo! +} diff --git a/codegen/config/testdata/cfg/glob/foo/foo.graphql b/codegen/config/testdata/cfg/glob/foo/foo.graphql new file mode 100644 index 0000000..5f0496c --- /dev/null +++ b/codegen/config/testdata/cfg/glob/foo/foo.graphql @@ -0,0 +1,11 @@ +type Todo { + id: ID! + text: String! + done: Boolean! + user: User! +} + +type User { + id: ID! + name: String! +} diff --git a/codegen/config/testdata/cfg/goInitialisms.yml b/codegen/config/testdata/cfg/goInitialisms.yml new file mode 100644 index 0000000..662bbd7 --- /dev/null +++ b/codegen/config/testdata/cfg/goInitialisms.yml @@ -0,0 +1,5 @@ +go_initialisms: + replace_defaults: true + initialisms: + - 'CC' + - 'BCC' diff --git a/codegen/config/testdata/cfg/gqlgen.yml b/codegen/config/testdata/cfg/gqlgen.yml new file mode 100644 index 0000000..1381aaf --- /dev/null +++ b/codegen/config/testdata/cfg/gqlgen.yml @@ -0,0 +1 @@ +schema: outer diff --git a/codegen/config/testdata/cfg/malformedconfig.yml b/codegen/config/testdata/cfg/malformedconfig.yml new file mode 100644 index 0000000..8bd6648 --- /dev/null +++ b/codegen/config/testdata/cfg/malformedconfig.yml @@ -0,0 +1 @@ +asdf diff --git a/codegen/config/testdata/cfg/otherdir/.gitkeep b/codegen/config/testdata/cfg/otherdir/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/codegen/config/testdata/cfg/outer b/codegen/config/testdata/cfg/outer new file mode 100644 index 0000000..e69de29 diff --git a/codegen/config/testdata/cfg/subdir/gqlgen.yaml b/codegen/config/testdata/cfg/subdir/gqlgen.yaml new file mode 100644 index 0000000..303effe --- /dev/null +++ b/codegen/config/testdata/cfg/subdir/gqlgen.yaml @@ -0,0 +1 @@ +schema: inner diff --git a/codegen/config/testdata/cfg/subdir/inner b/codegen/config/testdata/cfg/subdir/inner new file mode 100644 index 0000000..e69de29 diff --git a/codegen/config/testdata/cfg/unknownkeys.yml b/codegen/config/testdata/cfg/unknownkeys.yml new file mode 100644 index 0000000..dbf095f --- /dev/null +++ b/codegen/config/testdata/cfg/unknownkeys.yml @@ -0,0 +1,2 @@ +schema: outer +unknown: foo diff --git a/codegen/config/testdata/cfg/unwalkable.yml b/codegen/config/testdata/cfg/unwalkable.yml new file mode 100644 index 0000000..2eac23e --- /dev/null +++ b/codegen/config/testdata/cfg/unwalkable.yml @@ -0,0 +1,9 @@ +schema: +- not_walkable/**/*.graphql +exec: + filename: generated.go +model: + filename: models_gen.go +resolver: + filename: resolver.go + type: Resolver diff --git a/codegen/config/testdata/defaultconfig/schema.graphql b/codegen/config/testdata/defaultconfig/schema.graphql new file mode 100644 index 0000000..e69de29 diff --git a/codegen/config/testdata/example.go b/codegen/config/testdata/example.go new file mode 100644 index 0000000..08e717f --- /dev/null +++ b/codegen/config/testdata/example.go @@ -0,0 +1 @@ +package config_test_data diff --git a/codegen/data.go b/codegen/data.go new file mode 100644 index 0000000..e2e2a09 --- /dev/null +++ b/codegen/data.go @@ -0,0 +1,235 @@ +package codegen + +import ( + "fmt" + "os" + "path/filepath" + "sort" + "strings" + + "github.com/vektah/gqlparser/v2/ast" + + "github.com/niko0xdev/gqlgen/codegen/config" +) + +// 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 + // 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 + ReferencedTypes map[string]*config.TypeReference + ComplexityRoots map[string]*Object + + QueryRoot *Object + MutationRoot *Object + SubscriptionRoot *Object + AugmentedSources []AugmentedSource + Plugins []interface{} +} + +func (d *Data) HasEmbeddableSources() bool { + hasEmbeddableSources := false + for _, s := range d.AugmentedSources { + if s.Embeddable { + hasEmbeddableSources = true + } + } + return hasEmbeddableSources +} + +// AugmentedSource contains extra information about graphql schema files which is not known directly from the Config.Sources data +type AugmentedSource struct { + // path relative to Config.Exec.Filename + RelativePath string + Embeddable bool + BuiltIn bool + Source string +} + +type builder struct { + Config *config.Config + Schema *ast.Schema + Binder *config.Binder + 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, plugins ...interface{}) (*Data, error) { + // We reload all packages to allow packages to be compared correctly. + cfg.ReloadAllPackages() + + b := builder{ + Config: cfg, + Schema: cfg.Schema, + } + + b.Binder = b.Config.NewBinder() + + var err error + b.Directives, err = b.buildDirectives() + if err != nil { + return nil, err + } + + dataDirectives := make(map[string]*Directive) + for name, d := range b.Directives { + if !d.Builtin { + dataDirectives[name] = d + } + } + + s := Data{ + Config: cfg, + AllDirectives: dataDirectives, + Schema: b.Schema, + Interfaces: map[string]*Interface{}, + Plugins: plugins, + } + + for _, schemaType := range b.Schema.Types { + switch schemaType.Kind { + case ast.Object: + obj, err := b.buildObject(schemaType) + if err != nil { + 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, fmt.Errorf("unable to build input definition: %w", err) + } + + s.Inputs = append(s.Inputs, input) + + case ast.Union, ast.Interface: + s.Interfaces[schemaType.Name], err = b.buildInterface(schemaType) + if err != nil { + return nil, fmt.Errorf("unable to bind to interface: %w", err) + } + } + } + + if s.Schema.Query != nil { + s.QueryRoot = s.Objects.ByName(s.Schema.Query.Name) + } else { + return nil, fmt.Errorf("query entry point missing") + } + + if s.Schema.Mutation != nil { + s.MutationRoot = s.Objects.ByName(s.Schema.Mutation.Name) + } + + if s.Schema.Subscription != nil { + s.SubscriptionRoot = s.Objects.ByName(s.Schema.Subscription.Name) + } + + if err := b.injectIntrospectionRoots(&s); err != nil { + return nil, err + } + + s.ReferencedTypes = b.buildTypes() + + sort.Slice(s.Objects, func(i, j int) bool { + return s.Objects[i].Definition.Name < s.Objects[j].Definition.Name + }) + + sort.Slice(s.Inputs, func(i, j int) bool { + return s.Inputs[i].Definition.Name < s.Inputs[j].Definition.Name + }) + + if b.Binder.SawInvalid { + // if we have a syntax error, show it + err := cfg.Packages.Errors() + if len(err) > 0 { + return nil, err + } + + // otherwise show a generic error message + return nil, fmt.Errorf("invalid types were encountered while traversing the go source code, this probably means the invalid code generated isnt correct. add try adding -v to debug") + } + aSources := []AugmentedSource{} + for _, s := range cfg.Sources { + wd, err := os.Getwd() + if err != nil { + return nil, fmt.Errorf("failed to get working directory: %w", err) + } + outputDir := cfg.Exec.Dir() + sourcePath := filepath.Join(wd, s.Name) + relative, err := filepath.Rel(outputDir, sourcePath) + if err != nil { + return nil, fmt.Errorf("failed to compute path of %s relative to %s: %w", sourcePath, outputDir, err) + } + relative = filepath.ToSlash(relative) + embeddable := true + if strings.HasPrefix(relative, "..") || s.BuiltIn { + embeddable = false + } + aSources = append(aSources, AugmentedSource{ + RelativePath: relative, + Embeddable: embeddable, + BuiltIn: s.BuiltIn, + Source: s.Input, + }) + } + s.AugmentedSources = aSources + + return &s, nil +} + +func (b *builder) injectIntrospectionRoots(s *Data) error { + obj := s.Objects.ByName(b.Schema.Query.Name) + if obj == nil { + return fmt.Errorf("root query type must be defined") + } + + __type, err := b.buildField(obj, &ast.FieldDefinition{ + Name: "__type", + Type: ast.NamedType("__Type", nil), + Arguments: []*ast.ArgumentDefinition{ + { + Name: "name", + Type: ast.NonNullNamedType("String", nil), + }, + }, + }) + if err != nil { + return err + } + + __schema, err := b.buildField(obj, &ast.FieldDefinition{ + Name: "__schema", + Type: ast.NamedType("__Schema", nil), + }) + if err != nil { + return err + } + + obj.Fields = append(obj.Fields, __type, __schema) + + return nil +} diff --git a/codegen/data_test.go b/codegen/data_test.go new file mode 100644 index 0000000..2af3436 --- /dev/null +++ b/codegen/data_test.go @@ -0,0 +1,68 @@ +package codegen + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/vektah/gqlparser/v2/ast" + + "github.com/niko0xdev/gqlgen/codegen/config" +) + +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 new file mode 100644 index 0000000..b122f17 --- /dev/null +++ b/codegen/directive.go @@ -0,0 +1,175 @@ +package codegen + +import ( + "fmt" + "strconv" + "strings" + + "github.com/vektah/gqlparser/v2/ast" + + "github.com/niko0xdev/gqlgen/codegen/templates" +) + +type DirectiveList map[string]*Directive + +// LocationDirectives filter directives by location +func (dl DirectiveList) LocationDirectives(location string) DirectiveList { + return locationDirectives(dl, ast.DirectiveLocation(location)) +} + +type Directive struct { + *ast.DirectiveDefinition + Name string + Args []*FieldArgument + Builtin bool +} + +// IsLocation check location directive +func (d *Directive) IsLocation(location ...ast.DirectiveLocation) bool { + for _, l := range d.Locations { + for _, a := range location { + if l == a { + return true + } + } + } + + return false +} + +func locationDirectives(directives DirectiveList, location ...ast.DirectiveLocation) map[string]*Directive { + mDirectives := make(map[string]*Directive) + for name, d := range directives { + if d.IsLocation(location...) { + mDirectives[name] = d + } + } + return mDirectives +} + +func (b *builder) buildDirectives() (map[string]*Directive, error) { + directives := make(map[string]*Directive, len(b.Schema.Directives)) + + for name, dir := range b.Schema.Directives { + if _, ok := directives[name]; ok { + return nil, fmt.Errorf("directive with name %s already exists", name) + } + + var args []*FieldArgument + for _, arg := range dir.Arguments { + tr, err := b.Binder.TypeReference(arg.Type, nil) + if err != nil { + return nil, err + } + + newArg := &FieldArgument{ + ArgumentDefinition: arg, + TypeReference: tr, + VarName: templates.ToGoPrivate(arg.Name), + } + + if arg.DefaultValue != nil { + var err error + newArg.Default, err = arg.DefaultValue.Value(nil) + if err != nil { + return nil, fmt.Errorf("default value for directive argument %s(%s) is not valid: %w", dir.Name, arg.Name, err) + } + } + args = append(args, newArg) + } + + directives[name] = &Directive{ + DirectiveDefinition: dir, + Name: name, + Args: args, + Builtin: b.Config.Directives[name].SkipRuntime, + } + } + + return directives, nil +} + +func (b *builder) getDirectives(list ast.DirectiveList) ([]*Directive, error) { + dirs := make([]*Directive, len(list)) + for i, d := range list { + argValues := make(map[string]interface{}, len(d.Arguments)) + for _, da := range d.Arguments { + val, err := da.Value.Value(nil) + if err != nil { + return nil, err + } + argValues[da.Name] = val + } + def, ok := b.Directives[d.Name] + if !ok { + return nil, fmt.Errorf("directive %s not found", d.Name) + } + + var args []*FieldArgument + for _, a := range def.Args { + value := a.Default + if argValue, ok := argValues[a.Name]; ok { + value = argValue + } + args = append(args, &FieldArgument{ + ArgumentDefinition: a.ArgumentDefinition, + Value: value, + VarName: a.VarName, + TypeReference: a.TypeReference, + }) + } + dirs[i] = &Directive{ + Name: d.Name, + Args: args, + DirectiveDefinition: list[i].Definition, + Builtin: b.Config.Directives[d.Name].SkipRuntime, + } + + } + + return dirs, nil +} + +func (d *Directive) ArgsFunc() string { + if len(d.Args) == 0 { + return "" + } + + return "dir_" + d.Name + "_args" +} + +func (d *Directive) CallArgs() string { + args := []string{"ctx", "obj", "n"} + + for _, arg := range d.Args { + args = append(args, "args["+strconv.Quote(arg.Name)+"].("+templates.CurrentImports.LookupType(arg.TypeReference.GO)+")") + } + + return strings.Join(args, ", ") +} + +func (d *Directive) ResolveArgs(obj string, next int) string { + args := []string{"ctx", obj, fmt.Sprintf("directive%d", next)} + + for _, arg := range d.Args { + dArg := arg.VarName + if arg.Value == nil && arg.Default == nil { + dArg = "nil" + } + + args = append(args, dArg) + } + + return strings.Join(args, ", ") +} + +func (d *Directive) Declaration() string { + res := ucFirst(d.Name) + " func(ctx context.Context, obj interface{}, next graphql.Resolver" + + for _, arg := range d.Args { + res += fmt.Sprintf(", %s %s", templates.ToGoPrivate(arg.Name), templates.CurrentImports.LookupType(arg.TypeReference.GO)) + } + + res += ") (res interface{}, err error)" + return res +} diff --git a/codegen/directives.gotpl b/codegen/directives.gotpl new file mode 100644 index 0000000..145df1c --- /dev/null +++ b/codegen/directives.gotpl @@ -0,0 +1,149 @@ +{{ define "implDirectives" }}{{ $in := .DirectiveObjName }} + {{- range $i, $directive := .ImplDirectives -}} + directive{{add $i 1}} := func(ctx context.Context) (interface{}, error) { + {{- range $arg := $directive.Args }} + {{- if notNil "Value" $arg }} + {{ $arg.VarName }}, err := ec.{{ $arg.TypeReference.UnmarshalFunc }}(ctx, {{ $arg.Value | dump }}) + if err != nil{ + return nil, err + } + {{- else if notNil "Default" $arg }} + {{ $arg.VarName }}, err := ec.{{ $arg.TypeReference.UnmarshalFunc }}(ctx, {{ $arg.Default | dump }}) + if err != nil{ + return nil, err + } + {{- end }} + {{- end }} + if ec.directives.{{$directive.Name|ucFirst}} == nil { + return nil, errors.New("directive {{$directive.Name}} is not implemented") + } + return ec.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs $in $i }}) + } + {{ end -}} +{{ end }} + +{{define "queryDirectives"}} + for _, d := range obj.Directives { + switch d.Name { + {{- range $directive := . }} + case "{{$directive.Name}}": + {{- if $directive.Args }} + rawArgs := d.ArgumentMap(ec.Variables) + args, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + {{- end }} + n := next + next = func(ctx context.Context) (interface{}, error) { + if ec.directives.{{$directive.Name|ucFirst}} == nil { + return nil, errors.New("directive {{$directive.Name}} is not implemented") + } + return ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}}) + } + {{- end }} + } + } + tmp, err := next(ctx) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if data, ok := tmp.(graphql.Marshaler); ok { + return data + } + ec.Errorf(ctx, `unexpected type %T from directive, should be graphql.Marshaler`, tmp) + return graphql.Null +{{end}} + +{{ if .Directives.LocationDirectives "QUERY" }} +func (ec *executionContext) _queryMiddleware(ctx context.Context, obj *ast.OperationDefinition, next func(ctx context.Context) (interface{}, error)) graphql.Marshaler { + {{ template "queryDirectives" .Directives.LocationDirectives "QUERY" }} +} +{{ end }} + +{{ if .Directives.LocationDirectives "MUTATION" }} +func (ec *executionContext) _mutationMiddleware(ctx context.Context, obj *ast.OperationDefinition, next func(ctx context.Context) (interface{}, error)) graphql.Marshaler { + {{ template "queryDirectives" .Directives.LocationDirectives "MUTATION" }} +} +{{ end }} + +{{ if .Directives.LocationDirectives "SUBSCRIPTION" }} +func (ec *executionContext) _subscriptionMiddleware(ctx context.Context, obj *ast.OperationDefinition, next func(ctx context.Context) (interface{}, error)) func(ctx context.Context) graphql.Marshaler { + for _, d := range obj.Directives { + switch d.Name { + {{- range $directive := .Directives.LocationDirectives "SUBSCRIPTION" }} + case "{{$directive.Name}}": + {{- if $directive.Args }} + rawArgs := d.ArgumentMap(ec.Variables) + args, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs) + if err != nil { + ec.Error(ctx, err) + return func(ctx context.Context) graphql.Marshaler { + return graphql.Null + } + } + {{- end }} + n := next + next = func(ctx context.Context) (interface{}, error) { + if ec.directives.{{$directive.Name|ucFirst}} == nil { + return nil, errors.New("directive {{$directive.Name}} is not implemented") + } + return ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}}) + } + {{- end }} + } + } + tmp, err := next(ctx) + if err != nil { + ec.Error(ctx, err) + return func(ctx context.Context) graphql.Marshaler { + return graphql.Null + } + } + if data, ok := tmp.(func(ctx context.Context) graphql.Marshaler); ok { + return data + } + ec.Errorf(ctx, `unexpected type %T from directive, should be graphql.Marshaler`, tmp) + return func(ctx context.Context) graphql.Marshaler { + return graphql.Null + } +} +{{ end }} + + + func (ec *executionContext) _fieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) interface{} { + {{- if .Directives.LocationDirectives "FIELD" }} + fc := graphql.GetFieldContext(ctx) + for _, d := range fc.Field.Directives { + switch d.Name { + {{- range $directive := .Directives.LocationDirectives "FIELD" }} + case "{{$directive.Name}}": + {{- if $directive.Args }} + rawArgs := d.ArgumentMap(ec.Variables) + args, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs) + if err != nil { + ec.Error(ctx, err) + return nil + } + {{- end }} + n := next + next = func(ctx context.Context) (interface{}, error) { + if ec.directives.{{$directive.Name|ucFirst}} == nil { + return nil, errors.New("directive {{$directive.Name}} is not implemented") + } + return ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}}) + } + {{- end }} + } + } + {{- end }} + res, err := ec.ResolverMiddleware(ctx, next) + if err != nil { + ec.Error(ctx, err) + return nil + } + return res + } + diff --git a/codegen/field.go b/codegen/field.go new file mode 100644 index 0000000..d385a49 --- /dev/null +++ b/codegen/field.go @@ -0,0 +1,617 @@ +package codegen + +import ( + "errors" + "fmt" + goast "go/ast" + "go/types" + "log" + "reflect" + "strconv" + "strings" + + "github.com/vektah/gqlparser/v2/ast" + "golang.org/x/text/cases" + "golang.org/x/text/language" + + "github.com/niko0xdev/gqlgen/codegen/config" + "github.com/niko0xdev/gqlgen/codegen/templates" +) + +type Field struct { + *ast.FieldDefinition + + TypeReference *config.TypeReference + GoFieldType GoFieldType // The field type in go, if any + GoReceiverName string // The name of method & var receiver in go, if any + GoFieldName string // The name of the method or var in go, if any + IsResolver bool // Does this field need a resolver + 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? + Directives []*Directive +} + +func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, error) { + dirs, err := b.getDirectives(field.Directives) + if err != nil { + return nil, err + } + + f := Field{ + FieldDefinition: field, + Object: obj, + Directives: dirs, + GoFieldName: templates.ToGo(field.Name), + GoFieldType: GoFieldVariable, + GoReceiverName: "obj", + } + + if field.DefaultValue != nil { + var err error + f.Default, err = field.DefaultValue.Value(nil) + if err != nil { + return nil, fmt.Errorf("default value %s is not valid: %w", field.Name, err) + } + } + + for _, arg := range field.Arguments { + newArg, err := b.buildArg(obj, arg) + if err != nil { + return nil, err + } + f.Args = append(f.Args, newArg) + } + + if err = b.bindField(obj, &f); err != nil { + f.IsResolver = true + if errors.Is(err, config.ErrTypeNotFound) { + return nil, err + } + log.Println(err.Error()) + } + + if f.IsResolver && b.Config.ResolversAlwaysReturnPointers && !f.TypeReference.IsPtr() && f.TypeReference.IsStruct() { + f.TypeReference = b.Binder.PointerTo(f.TypeReference) + } + + return &f, nil +} + +func (b *builder) bindField(obj *Object, f *Field) (errret error) { + defer func() { + if f.TypeReference == nil { + tr, err := b.Binder.TypeReference(f.Type, nil) + if err != nil { + errret = err + } + f.TypeReference = tr + } + if f.TypeReference != nil { + dirs, err := b.getDirectives(f.TypeReference.Definition.Directives) + 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...) + } + }() + + f.Stream = obj.Stream + + switch { + case f.Name == "__schema": + f.GoFieldType = GoFieldMethod + f.GoReceiverName = "ec" + f.GoFieldName = "introspectSchema" + return nil + case f.Name == "__type": + f.GoFieldType = GoFieldMethod + f.GoReceiverName = "ec" + f.GoFieldName = "introspectType" + return nil + case f.Name == "_entities": + f.GoFieldType = GoFieldMethod + f.GoReceiverName = "ec" + f.GoFieldName = "__resolve_entities" + f.MethodHasContext = true + f.NoErr = true + return nil + case f.Name == "_service": + f.GoFieldType = GoFieldMethod + f.GoReceiverName = "ec" + f.GoFieldName = "__resolve__service" + f.MethodHasContext = true + return nil + case obj.Root: + f.IsResolver = true + return nil + case b.Config.Models[obj.Name].Fields[f.Name].Resolver: + f.IsResolver = true + return nil + case obj.Type == config.MapType: + f.GoFieldType = GoFieldMap + return nil + case b.Config.Models[obj.Name].Fields[f.Name].FieldName != "": + f.GoFieldName = b.Config.Models[obj.Name].Fields[f.Name].FieldName + } + + target, err := b.findBindTarget(obj.Type.(*types.Named), f.GoFieldName) + if err != nil { + return err + } + + pos := b.Binder.ObjectPosition(target) + + switch target := target.(type) { + case nil: + // Skips creating a resolver for any root types + if b.Config.IsRoot(b.Schema.Types[f.Type.Name()]) { + return nil + } + + objPos := b.Binder.TypePosition(obj.Type) + return fmt.Errorf( + "%s:%d adding resolver method for %s.%s, nothing matched", + objPos.Filename, + objPos.Line, + obj.Name, + f.Name, + ) + + case *types.Func: + 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") + } + params := sig.Params() + // If the first argument is the context, remove it from the comparison and set + // the MethodHasContext flag so that the context will be passed to this model's method + if params.Len() > 0 && params.At(0).Type().String() == "context.Context" { + f.MethodHasContext = true + vars := make([]*types.Var, params.Len()-1) + for i := 1; i < params.Len(); i++ { + vars[i-1] = params.At(i) + } + params = types.NewTuple(vars...) + } + + // Try to match target function's arguments with GraphQL field arguments. + newArgs, err := b.bindArgs(f, sig, params) + if err != nil { + return fmt.Errorf("%s:%d: %w", pos.Filename, pos.Line, err) + } + + // Try to match target function's return types with GraphQL field return type + result := sig.Results().At(0) + tr, err := b.Binder.TypeReference(f.Type, result.Type()) + if err != nil { + return err + } + + // success, args and return type match. Bind to method + f.GoFieldType = GoFieldMethod + f.GoReceiverName = "obj" + f.GoFieldName = target.Name() + f.Args = newArgs + f.TypeReference = tr + + return nil + + case *types.Var: + tr, err := b.Binder.TypeReference(f.Type, target.Type()) + if err != nil { + return err + } + + // success, bind to var + f.GoFieldType = GoFieldVariable + f.GoReceiverName = "obj" + f.GoFieldName = target.Name() + f.TypeReference = tr + + return nil + default: + panic(fmt.Errorf("unknown bind target %T for %s", target, f.Name)) + } +} + +// findBindTarget attempts to match the name to a field or method on a Type +// with the following priorites: +// 1. Any Fields with a struct tag (see config.StructTag). Errors if more than one match is found +// 2. Any method or field with a matching name. Errors if more than one match is found +// 3. Same logic again for embedded fields +func (b *builder) findBindTarget(t types.Type, name string) (types.Object, error) { + // NOTE: a struct tag will override both methods and fields + // Bind to struct tag + found, err := b.findBindStructTagTarget(t, name) + if found != nil || err != nil { + return found, err + } + + // Search for a method to bind to + foundMethod, err := b.findBindMethodTarget(t, name) + if err != nil { + return nil, err + } + + // Search for a field to bind to + foundField, err := b.findBindFieldTarget(t, name) + if err != nil { + return nil, err + } + + switch { + case foundField == nil && foundMethod != nil: + // Bind to method + return foundMethod, nil + case foundField != nil && foundMethod == nil: + // Bind to field + return foundField, nil + case foundField != nil && foundMethod != nil: + // Error + return nil, fmt.Errorf("found more than one way to bind for %s", name) + } + + // Search embeds + return b.findBindEmbedsTarget(t, name) +} + +func (b *builder) findBindStructTagTarget(in types.Type, name string) (types.Object, error) { + if b.Config.StructTag == "" { + return nil, nil + } + + switch t := in.(type) { + case *types.Named: + return b.findBindStructTagTarget(t.Underlying(), name) + case *types.Struct: + var found types.Object + for i := 0; i < t.NumFields(); i++ { + field := t.Field(i) + if !field.Exported() || field.Embedded() { + continue + } + tags := reflect.StructTag(t.Tag(i)) + if val, ok := tags.Lookup(b.Config.StructTag); ok && equalFieldName(val, name) { + if found != nil { + return nil, fmt.Errorf("tag %s is ambigious; multiple fields have the same tag value of %s", b.Config.StructTag, val) + } + + found = field + } + } + + return found, nil + } + + return nil, nil +} + +func (b *builder) findBindMethodTarget(in types.Type, name string) (types.Object, error) { + switch t := in.(type) { + case *types.Named: + if _, ok := t.Underlying().(*types.Interface); ok { + return b.findBindMethodTarget(t.Underlying(), name) + } + + return b.findBindMethoderTarget(t.Method, t.NumMethods(), name) + case *types.Interface: + // FIX-ME: Should use ExplicitMethod here? What's the difference? + return b.findBindMethoderTarget(t.Method, t.NumMethods(), name) + } + + return nil, nil +} + +func (b *builder) findBindMethoderTarget(methodFunc func(i int) *types.Func, methodCount int, name string) (types.Object, error) { + var found types.Object + for i := 0; i < methodCount; i++ { + method := methodFunc(i) + if !method.Exported() || !strings.EqualFold(method.Name(), name) { + continue + } + + if found != nil { + return nil, fmt.Errorf("found more than one matching method to bind for %s", name) + } + + found = method + } + + return found, nil +} + +func (b *builder) findBindFieldTarget(in types.Type, name string) (types.Object, error) { + switch t := in.(type) { + case *types.Named: + return b.findBindFieldTarget(t.Underlying(), name) + case *types.Struct: + var found types.Object + for i := 0; i < t.NumFields(); i++ { + field := t.Field(i) + if !field.Exported() || !equalFieldName(field.Name(), name) { + continue + } + + if found != nil { + return nil, fmt.Errorf("found more than one matching field to bind for %s", name) + } + + found = field + } + + return found, nil + } + + return nil, nil +} + +func (b *builder) findBindEmbedsTarget(in types.Type, name string) (types.Object, error) { + switch t := in.(type) { + case *types.Named: + return b.findBindEmbedsTarget(t.Underlying(), name) + case *types.Struct: + return b.findBindStructEmbedsTarget(t, name) + case *types.Interface: + return b.findBindInterfaceEmbedsTarget(t, name) + } + + return nil, nil +} + +func (b *builder) findBindStructEmbedsTarget(strukt *types.Struct, name string) (types.Object, error) { + var found types.Object + for i := 0; i < strukt.NumFields(); i++ { + field := strukt.Field(i) + if !field.Embedded() { + continue + } + + fieldType := field.Type() + if ptr, ok := fieldType.(*types.Pointer); ok { + fieldType = ptr.Elem() + } + + f, err := b.findBindTarget(fieldType, name) + if err != nil { + return nil, err + } + + if f != nil && found != nil { + return nil, fmt.Errorf("found more than one way to bind for %s", name) + } + + if f != nil { + found = f + } + } + + return found, nil +} + +func (b *builder) findBindInterfaceEmbedsTarget(iface *types.Interface, name string) (types.Object, error) { + var found types.Object + for i := 0; i < iface.NumEmbeddeds(); i++ { + embeddedType := iface.EmbeddedType(i) + + f, err := b.findBindTarget(embeddedType, name) + if err != nil { + return nil, err + } + + if f != nil && found != nil { + return nil, fmt.Errorf("found more than one way to bind for %s", name) + } + + if f != nil { + found = f + } + } + + return found, nil +} + +func (f *Field) HasDirectives() bool { + return len(f.ImplDirectives()) > 0 +} + +func (f *Field) DirectiveObjName() string { + if f.Object.Root { + return "nil" + } + return f.GoReceiverName +} + +func (f *Field) ImplDirectives() []*Directive { + var d []*Directive + loc := ast.LocationFieldDefinition + if f.Object.IsInputType() { + loc = ast.LocationInputFieldDefinition + } + for i := range f.Directives { + 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]) + } + } + return d +} + +func (f *Field) IsReserved() bool { + return strings.HasPrefix(f.Name, "__") +} + +func (f *Field) IsMethod() bool { + return f.GoFieldType == GoFieldMethod +} + +func (f *Field) IsVariable() bool { + return f.GoFieldType == GoFieldVariable +} + +func (f *Field) IsMap() bool { + return f.GoFieldType == GoFieldMap +} + +func (f *Field) IsConcurrent() bool { + if f.Object.DisableConcurrency { + return false + } + return f.MethodHasContext || f.IsResolver +} + +func (f *Field) GoNameUnexported() string { + return templates.ToGoPrivate(f.Name) +} + +func (f *Field) ShortInvocation() string { + caser := cases.Title(language.English, cases.NoLower) + if f.Object.Kind == ast.InputObject { + return fmt.Sprintf("%s().%s(ctx, &it, data)", caser.String(f.Object.Definition.Name), f.GoFieldName) + } + return fmt.Sprintf("%s().%s(%s)", caser.String(f.Object.Definition.Name), f.GoFieldName, f.CallArgs()) +} + +func (f *Field) ArgsFunc() string { + if len(f.Args) == 0 { + return "" + } + + return "field_" + f.Object.Definition.Name + "_" + f.Name + "_args" +} + +func (f *Field) FieldContextFunc() string { + return "fieldContext_" + f.Object.Definition.Name + "_" + f.Name +} + +func (f *Field) ChildFieldContextFunc(name string) string { + return "fieldContext_" + f.TypeReference.Definition.Name + "_" + name +} + +func (f *Field) ResolverType() string { + if !f.IsResolver { + return "" + } + + return fmt.Sprintf("%s().%s(%s)", f.Object.Definition.Name, f.GoFieldName, f.CallArgs()) +} + +func (f *Field) IsInputObject() bool { + return f.Object.Kind == ast.InputObject +} + +func (f *Field) IsRoot() bool { + return f.Object.Root +} + +func (f *Field) ShortResolverDeclaration() string { + return f.ShortResolverSignature(nil) +} + +// ShortResolverSignature is identical to ShortResolverDeclaration, +// but respects previous naming (return) conventions, if any. +func (f *Field) ShortResolverSignature(ft *goast.FuncType) string { + if f.Object.Kind == ast.InputObject { + return fmt.Sprintf("(ctx context.Context, obj %s, data %s) error", + templates.CurrentImports.LookupType(f.Object.Reference()), + templates.CurrentImports.LookupType(f.TypeReference.GO), + ) + } + + res := "(ctx context.Context" + + if !f.Object.Root { + res += fmt.Sprintf(", obj %s", templates.CurrentImports.LookupType(f.Object.Reference())) + } + for _, arg := range f.Args { + res += fmt.Sprintf(", %s %s", arg.VarName, templates.CurrentImports.LookupType(arg.TypeReference.GO)) + } + + result := templates.CurrentImports.LookupType(f.TypeReference.GO) + if f.Object.Stream { + result = "<-chan " + result + } + // Named return. + var namedV, namedE string + if ft != nil { + if ft.Results != nil && len(ft.Results.List) > 0 && len(ft.Results.List[0].Names) > 0 { + namedV = ft.Results.List[0].Names[0].Name + } + if ft.Results != nil && len(ft.Results.List) > 1 && len(ft.Results.List[1].Names) > 0 { + namedE = ft.Results.List[1].Names[0].Name + } + } + res += fmt.Sprintf(") (%s %s, %s error)", namedV, result, namedE) + return res +} + +func (f *Field) GoResultName() (string, bool) { + name := fmt.Sprintf("%v", f.TypeReference.GO) + splits := strings.Split(name, "/") + + return splits[len(splits)-1], strings.HasPrefix(name, "[]") +} + +func (f *Field) ComplexitySignature() string { + res := "func(childComplexity int" + for _, arg := range f.Args { + res += fmt.Sprintf(", %s %s", arg.VarName, templates.CurrentImports.LookupType(arg.TypeReference.GO)) + } + res += ") int" + return res +} + +func (f *Field) ComplexityArgs() string { + args := make([]string, len(f.Args)) + for i, arg := range f.Args { + args[i] = "args[" + strconv.Quote(arg.Name) + "].(" + templates.CurrentImports.LookupType(arg.TypeReference.GO) + ")" + } + + return strings.Join(args, ", ") +} + +func (f *Field) CallArgs() string { + args := make([]string, 0, len(f.Args)+2) + + if f.IsResolver { + args = append(args, "rctx") + + if !f.Object.Root { + args = append(args, "obj") + } + } else if f.MethodHasContext { + args = append(args, "ctx") + } + + for _, arg := range f.Args { + tmp := "fc.Args[" + strconv.Quote(arg.Name) + "].(" + templates.CurrentImports.LookupType(arg.TypeReference.GO) + ")" + + if iface, ok := arg.TypeReference.GO.(*types.Interface); ok && iface.Empty() { + tmp = fmt.Sprintf(` + func () interface{} { + if fc.Args["%s"] == nil { + return nil + } + return fc.Args["%s"].(interface{}) + }()`, arg.Name, arg.Name, + ) + } + + args = append(args, tmp) + } + + return strings.Join(args, ", ") +} diff --git a/codegen/field.gotpl b/codegen/field.gotpl new file mode 100644 index 0000000..52659a5 --- /dev/null +++ b/codegen/field.gotpl @@ -0,0 +1,162 @@ +{{- range $object := .Objects }}{{- range $field := $object.Fields }} + +func (ec *executionContext) _{{$object.Name}}_{{$field.Name}}(ctx context.Context, field graphql.CollectedField{{ if not $object.Root }}, obj {{$object.Reference | ref}}{{end}}) (ret {{ if $object.Stream }}func(ctx context.Context){{ end }}graphql.Marshaler) { + {{- $null := "graphql.Null" }} + {{- if $object.Stream }} + {{- $null = "nil" }} + {{- end }} + fc, err := ec.{{ $field.FieldContextFunc }}(ctx, field) + if err != nil { + return {{ $null }} + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func () { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = {{ $null }} + } + }() + {{- if $field.TypeReference.IsRoot }} + {{- if $field.TypeReference.IsPtr }} + res := &{{ $field.TypeReference.Elem.GO | ref }}{} + {{- else }} + res := {{ $field.TypeReference.GO | ref }}{} + {{- end }} + fc.Result = res + return ec.{{ $field.TypeReference.MarshalFunc }}(ctx, field.Selections, res) + {{- else}} + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + {{ template "field" $field }} + }) + if err != nil { + ec.Error(ctx, err) + return {{ $null }} + } + if resTmp == nil { + {{- if $field.TypeReference.GQL.NonNull }} + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + {{- end }} + return {{ $null }} + } + {{- if $object.Stream }} + return func(ctx context.Context) graphql.Marshaler { + select { + case res, ok := <-resTmp.(<-chan {{$field.TypeReference.GO | ref}}): + if !ok { + return nil + } + return graphql.WriterFunc(func(w io.Writer) { + w.Write([]byte{'{'}) + graphql.MarshalString(field.Alias).MarshalGQL(w) + w.Write([]byte{':'}) + ec.{{ $field.TypeReference.MarshalFunc }}(ctx, field.Selections, res).MarshalGQL(w) + w.Write([]byte{'}'}) + }) + case <-ctx.Done(): + return nil + } + } + {{- else }} + res := resTmp.({{$field.TypeReference.GO | ref}}) + fc.Result = res + return ec.{{ $field.TypeReference.MarshalFunc }}(ctx, field.Selections, res) + {{- end }} + {{- end }} +} + +func (ec *executionContext) {{ $field.FieldContextFunc }}(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: {{quote $field.Object.Name}}, + Field: field, + IsMethod: {{or $field.IsMethod $field.IsResolver}}, + IsResolver: {{ $field.IsResolver }}, + Child: func (ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + {{- if not $field.TypeReference.Definition.Fields }} + return nil, errors.New("field of type {{ $field.TypeReference.Definition.Name }} does not have child fields") + {{- else if ne $field.TypeReference.Definition.Kind "OBJECT" }} + return nil, errors.New("FieldContext.Child cannot be called on type {{ $field.TypeReference.Definition.Kind }}") + {{- else }} + switch field.Name { + {{- range $f := $field.TypeReference.Definition.Fields }} + case "{{ $f.Name }}": + return ec.{{ $field.ChildFieldContextFunc $f.Name }}(ctx, field) + {{- end }} + } + return nil, fmt.Errorf("no field named %q was found under type {{ $field.TypeReference.Definition.Name }}", field.Name) + {{- end }} + }, + } + {{- if $field.Args }} + defer func () { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.{{ $field.ArgsFunc }}(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + {{- end }} + return fc, nil +} + +{{- end }}{{- end}} + +{{ define "field" }} + {{- if .HasDirectives -}} + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + {{ template "fieldDefinition" . }} + } + {{ template "implDirectives" . }} + tmp, err := directive{{.ImplDirectives|len}}(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.({{if .Stream}}<-chan {{end}}{{ .TypeReference.GO | ref }}) ; ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be {{if .Stream}}<-chan {{end}}{{ .TypeReference.GO }}`, tmp) + {{- else -}} + ctx = rctx // use context from middleware stack in children + {{ template "fieldDefinition" . }} + {{- end -}} +{{ end }} + +{{ define "fieldDefinition" }} + {{- if .IsResolver -}} + return ec.resolvers.{{ .ShortInvocation }} + {{- else if .IsMap -}} + switch v := {{.GoReceiverName}}[{{.Name|quote}}].(type) { + case {{if .Stream}}<-chan {{end}}{{.TypeReference.GO | ref}}: + return v, nil + case {{if .Stream}}<-chan {{end}}{{.TypeReference.Elem.GO | ref}}: + return &v, nil + case nil: + return ({{.TypeReference.GO | ref}})(nil), nil + default: + return nil, fmt.Errorf("unexpected type %T for field %s", v, {{ .Name | quote}}) + } + {{- else if .IsMethod -}} + {{- 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 }}) + {{- end -}} + {{- else if .IsVariable -}} + return {{.GoReceiverName}}.{{.GoFieldName}}, nil + {{- end }} +{{- end }} diff --git a/codegen/field_test.go b/codegen/field_test.go new file mode 100644 index 0000000..0b32b9a --- /dev/null +++ b/codegen/field_test.go @@ -0,0 +1,196 @@ +package codegen + +import ( + "go/ast" + "go/importer" + "go/parser" + "go/token" + "go/types" + "testing" + + "github.com/stretchr/testify/require" + ast2 "github.com/vektah/gqlparser/v2/ast" + + "github.com/niko0xdev/gqlgen/codegen/config" +) + +func TestFindField(t *testing.T) { + input := ` +package test + +type Std struct { + Name string + Value int +} +type Anon struct { + Name string + Tags +} +type Tags struct { + Bar string ` + "`" + `gqlgen:"foo"` + "`" + ` + Foo int ` + "`" + `gqlgen:"bar"` + "`" + ` +} +type Amb struct { + Bar string ` + "`" + `gqlgen:"foo"` + "`" + ` + Foo int ` + "`" + `gqlgen:"foo"` + "`" + ` +} +type Embed struct { + Std + Test string +} +` + scope, err := parseScope(input, "test") + require.NoError(t, err) + + std := scope.Lookup("Std").Type().(*types.Named) + anon := scope.Lookup("Anon").Type().(*types.Named) + tags := scope.Lookup("Tags").Type().(*types.Named) + amb := scope.Lookup("Amb").Type().(*types.Named) + embed := scope.Lookup("Embed").Type().(*types.Named) + + tests := []struct { + Name string + Named *types.Named + Field string + Tag string + Expected string + ShouldError bool + }{ + {"Finds a field by name with no tag", std, "name", "", "Name", false}, + {"Finds a field by name when passed tag but tag not used", std, "name", "gqlgen", "Name", false}, + {"Ignores tags when not passed a tag", tags, "foo", "", "Foo", false}, + {"Picks field with tag over field name when passed a tag", tags, "foo", "gqlgen", "Bar", false}, + {"Errors when ambigious", amb, "foo", "gqlgen", "", true}, + {"Finds a field that is in embedded struct", anon, "bar", "", "Bar", false}, + {"Finds field that is not in embedded struct", embed, "test", "", "Test", false}, + } + + for _, tt := range tests { + b := builder{Config: &config.Config{StructTag: tt.Tag}} + target, err := b.findBindTarget(tt.Named, tt.Field) + if tt.ShouldError { + require.Nil(t, target, tt.Name) + require.Error(t, err, tt.Name) + } else { + require.NoError(t, err, tt.Name) + require.Equal(t, tt.Expected, target.Name(), tt.Name) + } + } +} + +func parseScope(input interface{}, packageName string) (*types.Scope, error) { + // test setup to parse the types + fset := token.NewFileSet() + f, err := parser.ParseFile(fset, "test.go", input, 0) + if err != nil { + return nil, err + } + + conf := types.Config{Importer: importer.Default()} + pkg, err := conf.Check(packageName, fset, []*ast.File{f}, nil) + if err != nil { + return nil, err + } + + return pkg.Scope(), nil +} + +func TestEqualFieldName(t *testing.T) { + tt := []struct { + Name string + Source string + Target string + Expected bool + }{ + {Name: "words with same case", Source: "test", Target: "test", Expected: true}, + {Name: "words different case", Source: "test", Target: "tEsT", Expected: true}, + {Name: "different words", Source: "foo", Target: "bar", Expected: false}, + {Name: "separated with underscore", Source: "the_test", Target: "TheTest", Expected: true}, + {Name: "empty values", Source: "", Target: "", Expected: true}, + } + + for _, tc := range tt { + t.Run(tc.Name, func(t *testing.T) { + result := equalFieldName(tc.Source, tc.Target) + require.Equal(t, tc.Expected, result) + }) + } +} + +func TestField_CallArgs(t *testing.T) { + tt := []struct { + Name string + Field + Expected string + }{ + { + Name: "Field with method that has context, and three args (string, interface, named interface)", + Field: Field{ + MethodHasContext: true, + Args: []*FieldArgument{ + { + ArgumentDefinition: &ast2.ArgumentDefinition{ + Name: "test", + }, + TypeReference: &config.TypeReference{ + GO: (&types.Interface{}).Complete(), + }, + }, + { + ArgumentDefinition: &ast2.ArgumentDefinition{ + Name: "test2", + }, + TypeReference: &config.TypeReference{ + GO: types.NewNamed( + types.NewTypeName(token.NoPos, nil, "TestInterface", nil), + (&types.Interface{}).Complete(), + nil, + ), + }, + }, + { + ArgumentDefinition: &ast2.ArgumentDefinition{ + Name: "test3", + }, + TypeReference: &config.TypeReference{ + GO: types.Typ[types.String], + }, + }, + }, + }, + Expected: `ctx, ` + ` + func () interface{} { + if fc.Args["test"] == nil { + return nil + } + return fc.Args["test"].(interface{}) + }(), fc.Args["test2"].(TestInterface), fc.Args["test3"].(string)`, + }, + { + Name: "Resolver field that isn't root object with single int argument", + Field: Field{ + Object: &Object{ + Root: false, + }, + IsResolver: true, + Args: []*FieldArgument{ + { + ArgumentDefinition: &ast2.ArgumentDefinition{ + Name: "test", + }, + TypeReference: &config.TypeReference{ + GO: types.Typ[types.Int], + }, + }, + }, + }, + Expected: `rctx, obj, fc.Args["test"].(int)`, + }, + } + + for _, tc := range tt { + t.Run(tc.Name, func(t *testing.T) { + require.Equal(t, tc.CallArgs(), tc.Expected) + }) + } +} diff --git a/codegen/generate.go b/codegen/generate.go new file mode 100644 index 0000000..15aeeb3 --- /dev/null +++ b/codegen/generate.go @@ -0,0 +1,221 @@ +package codegen + +import ( + "embed" + "errors" + "fmt" + "os" + "path/filepath" + "runtime" + "strings" + + "github.com/vektah/gqlparser/v2/ast" + + "github.com/niko0xdev/gqlgen/codegen/config" + "github.com/niko0xdev/gqlgen/codegen/templates" +) + +//go:embed *.gotpl +var codegenTemplates embed.FS + +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, + Data: data, + RegionTags: true, + GeneratedHeader: true, + Packages: data.Config.Packages, + TemplateFS: codegenTemplates, + }) +} + +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, + TemplateFS: codegenTemplates, + }) + 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 := os.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, + TemplateFS: codegenTemplates, + }) +} + +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 new file mode 100644 index 0000000..aa1ee75 --- /dev/null +++ b/codegen/generated!.gotpl @@ -0,0 +1,306 @@ +{{ reserveImport "context" }} +{{ reserveImport "fmt" }} +{{ reserveImport "io" }} +{{ reserveImport "strconv" }} +{{ reserveImport "time" }} +{{ reserveImport "sync" }} +{{ reserveImport "sync/atomic" }} +{{ reserveImport "errors" }} +{{ reserveImport "bytes" }} +{{ reserveImport "embed" }} + +{{ reserveImport "github.com/vektah/gqlparser/v2" "gqlparser" }} +{{ reserveImport "github.com/vektah/gqlparser/v2/ast" }} +{{ reserveImport "github.com/niko0xdev/gqlgen/graphql" }} +{{ reserveImport "github.com/niko0xdev/gqlgen/graphql/introspection" }} + +{{ if eq .Config.Exec.Layout "single-file" }} + // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. + func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } + } + + type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot + } + + type ResolverRoot interface { + {{- range $object := .Objects -}} + {{ if $object.HasResolvers -}} + {{ucFirst $object.Name}}() {{ucFirst $object.Name}}Resolver + {{ end }} + {{- end }} + {{- range $object := .Inputs -}} + {{ if $object.HasResolvers -}} + {{ucFirst $object.Name}}() {{ucFirst $object.Name}}Resolver + {{ end }} +{{- end }} +} + + type DirectiveRoot struct { + {{ range $directive := .Directives }} + {{- $directive.Declaration }} + {{ end }} + } + + type ComplexityRoot struct { + {{- if not .Config.OmitComplexity }} + {{ 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 {{ucFirst $object.Name}}Resolver interface { + {{ range $field := $object.Fields -}} + {{- if $field.IsResolver }} + {{- $field.GoFieldName}}{{ $field.ShortResolverDeclaration }} + {{- end }} + {{ end }} + } + {{- end }} +{{- end }} + +{{ range $object := .Inputs -}} + {{ if $object.HasResolvers }} + type {{$object.Name}}Resolver interface { + {{ range $field := $object.Fields -}} + {{- if $field.IsResolver }} + {{- $field.GoFieldName}}{{ $field.ShortResolverDeclaration }} + {{- end }} + {{ end }} + } + {{- end }} +{{- end }} + +{{ if eq .Config.Exec.Layout "single-file" }} + type executableSchema struct { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot + } + + func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema + } + + func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = ec + {{ if not .Config.OmitComplexity -}} + 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 }} + } + {{- end }} + return 0, false + } + + func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap( + {{- range $input := .Inputs -}} + {{ if not $input.HasUnmarshal }} + ec.unmarshalInput{{ $input.Name }}, + {{- end }} + {{- end }} + ) + first := true + + switch rc.Operation.Operation { + {{- if .QueryRoot }} case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + {{ 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 }} + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + {{ end }} + + {{- if .MutationRoot }} case ast.Mutation: + return func(ctx context.Context) *graphql.Response { + if !first { return nil } + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + {{ 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(ctx) + + 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 + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult + } + + func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func () { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() + } + + func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil + } + + func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil + } + + {{if .HasEmbeddableSources }} + //go:embed{{- range $source := .AugmentedSources }}{{if $source.Embeddable}} {{$source.RelativePath|quote}}{{end}}{{- end }} + var sourcesFS embed.FS + + func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) + } + {{- end }} + + var sources = []*ast.Source{ + {{- range $source := .AugmentedSources }} + {Name: {{$source.RelativePath|quote}}, Input: {{if (not $source.Embeddable)}}{{$source.Source|rawQuote}}{{else}}sourceData({{$source.RelativePath|quote}}){{end}}, BuiltIn: {{$source.BuiltIn}}}, + {{- end }} + } + var parsedSchema = gqlparser.MustLoadSchema(sources...) +{{ end }} diff --git a/codegen/input.gotpl b/codegen/input.gotpl new file mode 100644 index 0000000..9240b56 --- /dev/null +++ b/codegen/input.gotpl @@ -0,0 +1,100 @@ +{{- range $input := .Inputs }} + {{- if not .HasUnmarshal }} + {{- $it := "it" }} + {{- if .PointersInUmarshalInput }} + {{- $it = "&it" }} + {{- end }} + func (ec *executionContext) unmarshalInput{{ .Name }}(ctx context.Context, obj interface{}) ({{ if .PointersInUmarshalInput }}*{{ end }}{{.Type | ref}}, error) { + {{- if $input.IsMap }} + it := make(map[string]interface{}, len(obj.(map[string]interface{}))) + {{- else }} + var it {{.Type | ref}} + {{- end }} + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + {{ range $field := .Fields}} + {{- if notNil "Default" $field }} + if _, present := asMap[{{$field.Name|quote}}] ; !present { + asMap[{{$field.Name|quote}}] = {{ $field.Default | dump }} + } + {{- end}} + {{- end }} + + fieldsInOrder := [...]string{ {{ range .Fields }}{{ quote .Name }},{{ end }} } + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + {{- range $field := .Fields }} + case {{$field.Name|quote}}: + {{- $lhs := (printf "it.%s" $field.GoFieldName) }} + {{- if $input.IsMap }} + {{- $lhs = (printf "it[%q]" $field.Name) }} + {{- end }} + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField({{$field.Name|quote}})) + {{- if $field.ImplDirectives }} + directive0 := func(ctx context.Context) (interface{}, error) { return ec.{{ $field.TypeReference.UnmarshalFunc }}(ctx, v) } + {{ template "implDirectives" $field }} + tmp, err := directive{{$field.ImplDirectives|len}}(ctx) + if err != nil { + return {{$it}}, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.({{ $field.TypeReference.GO | ref }}) ; ok { + {{- if $field.IsResolver }} + if err = ec.resolvers.{{ $field.ShortInvocation }}; err != nil { + return {{$it}}, err + } + {{- else }} + {{- if $field.TypeReference.IsOmittable }} + {{ $lhs }} = graphql.OmittableOf(data) + {{- else }} + {{ $lhs }} = data + {{- end }} + {{- end }} + {{- if $field.TypeReference.IsNilable }} + {{- if not $field.IsResolver }} + } else if tmp == nil { + {{- if $field.TypeReference.IsOmittable }} + {{ $lhs }} = graphql.OmittableOf[{{ $field.TypeReference.GO | ref }}](nil) + {{- else }} + {{ $lhs }} = nil + {{- end }} + {{- end }} + {{- end }} + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be {{ $field.TypeReference.GO }}`, tmp) + return {{$it}}, graphql.ErrorOnPath(ctx, err) + } + {{- else }} + {{- if $field.IsResolver }} + data, err := ec.{{ $field.TypeReference.UnmarshalFunc }}(ctx, v) + if err != nil { + return {{$it}}, err + } + if err = ec.resolvers.{{ $field.ShortInvocation }}; err != nil { + return {{$it}}, err + } + {{- else }} + data, err := ec.{{ $field.TypeReference.UnmarshalFunc }}(ctx, v) + if err != nil { + return {{$it}}, err + } + {{- if $field.TypeReference.IsOmittable }} + {{ $lhs }} = graphql.OmittableOf(data) + {{- else }} + {{ $lhs }} = data + {{- end }} + {{- end }} + {{- end }} + {{- end }} + } + } + + return {{$it}}, nil + } + {{- end }} +{{ end }} diff --git a/codegen/interface.go b/codegen/interface.go new file mode 100644 index 0000000..166cf59 --- /dev/null +++ b/codegen/interface.go @@ -0,0 +1,94 @@ +package codegen + +import ( + "fmt" + "go/types" + "sort" + + "github.com/vektah/gqlparser/v2/ast" + + "github.com/niko0xdev/gqlgen/codegen/config" +) + +type Interface struct { + *ast.Definition + Type types.Type + Implementors []InterfaceImplementor + InTypemap bool +} + +type InterfaceImplementor struct { + *ast.Definition + + Type types.Type + TakeRef bool +} + +func (b *builder) buildInterface(typ *ast.Definition) (*Interface, error) { + obj, err := b.Binder.DefaultUserObject(typ.Name) + if err != nil { + panic(err) + } + + i := &Interface{ + Definition: typ, + Type: obj, + InTypemap: b.Config.Models.UserDefined(typ.Name), + } + + interfaceType, err := findGoInterface(i.Type) + if interfaceType == nil || err != nil { + return nil, fmt.Errorf("%s is not an interface", i.Type) + } + + // Sort so that more specific types are evaluated first. + implementors := b.Schema.GetPossibleTypes(typ) + sort.Slice(implementors, func(i, j int) bool { + return len(implementors[i].Interfaces) > len(implementors[j].Interfaces) + }) + + for _, implementor := range implementors { + obj, err := b.Binder.DefaultUserObject(implementor.Name) + if err != nil { + return nil, fmt.Errorf("%s has no backing go type", implementor.Name) + } + + implementorType, err := findGoNamedType(obj) + if err != nil { + 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()) + } + + anyValid := false + + // first check if the value receiver can be nil, eg can we type switch on case Thing: + if types.Implements(implementorType, interfaceType) { + i.Implementors = append(i.Implementors, InterfaceImplementor{ + Definition: implementor, + Type: obj, + TakeRef: !types.IsInterface(obj), + }) + anyValid = true + } + + // then check if the pointer receiver can be nil, eg can we type switch on case *Thing: + if types.Implements(types.NewPointer(implementorType), interfaceType) { + i.Implementors = append(i.Implementors, InterfaceImplementor{ + Definition: implementor, + Type: types.NewPointer(obj), + }) + anyValid = true + } + + if !anyValid { + return nil, fmt.Errorf("%s does not satisfy the interface %s", implementorType.String(), i.Type.String()) + } + } + + return i, nil +} + +func (i *InterfaceImplementor) CanBeNil() bool { + return config.IsNilable(i.Type) +} diff --git a/codegen/interface.gotpl b/codegen/interface.gotpl new file mode 100644 index 0000000..e9d560c --- /dev/null +++ b/codegen/interface.gotpl @@ -0,0 +1,21 @@ +{{- range $interface := .Interfaces }} + +func (ec *executionContext) _{{$interface.Name}}(ctx context.Context, sel ast.SelectionSet, obj {{$interface.Type | ref}}) graphql.Marshaler { + switch obj := (obj).(type) { + case nil: + return graphql.Null + {{- range $implementor := $interface.Implementors }} + case {{$implementor.Type | ref}}: + {{- if $implementor.CanBeNil }} + if obj == nil { + return graphql.Null + } + {{- end }} + return ec._{{$implementor.Name}}(ctx, sel, {{ if $implementor.TakeRef }}&{{ end }}obj) + {{- end }} + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +{{- end }} diff --git a/codegen/object.go b/codegen/object.go new file mode 100644 index 0000000..21b92a8 --- /dev/null +++ b/codegen/object.go @@ -0,0 +1,188 @@ +package codegen + +import ( + "fmt" + "go/types" + "strconv" + "strings" + "unicode" + + "github.com/vektah/gqlparser/v2/ast" + "golang.org/x/text/cases" + "golang.org/x/text/language" + + "github.com/niko0xdev/gqlgen/codegen/config" +) + +type GoFieldType int + +const ( + GoFieldUndefined GoFieldType = iota + GoFieldMethod + GoFieldVariable + GoFieldMap +) + +type Object struct { + *ast.Definition + + Type types.Type + ResolverInterface types.Type + Root bool + Fields []*Field + Implements []*ast.Definition + DisableConcurrency bool + Stream bool + Directives []*Directive + PointersInUmarshalInput bool +} + +func (b *builder) buildObject(typ *ast.Definition) (*Object, error) { + dirs, err := b.getDirectives(typ.Directives) + if err != nil { + return nil, fmt.Errorf("%s: %w", typ.Name, err) + } + caser := cases.Title(language.English, cases.NoLower) + obj := &Object{ + Definition: typ, + Root: b.Config.IsRoot(typ), + DisableConcurrency: typ == b.Schema.Mutation, + Stream: typ == b.Schema.Subscription, + Directives: dirs, + PointersInUmarshalInput: b.Config.ReturnPointersInUmarshalInput, + ResolverInterface: types.NewNamed( + types.NewTypeName(0, b.Config.Exec.Pkg(), caser.String(typ.Name)+"Resolver", nil), + nil, + nil, + ), + } + + if !obj.Root { + goObject, err := b.Binder.DefaultUserObject(typ.Name) + if err != nil { + return nil, err + } + obj.Type = goObject + } + + for _, intf := range b.Schema.GetImplements(typ) { + obj.Implements = append(obj.Implements, b.Schema.Types[intf.Name]) + } + + for _, field := range typ.Fields { + if strings.HasPrefix(field.Name, "__") { + continue + } + + var f *Field + f, err = b.buildField(obj, field) + if err != nil { + return nil, err + } + + obj.Fields = append(obj.Fields, f) + } + + return obj, nil +} + +func (o *Object) Reference() types.Type { + if config.IsNilable(o.Type) { + return o.Type + } + return types.NewPointer(o.Type) +} + +type Objects []*Object + +func (o *Object) Implementors() string { + satisfiedBy := strconv.Quote(o.Name) + for _, s := range o.Implements { + satisfiedBy += ", " + strconv.Quote(s.Name) + } + return "[]string{" + satisfiedBy + "}" +} + +func (o *Object) HasResolvers() bool { + for _, f := range o.Fields { + if f.IsResolver { + return true + } + } + return false +} + +func (o *Object) HasUnmarshal() bool { + if o.IsMap() { + return false + } + for i := 0; i < o.Type.(*types.Named).NumMethods(); i++ { + if o.Type.(*types.Named).Method(i).Name() == "UnmarshalGQL" { + return true + } + } + return false +} + +func (o *Object) HasDirectives() bool { + if len(o.Directives) > 0 { + return true + } + for _, f := range o.Fields { + if f.HasDirectives() { + return true + } + } + + return false +} + +func (o *Object) IsConcurrent() bool { + for _, f := range o.Fields { + if f.IsConcurrent() { + return true + } + } + return false +} + +func (o *Object) IsReserved() bool { + return strings.HasPrefix(o.Definition.Name, "__") +} + +func (o *Object) IsMap() bool { + return o.Type == config.MapType +} + +func (o *Object) Description() string { + return o.Definition.Description +} + +func (o *Object) HasField(name string) bool { + for _, f := range o.Fields { + if f.Name == name { + return true + } + } + + return false +} + +func (os Objects) ByName(name string) *Object { + for i, o := range os { + if strings.EqualFold(o.Definition.Name, name) { + return os[i] + } + } + return nil +} + +func ucFirst(s string) string { + if s == "" { + return "" + } + + r := []rune(s) + r[0] = unicode.ToUpper(r[0]) + return string(r) +} diff --git a/codegen/object.gotpl b/codegen/object.gotpl new file mode 100644 index 0000000..adb1df4 --- /dev/null +++ b/codegen/object.gotpl @@ -0,0 +1,147 @@ +{{- range $object := .Objects }} + +var {{ $object.Name|lcFirst}}Implementors = {{$object.Implementors}} + +{{- if .Stream }} +func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.SelectionSet) func(ctx context.Context) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, {{$object.Name|lcFirst}}Implementors) + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ + Object: {{$object.Name|quote}}, + }) + if len(fields) != 1 { + ec.Errorf(ctx, "must subscribe to exactly one stream") + return nil + } + + switch fields[0].Name { + {{- range $field := $object.Fields }} + case "{{$field.Name}}": + return ec._{{$object.Name}}_{{$field.Name}}(ctx, fields[0]) + {{- end }} + default: + panic("unknown field " + strconv.Quote(fields[0].Name)) + } +} +{{- 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}} + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + {{- 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, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + {{- else }} + fs.Invalids++ + {{- end }} + } + {{- end }} + return res + } + + {{if $object.Root}} + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + {{end}} + + {{if not $object.Root}} + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + {{end}} + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { + {{- if $object.Root -}} + return rrm(innerCtx) + {{- else -}} + return innerFunc(ctx, out) + {{- end -}} + }) + {{- else }} + {{- if $object.Root -}} + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._{{$object.Name}}_{{$field.Name}}(ctx, field) + }) + {{- else -}} + out.Values[i] = ec._{{$object.Name}}_{{$field.Name}}(ctx, field, obj) + {{- end -}} + + {{- if $field.TypeReference.GQL.NonNull }} + if out.Values[i] == graphql.Null { + {{- if $object.IsConcurrent }} + atomic.AddUint32(&out.Invalids, 1) + {{- else }} + out.Invalids++ + {{- end }} + } + {{- end }} + {{- end }} + {{- end }} + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { return graphql.Null } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} +{{- end }} + +{{- end }} diff --git a/codegen/root_.gotpl b/codegen/root_.gotpl new file mode 100644 index 0000000..35798fa --- /dev/null +++ b/codegen/root_.gotpl @@ -0,0 +1,279 @@ +{{ reserveImport "context" }} +{{ reserveImport "fmt" }} +{{ reserveImport "io" }} +{{ reserveImport "strconv" }} +{{ reserveImport "time" }} +{{ reserveImport "sync" }} +{{ reserveImport "sync/atomic" }} +{{ reserveImport "errors" }} +{{ reserveImport "bytes" }} +{{ reserveImport "embed" }} + +{{ reserveImport "github.com/vektah/gqlparser/v2" "gqlparser" }} +{{ reserveImport "github.com/vektah/gqlparser/v2/ast" }} +{{ reserveImport "github.com/niko0xdev/gqlgen/graphql" }} +{{ reserveImport "github.com/niko0xdev/gqlgen/graphql/introspection" }} + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { +{{- range $object := .Objects -}} + {{ if $object.HasResolvers -}} + {{ucFirst $object.Name}}() {{ucFirst $object.Name}}Resolver + {{ end }} +{{- end }} +{{- range $object := .Inputs -}} + {{ if $object.HasResolvers -}} + {{ucFirst $object.Name}}() {{ucFirst $object.Name}}Resolver + {{ end }} +{{- end }} +} + +type DirectiveRoot struct { +{{ range $directive := .Directives }} + {{- $directive.Declaration }} +{{ end }} +} + +type ComplexityRoot struct { +{{- if not .Config.OmitComplexity }} +{{ 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 }} +} + +type executableSchema struct { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = ec + {{- if not .Config.OmitComplexity }} + 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 }} + } + {{- end }} + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap( + {{- range $input := .Inputs -}} + {{ if not $input.HasUnmarshal }} + ec.unmarshalInput{{ $input.Name }}, + {{- end }} + {{- end }} + ) + first := true + + switch rc.Operation.Operation { + {{- if .QueryRoot }} case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + {{ 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 }} + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + {{ end }} + + {{- if .MutationRoot }} case ast.Mutation: + return func(ctx context.Context) *graphql.Response { + if !first { return nil } + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + {{ 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(ctx) + + 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 + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func () { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + + +{{if .HasEmbeddableSources }} +//go:embed{{- range $source := .AugmentedSources }}{{if $source.Embeddable}} {{$source.RelativePath|quote}}{{end}}{{- end }} +var sourcesFS embed.FS + +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) +} +{{- end}} + +var sources = []*ast.Source{ +{{- range $source := .AugmentedSources }} + {Name: {{$source.RelativePath|quote}}, Input: {{if (not $source.Embeddable)}}{{$source.Source|rawQuote}}{{else}}sourceData({{$source.RelativePath|quote}}){{end}}, BuiltIn: {{$source.BuiltIn}}}, +{{- end }} +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) diff --git a/codegen/templates/import.go b/codegen/templates/import.go new file mode 100644 index 0000000..8201499 --- /dev/null +++ b/codegen/templates/import.go @@ -0,0 +1,139 @@ +package templates + +import ( + "fmt" + "go/types" + "strconv" + "strings" + + "github.com/niko0xdev/gqlgen/internal/code" +) + +type Import struct { + Name string + Path string + Alias string +} + +type Imports struct { + imports []*Import + destDir string + packages *code.Packages +} + +func (i *Import) String() string { + if strings.HasSuffix(i.Path, i.Alias) { + return strconv.Quote(i.Path) + } + + return i.Alias + " " + strconv.Quote(i.Path) +} + +func (s *Imports) String() string { + res := "" + for i, imp := range s.imports { + if i != 0 { + res += "\n" + } + res += imp.String() + } + return res +} + +func (s *Imports) Reserve(path string, aliases ...string) (string, error) { + if path == "" { + panic("empty ambient import") + } + + // if we are referencing our own package we don't need an import + if code.ImportPathForDir(s.destDir) == path { + return "", nil + } + + name := s.packages.NameForPackage(path) + var alias string + if len(aliases) != 1 { + alias = name + } else { + alias = aliases[0] + } + + if existing := s.findByPath(path); existing != nil { + if existing.Alias == alias { + return "", nil + } + return "", fmt.Errorf("ambient import already exists") + } + + if alias := s.findByAlias(alias); alias != nil { + return "", fmt.Errorf("ambient import collides on an alias") + } + + s.imports = append(s.imports, &Import{ + Name: name, + Path: path, + Alias: alias, + }) + + return "", nil +} + +func (s *Imports) Lookup(path string) string { + if path == "" { + return "" + } + + path = code.NormalizeVendor(path) + + // if we are referencing our own package we don't need an import + if code.ImportPathForDir(s.destDir) == path { + return "" + } + + if existing := s.findByPath(path); existing != nil { + return existing.Alias + } + + imp := &Import{ + Name: s.packages.NameForPackage(path), + Path: path, + } + s.imports = append(s.imports, imp) + + alias := imp.Name + i := 1 + for s.findByAlias(alias) != nil { + alias = imp.Name + strconv.Itoa(i) + i++ + if i > 1000 { + panic(fmt.Errorf("too many collisions, last attempt was %s", alias)) + } + } + imp.Alias = alias + + return imp.Alias +} + +func (s *Imports) LookupType(t types.Type) string { + return types.TypeString(t, func(i *types.Package) string { + return s.Lookup(i.Path()) + }) +} + +func (s Imports) findByPath(importPath string) *Import { + for _, imp := range s.imports { + if imp.Path == importPath { + return imp + } + } + return nil +} + +func (s Imports) findByAlias(alias string) *Import { + for _, imp := range s.imports { + if imp.Alias == alias { + return imp + } + } + return nil +} diff --git a/codegen/templates/import_test.go b/codegen/templates/import_test.go new file mode 100644 index 0000000..f5c8b1e --- /dev/null +++ b/codegen/templates/import_test.go @@ -0,0 +1,91 @@ +package templates + +import ( + "fmt" + "go/types" + "os" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/internal/code" +) + +func TestImports(t *testing.T) { + wd, err := os.Getwd() + require.NoError(t, err) + + aBar := "github.com/niko0xdev/gqlgen/codegen/templates/testdata/a/bar" + bBar := "github.com/niko0xdev/gqlgen/codegen/templates/testdata/b/bar" + mismatch := "github.com/niko0xdev/gqlgen/codegen/templates/testdata/pkg_mismatch" + + t.Run("multiple lookups is ok", func(t *testing.T) { + a := Imports{destDir: wd, packages: code.NewPackages()} + + require.Equal(t, "bar", a.Lookup(aBar)) + require.Equal(t, "bar", a.Lookup(aBar)) + }) + + t.Run("lookup by type", func(t *testing.T) { + a := Imports{destDir: wd, packages: code.NewPackages()} + + pkg := types.NewPackage("github.com/niko0xdev/gqlgen/codegen/templates/testdata/b/bar", "bar") + typ := types.NewNamed(types.NewTypeName(0, pkg, "Boolean", types.Typ[types.Bool]), types.Typ[types.Bool], nil) + + require.Equal(t, "bar.Boolean", a.LookupType(typ)) + }) + + t.Run("duplicates are decollisioned", func(t *testing.T) { + a := Imports{destDir: wd, packages: code.NewPackages()} + + require.Equal(t, "bar", a.Lookup(aBar)) + require.Equal(t, "bar1", a.Lookup(bBar)) + + t.Run("additionial calls get decollisioned name", func(t *testing.T) { + require.Equal(t, "bar1", a.Lookup(bBar)) + }) + }) + + t.Run("duplicates above 10 are decollisioned", func(t *testing.T) { + a := Imports{destDir: wd, packages: code.NewPackages()} + for i := 0; i < 100; i++ { + cBar := fmt.Sprintf("github.com/niko0xdev/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.NewPackages()} + + require.Equal(t, "turtles", a.Lookup(mismatch)) + }) + + t.Run("string printing for import block", func(t *testing.T) { + a := Imports{destDir: wd, packages: code.NewPackages()} + a.Lookup(aBar) + a.Lookup(bBar) + a.Lookup(mismatch) + + require.Equal( + t, + `"github.com/niko0xdev/gqlgen/codegen/templates/testdata/a/bar" +bar1 "github.com/niko0xdev/gqlgen/codegen/templates/testdata/b/bar" +turtles "github.com/niko0xdev/gqlgen/codegen/templates/testdata/pkg_mismatch"`, + a.String(), + ) + }) + + t.Run("aliased imports will not collide", func(t *testing.T) { + a := Imports{destDir: wd, packages: code.NewPackages()} + + _, _ = a.Reserve(aBar, "abar") + _, _ = a.Reserve(bBar, "bbar") + + require.Equal(t, `abar "github.com/niko0xdev/gqlgen/codegen/templates/testdata/a/bar" +bbar "github.com/niko0xdev/gqlgen/codegen/templates/testdata/b/bar"`, a.String()) + }) +} diff --git a/codegen/templates/templates.go b/codegen/templates/templates.go new file mode 100644 index 0000000..fd6994c --- /dev/null +++ b/codegen/templates/templates.go @@ -0,0 +1,763 @@ +package templates + +import ( + "bytes" + "fmt" + "go/types" + "io/fs" + "os" + "path/filepath" + "reflect" + "regexp" + "runtime" + "sort" + "strconv" + "strings" + "sync" + "text/template" + "unicode" + + "github.com/niko0xdev/gqlgen/internal/code" + "github.com/niko0xdev/gqlgen/internal/imports" +) + +// CurrentImports keeps track of all the import declarations that are needed during the execution of a plugin. +// this is done with a global because subtemplates currently get called in functions. Lets aim to remove this eventually. +var CurrentImports *Imports + +// Options specify various parameters to rendering a template. +type Options struct { + // PackageName is a helper that specifies the package header declaration. + // In other words, when you write the template you don't need to specify `package X` + // at the top of the file. By providing PackageName in the Options, the Render + // function will do that for you. + PackageName string + // Template is a string of the entire template that + // will be parsed and rendered. If it's empty, + // the plugin processor will look for .gotpl files + // in the same directory of where you wrote the plugin. + Template string + + // Use the go:embed API to collect all the template files you want to pass into Render + // this is an alternative to passing the Template option + TemplateFS fs.FS + + // Filename is the name of the file that will be + // written to the system disk once the template is rendered. + Filename string + RegionTags bool + GeneratedHeader bool + // PackageDoc is documentation written above the package line + PackageDoc string + // FileNotice is notice written below the package line + FileNotice string + // Data will be passed to the template execution. + Data interface{} + Funcs template.FuncMap + + // Packages cache, you can find me on config.Config + Packages *code.Packages +} + +var ( + modelNamesMu sync.Mutex + modelNames = make(map[string]string, 0) + goNameRe = regexp.MustCompile("[^a-zA-Z0-9_]") +) + +// Render renders a gql plugin template from the given Options. Render is an +// abstraction of the text/template package that makes it easier to write gqlgen +// plugins. If Options.Template is empty, the Render function will look for `.gotpl` +// files inside the directory where you wrote the plugin. +func Render(cfg Options) error { + if CurrentImports != nil { + panic(fmt.Errorf("recursive or concurrent call to RenderToFile detected")) + } + CurrentImports = &Imports{packages: cfg.Packages, destDir: filepath.Dir(cfg.Filename)} + + funcs := Funcs() + for n, f := range cfg.Funcs { + funcs[n] = f + } + + t := template.New("").Funcs(funcs) + t, err := parseTemplates(cfg, t) + if err != nil { + return err + } + + roots := make([]string, 0, len(t.Templates())) + for _, template := range t.Templates() { + // templates that end with _.gotpl are special files we don't want to include + if strings.HasSuffix(template.Name(), "_.gotpl") || + // filter out templates added with {{ template xxx }} syntax inside the template file + !strings.HasSuffix(template.Name(), ".gotpl") { + continue + } + + roots = append(roots, template.Name()) + } + + // then execute all the important looking ones in order, adding them to the same file + sort.Slice(roots, func(i, j int) bool { + // important files go first + if strings.HasSuffix(roots[i], "!.gotpl") { + return true + } + if strings.HasSuffix(roots[j], "!.gotpl") { + return false + } + return roots[i] < roots[j] + }) + + var buf bytes.Buffer + for _, root := range roots { + if cfg.RegionTags { + buf.WriteString("\n// region " + center(70, "*", " "+root+" ") + "\n") + } + err := t.Lookup(root).Execute(&buf, cfg.Data) + if err != nil { + return fmt.Errorf("%s: %w", root, err) + } + if cfg.RegionTags { + buf.WriteString("\n// endregion " + center(70, "*", " "+root+" ") + "\n") + } + } + + var result bytes.Buffer + if cfg.GeneratedHeader { + result.WriteString("// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT.\n\n") + } + if cfg.PackageDoc != "" { + result.WriteString(cfg.PackageDoc + "\n") + } + result.WriteString("package ") + result.WriteString(cfg.PackageName) + result.WriteString("\n\n") + if cfg.FileNotice != "" { + result.WriteString(cfg.FileNotice) + result.WriteString("\n\n") + } + result.WriteString("import (\n") + result.WriteString(CurrentImports.String()) + result.WriteString(")\n") + _, err = buf.WriteTo(&result) + if err != nil { + return err + } + CurrentImports = nil + + err = write(cfg.Filename, result.Bytes(), cfg.Packages) + if err != nil { + return err + } + + cfg.Packages.Evict(code.ImportPathForDir(filepath.Dir(cfg.Filename))) + return nil +} + +func parseTemplates(cfg Options, t *template.Template) (*template.Template, error) { + if cfg.Template != "" { + var err error + t, err = t.New("template.gotpl").Parse(cfg.Template) + if err != nil { + return nil, fmt.Errorf("error with provided template: %w", err) + } + return t, nil + } + + var fileSystem fs.FS + if cfg.TemplateFS != nil { + fileSystem = cfg.TemplateFS + } else { + // load path relative to calling source file + _, callerFile, _, _ := runtime.Caller(2) + rootDir := filepath.Dir(callerFile) + fileSystem = os.DirFS(rootDir) + } + + t, err := t.ParseFS(fileSystem, "*.gotpl") + if err != nil { + return nil, fmt.Errorf("locating templates: %w", err) + } + + return t, nil +} + +func center(width int, pad string, s string) string { + if len(s)+2 > width { + return s + } + lpad := (width - len(s)) / 2 + rpad := width - (lpad + len(s)) + return strings.Repeat(pad, lpad) + s + strings.Repeat(pad, rpad) +} + +func Funcs() template.FuncMap { + return template.FuncMap{ + "ucFirst": UcFirst, + "lcFirst": LcFirst, + "quote": strconv.Quote, + "rawQuote": rawQuote, + "dump": Dump, + "ref": ref, + "ts": TypeIdentifier, + "call": Call, + "prefixLines": prefixLines, + "notNil": notNil, + "reserveImport": CurrentImports.Reserve, + "lookupImport": CurrentImports.Lookup, + "go": ToGo, + "goPrivate": ToGoPrivate, + "goModelName": ToGoModelName, + "goPrivateModelName": ToGoPrivateModelName, + "add": func(a, b int) int { + return a + b + }, + "render": func(filename string, tpldata interface{}) (*bytes.Buffer, error) { + return render(resolveName(filename, 0), tpldata) + }, + } +} + +func UcFirst(s string) string { + if s == "" { + return "" + } + r := []rune(s) + r[0] = unicode.ToUpper(r[0]) + return string(r) +} + +func LcFirst(s string) string { + if s == "" { + return "" + } + + r := []rune(s) + r[0] = unicode.ToLower(r[0]) + return string(r) +} + +func isDelimiter(c rune) bool { + return c == '-' || c == '_' || unicode.IsSpace(c) +} + +func ref(p types.Type) string { + return CurrentImports.LookupType(p) +} + +func Call(p *types.Func) string { + pkg := CurrentImports.Lookup(p.Pkg().Path()) + + if pkg != "" { + pkg += "." + } + + if p.Type() != nil { + // make sure the returned type is listed in our imports. + ref(p.Type().(*types.Signature).Results().At(0).Type()) + } + + return pkg + p.Name() +} + +func resetModelNames() { + modelNamesMu.Lock() + defer modelNamesMu.Unlock() + modelNames = make(map[string]string, 0) +} + +func buildGoModelNameKey(parts []string) string { + const sep = ":" + return strings.Join(parts, sep) +} + +func goModelName(primaryToGoFunc func(string) string, parts []string) string { + modelNamesMu.Lock() + defer modelNamesMu.Unlock() + + var ( + goNameKey string + partLen int + + nameExists = func(n string) bool { + for _, v := range modelNames { + if n == v { + return true + } + } + return false + } + + applyToGoFunc = func(parts []string) string { + var out string + switch len(parts) { + case 0: + return "" + case 1: + return primaryToGoFunc(parts[0]) + default: + out = primaryToGoFunc(parts[0]) + } + for _, p := range parts[1:] { + out = fmt.Sprintf("%s%s", out, ToGo(p)) + } + return out + } + + applyValidGoName = func(parts []string) string { + var out string + for _, p := range parts { + out = fmt.Sprintf("%s%s", out, replaceInvalidCharacters(p)) + } + return out + } + ) + + // build key for this entity + goNameKey = buildGoModelNameKey(parts) + + // determine if we've seen this entity before, and reuse if so + if goName, ok := modelNames[goNameKey]; ok { + return goName + } + + // attempt first pass + if goName := applyToGoFunc(parts); !nameExists(goName) { + modelNames[goNameKey] = goName + return goName + } + + // determine number of parts + partLen = len(parts) + + // if there is only 1 part, append incrementing number until no conflict + if partLen == 1 { + base := applyToGoFunc(parts) + for i := 0; ; i++ { + tmp := fmt.Sprintf("%s%d", base, i) + if !nameExists(tmp) { + modelNames[goNameKey] = tmp + return tmp + } + } + } + + // best effort "pretty" name + for i := partLen - 1; i >= 1; i-- { + tmp := fmt.Sprintf("%s%s", applyToGoFunc(parts[0:i]), applyValidGoName(parts[i:])) + if !nameExists(tmp) { + modelNames[goNameKey] = tmp + return tmp + } + } + + // finally, fallback to just adding an incrementing number + base := applyToGoFunc(parts) + for i := 0; ; i++ { + tmp := fmt.Sprintf("%s%d", base, i) + if !nameExists(tmp) { + modelNames[goNameKey] = tmp + return tmp + } + } +} + +func ToGoModelName(parts ...string) string { + return goModelName(ToGo, parts) +} + +func ToGoPrivateModelName(parts ...string) string { + return goModelName(ToGoPrivate, parts) +} + +func replaceInvalidCharacters(in string) string { + return goNameRe.ReplaceAllLiteralString(in, "_") +} + +func wordWalkerFunc(private bool, nameRunes *[]rune) func(*wordInfo) { + return func(info *wordInfo) { + word := info.Word + + switch { + case private && info.WordOffset == 0: + if strings.ToUpper(word) == word || strings.ToLower(word) == word { + // ID → id, CAMEL → camel + word = strings.ToLower(info.Word) + } else { + // ITicket → iTicket + word = LcFirst(info.Word) + } + + case info.MatchCommonInitial: + word = strings.ToUpper(word) + + case !info.HasCommonInitial && (strings.ToUpper(word) == word || strings.ToLower(word) == word): + // FOO or foo → Foo + // FOo → FOo + word = UcFirst(strings.ToLower(word)) + } + + *nameRunes = append(*nameRunes, []rune(word)...) + } +} + +func ToGo(name string) string { + if name == "_" { + return "_" + } + runes := make([]rune, 0, len(name)) + + wordWalker(name, wordWalkerFunc(false, &runes)) + + return string(runes) +} + +func ToGoPrivate(name string) string { + if name == "_" { + return "_" + } + runes := make([]rune, 0, len(name)) + + wordWalker(name, wordWalkerFunc(true, &runes)) + + return sanitizeKeywords(string(runes)) +} + +type wordInfo struct { + WordOffset int + Word string + MatchCommonInitial bool + HasCommonInitial bool +} + +// This function is based on the following code. +// https://github.com/golang/lint/blob/06c8688daad7faa9da5a0c2f163a3d14aac986ca/lint.go#L679 +func wordWalker(str string, f func(*wordInfo)) { + runes := []rune(strings.TrimFunc(str, isDelimiter)) + w, i, wo := 0, 0, 0 // index of start of word, scan, word offset + hasCommonInitial := false + for i+1 <= len(runes) { + eow := false // whether we hit the end of a word + switch { + case i+1 == len(runes): + eow = true + case isDelimiter(runes[i+1]): + // underscore; shift the remainder forward over any run of underscores + eow = true + n := 1 + for i+n+1 < len(runes) && isDelimiter(runes[i+n+1]) { + n++ + } + + // Leave at most one underscore if the underscore is between two digits + if i+n+1 < len(runes) && unicode.IsDigit(runes[i]) && unicode.IsDigit(runes[i+n+1]) { + n-- + } + + copy(runes[i+1:], runes[i+n+1:]) + runes = runes[:len(runes)-n] + case unicode.IsLower(runes[i]) && !unicode.IsLower(runes[i+1]): + // lower->non-lower + eow = true + } + i++ + + initialisms := GetInitialisms() + // [w,i) is a word. + word := string(runes[w:i]) + if !eow && initialisms[word] && !unicode.IsLower(runes[i]) { + // through + // split IDFoo → ID, Foo + // but URLs → URLs + } else if !eow { + if initialisms[word] { + hasCommonInitial = true + } + continue + } + + matchCommonInitial := false + upperWord := strings.ToUpper(word) + if initialisms[upperWord] { + // If the uppercase word (string(runes[w:i]) is "ID" or "IP" + // AND + // the word is the first two characters of the str + // AND + // that is not the end of the word + // AND + // the length of the string is greater than 3 + // AND + // the third rune is an uppercase one + // THEN + // do NOT count this as an initialism. + switch upperWord { + case "ID", "IP": + if word == str[:2] && !eow && len(str) > 3 && unicode.IsUpper(runes[3]) { + continue + } + } + hasCommonInitial = true + matchCommonInitial = true + } + + f(&wordInfo{ + WordOffset: wo, + Word: word, + MatchCommonInitial: matchCommonInitial, + HasCommonInitial: hasCommonInitial, + }) + hasCommonInitial = false + w = i + wo++ + } +} + +var keywords = []string{ + "break", + "default", + "func", + "interface", + "select", + "case", + "defer", + "go", + "map", + "struct", + "chan", + "else", + "goto", + "package", + "switch", + "const", + "fallthrough", + "if", + "range", + "type", + "continue", + "for", + "import", + "return", + "var", + "_", +} + +// sanitizeKeywords prevents collisions with go keywords for arguments to resolver functions +func sanitizeKeywords(name string) string { + for _, k := range keywords { + if name == k { + return name + "Arg" + } + } + return name +} + +func rawQuote(s string) string { + return "`" + strings.ReplaceAll(s, "`", "`+\"`\"+`") + "`" +} + +func notNil(field string, data interface{}) bool { + v := reflect.ValueOf(data) + + if v.Kind() == reflect.Ptr { + v = v.Elem() + } + if v.Kind() != reflect.Struct { + return false + } + val := v.FieldByName(field) + + return val.IsValid() && !val.IsNil() +} + +func Dump(val interface{}) string { + switch val := val.(type) { + case int: + return strconv.Itoa(val) + case int64: + return fmt.Sprintf("%d", val) + case float64: + return fmt.Sprintf("%f", val) + case string: + return strconv.Quote(val) + case bool: + return strconv.FormatBool(val) + case nil: + return "nil" + case []interface{}: + var parts []string + for _, part := range val { + parts = append(parts, Dump(part)) + } + return "[]interface{}{" + strings.Join(parts, ",") + "}" + case map[string]interface{}: + buf := bytes.Buffer{} + buf.WriteString("map[string]interface{}{") + var keys []string + for key := range val { + keys = append(keys, key) + } + sort.Strings(keys) + + for _, key := range keys { + data := val[key] + + buf.WriteString(strconv.Quote(key)) + buf.WriteString(":") + buf.WriteString(Dump(data)) + buf.WriteString(",") + } + buf.WriteString("}") + return buf.String() + default: + panic(fmt.Errorf("unsupported type %T", val)) + } +} + +func prefixLines(prefix, s string) string { + return prefix + strings.ReplaceAll(s, "\n", "\n"+prefix) +} + +func resolveName(name string, skip int) string { + if name[0] == '.' { + // load path relative to calling source file + _, callerFile, _, _ := runtime.Caller(skip + 1) + return filepath.Join(filepath.Dir(callerFile), name[1:]) + } + + // load path relative to this directory + _, callerFile, _, _ := runtime.Caller(0) + return filepath.Join(filepath.Dir(callerFile), name) +} + +func render(filename string, tpldata interface{}) (*bytes.Buffer, error) { + t := template.New("").Funcs(Funcs()) + + b, err := os.ReadFile(filename) + if err != nil { + return nil, err + } + + t, err = t.New(filepath.Base(filename)).Parse(string(b)) + if err != nil { + panic(err) + } + + buf := &bytes.Buffer{} + return buf, t.Execute(buf, tpldata) +} + +func write(filename string, b []byte, packages *code.Packages) error { + err := os.MkdirAll(filepath.Dir(filename), 0o755) + if err != nil { + return fmt.Errorf("failed to create directory: %w", err) + } + + formatted, err := imports.Prune(filename, b, packages) + if err != nil { + fmt.Fprintf(os.Stderr, "gofmt failed on %s: %s\n", filepath.Base(filename), err.Error()) + formatted = b + } + + err = os.WriteFile(filename, formatted, 0o644) + if err != nil { + return fmt.Errorf("failed to write %s: %w", filename, err) + } + + return nil +} + +var pkgReplacer = strings.NewReplacer( + "/", "ᚋ", + ".", "ᚗ", + "-", "ᚑ", + "~", "א", +) + +func TypeIdentifier(t types.Type) string { + res := "" + for { + switch it := t.(type) { + case *types.Pointer: + t.Underlying() + res += "ᚖ" + t = it.Elem() + case *types.Slice: + res += "ᚕ" + t = it.Elem() + case *types.Named: + res += pkgReplacer.Replace(it.Obj().Pkg().Path()) + res += "ᚐ" + res += it.Obj().Name() + return res + case *types.Basic: + res += it.Name() + return res + case *types.Map: + res += "map" + return res + case *types.Interface: + res += "interface" + return res + default: + panic(fmt.Errorf("unexpected type %T", it)) + } + } +} + +// CommonInitialisms is a set of common initialisms. +// Only add entries that are highly unlikely to be non-initialisms. +// For instance, "ID" is fine (Freudian code is rare), but "AND" is not. +var CommonInitialisms = map[string]bool{ + "ACL": true, + "API": true, + "ASCII": true, + "CPU": true, + "CSS": true, + "CSV": true, + "DNS": true, + "EOF": true, + "GUID": true, + "HTML": true, + "HTTP": true, + "HTTPS": true, + "ICMP": true, + "ID": true, + "IP": true, + "JSON": true, + "KVK": true, + "LHS": true, + "PDF": true, + "PGP": true, + "QPS": true, + "QR": true, + "RAM": true, + "RHS": true, + "RPC": true, + "SLA": true, + "SMTP": true, + "SQL": true, + "SSH": true, + "SVG": true, + "TCP": true, + "TLS": true, + "TTL": true, + "UDP": true, + "UI": true, + "UID": true, + "URI": true, + "URL": true, + "UTF8": true, + "UUID": true, + "VM": true, + "XML": true, + "XMPP": true, + "XSRF": true, + "XSS": true, +} + +// GetInitialisms returns the initialisms to capitalize in Go names. If unchanged, default initialisms will be returned +var GetInitialisms = func() map[string]bool { + return CommonInitialisms +} diff --git a/codegen/templates/templates_test.go b/codegen/templates/templates_test.go new file mode 100644 index 0000000..93984ea --- /dev/null +++ b/codegen/templates/templates_test.go @@ -0,0 +1,360 @@ +package templates + +import ( + "embed" + "fmt" + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/internal/code" +) + +//go:embed *.gotpl +var templateFS embed.FS + +func TestToGo(t *testing.T) { + require.Equal(t, "ToCamel", ToGo("TO_CAMEL")) + require.Equal(t, "ToCamel", ToGo("to_camel")) + require.Equal(t, "ToCamel", ToGo("toCamel")) + require.Equal(t, "ToCamel", ToGo("ToCamel")) + require.Equal(t, "ToCamel", ToGo("to-camel")) + require.Equal(t, "ToCamel", ToGo("-to-camel")) + require.Equal(t, "ToCamel", ToGo("_to-camel")) + require.Equal(t, "_", ToGo("_")) + + require.Equal(t, "RelatedURLs", ToGo("RelatedURLs")) + require.Equal(t, "ImageIDs", ToGo("ImageIDs")) + require.Equal(t, "FooID", ToGo("FooID")) + require.Equal(t, "IDFoo", ToGo("IDFoo")) + require.Equal(t, "FooASCII", ToGo("FooASCII")) + require.Equal(t, "ASCIIFoo", ToGo("ASCIIFoo")) + require.Equal(t, "FooUTF8", ToGo("FooUTF8")) + require.Equal(t, "UTF8Foo", ToGo("UTF8Foo")) + require.Equal(t, "JSONEncoding", ToGo("JSONEncoding")) + + require.Equal(t, "A", ToGo("A")) + require.Equal(t, "ID", ToGo("ID")) + require.Equal(t, "ID", ToGo("id")) + require.Equal(t, "", ToGo("")) + + require.Equal(t, "RelatedUrls", ToGo("RelatedUrls")) + require.Equal(t, "ITicket", ToGo("ITicket")) + require.Equal(t, "FooTicket", ToGo("fooTicket")) + + require.Equal(t, "Idle", ToGo("IDLE")) + require.Equal(t, "Idle", ToGo("Idle")) + require.Equal(t, "Idle", ToGo("idle")) + require.Equal(t, "Identities", ToGo("IDENTITIES")) + require.Equal(t, "Identities", ToGo("Identities")) + require.Equal(t, "Identities", ToGo("identities")) + require.Equal(t, "Iphone", ToGo("IPHONE")) + require.Equal(t, "IPhone", ToGo("iPHONE")) +} + +func TestToGoPrivate(t *testing.T) { + require.Equal(t, "toCamel", ToGoPrivate("TO_CAMEL")) + require.Equal(t, "toCamel", ToGoPrivate("to_camel")) + require.Equal(t, "toCamel", ToGoPrivate("toCamel")) + require.Equal(t, "toCamel", ToGoPrivate("ToCamel")) + require.Equal(t, "toCamel", ToGoPrivate("to-camel")) + + require.Equal(t, "relatedURLs", ToGoPrivate("RelatedURLs")) + require.Equal(t, "imageIDs", ToGoPrivate("ImageIDs")) + require.Equal(t, "fooID", ToGoPrivate("FooID")) + require.Equal(t, "idFoo", ToGoPrivate("IDFoo")) + require.Equal(t, "fooASCII", ToGoPrivate("FooASCII")) + require.Equal(t, "asciiFoo", ToGoPrivate("ASCIIFoo")) + require.Equal(t, "fooUTF8", ToGoPrivate("FooUTF8")) + require.Equal(t, "utf8Foo", ToGoPrivate("UTF8Foo")) + require.Equal(t, "jsonEncoding", ToGoPrivate("JSONEncoding")) + + require.Equal(t, "relatedUrls", ToGoPrivate("RelatedUrls")) + require.Equal(t, "iTicket", ToGoPrivate("ITicket")) + + require.Equal(t, "rangeArg", ToGoPrivate("Range")) + + require.Equal(t, "a", ToGoPrivate("A")) + require.Equal(t, "id", ToGoPrivate("ID")) + require.Equal(t, "id", ToGoPrivate("id")) + require.Equal(t, "", ToGoPrivate("")) + require.Equal(t, "_", ToGoPrivate("_")) + + require.Equal(t, "idle", ToGoPrivate("IDLE")) + require.Equal(t, "idle", ToGoPrivate("Idle")) + require.Equal(t, "idle", ToGoPrivate("idle")) + require.Equal(t, "identities", ToGoPrivate("IDENTITIES")) + require.Equal(t, "identities", ToGoPrivate("Identities")) + require.Equal(t, "identities", ToGoPrivate("identities")) + require.Equal(t, "iphone", ToGoPrivate("IPHONE")) + require.Equal(t, "iPhone", ToGoPrivate("iPHONE")) +} + +func TestToGoModelName(t *testing.T) { + type aTest struct { + input [][]string + expected []string + } + + theTests := []aTest{ + { + input: [][]string{{"MyValue"}}, + expected: []string{"MyValue"}, + }, + { + input: [][]string{{"MyValue"}, {"myValue"}}, + expected: []string{"MyValue", "MyValue0"}, + }, + { + input: [][]string{{"MyValue"}, {"YourValue"}}, + expected: []string{"MyValue", "YourValue"}, + }, + { + input: [][]string{{"MyEnumName", "Value"}}, + expected: []string{"MyEnumNameValue"}, + }, + { + input: [][]string{{"MyEnumName", "Value"}, {"MyEnumName", "value"}}, + expected: []string{"MyEnumNameValue", "MyEnumNamevalue"}, + }, + { + input: [][]string{{"MyEnumName", "value"}, {"MyEnumName", "Value"}}, + expected: []string{"MyEnumNameValue", "MyEnumNameValue0"}, + }, + { + input: [][]string{{"MyEnumName", "Value"}, {"MyEnumName", "value"}, {"MyEnumName", "vALue"}, {"MyEnumName", "VALue"}}, + expected: []string{"MyEnumNameValue", "MyEnumNamevalue", "MyEnumNameVALue", "MyEnumNameVALue0"}, + }, + { + input: [][]string{{"MyEnumName", "TitleValue"}, {"MyEnumName", "title_value"}, {"MyEnumName", "title_Value"}, {"MyEnumName", "Title_Value"}}, + expected: []string{"MyEnumNameTitleValue", "MyEnumNametitle_value", "MyEnumNametitle_Value", "MyEnumNameTitle_Value"}, + }, + { + input: [][]string{{"MyEnumName", "TitleValue", "OtherValue"}}, + expected: []string{"MyEnumNameTitleValueOtherValue"}, + }, + { + input: [][]string{{"MyEnumName", "TitleValue", "OtherValue"}, {"MyEnumName", "title_value", "OtherValue"}}, + expected: []string{"MyEnumNameTitleValueOtherValue", "MyEnumNametitle_valueOtherValue"}, + }, + } + + for ti, at := range theTests { + resetModelNames() + t.Run(fmt.Sprintf("modelname-%d", ti), func(t *testing.T) { + at := at + for i, n := range at.input { + require.Equal(t, at.expected[i], ToGoModelName(n...)) + } + }) + } +} + +func TestToGoPrivateModelName(t *testing.T) { + type aTest struct { + input [][]string + expected []string + } + + theTests := []aTest{ + { + input: [][]string{{"MyValue"}}, + expected: []string{"myValue"}, + }, + { + input: [][]string{{"MyValue"}, {"myValue"}}, + expected: []string{"myValue", "myValue0"}, + }, + { + input: [][]string{{"MyValue"}, {"YourValue"}}, + expected: []string{"myValue", "yourValue"}, + }, + { + input: [][]string{{"MyEnumName", "Value"}}, + expected: []string{"myEnumNameValue"}, + }, + { + input: [][]string{{"MyEnumName", "Value"}, {"MyEnumName", "value"}}, + expected: []string{"myEnumNameValue", "myEnumNamevalue"}, + }, + { + input: [][]string{{"MyEnumName", "value"}, {"MyEnumName", "Value"}}, + expected: []string{"myEnumNameValue", "myEnumNameValue0"}, + }, + { + input: [][]string{{"MyEnumName", "Value"}, {"MyEnumName", "value"}, {"MyEnumName", "vALue"}, {"MyEnumName", "VALue"}}, + expected: []string{"myEnumNameValue", "myEnumNamevalue", "myEnumNameVALue", "myEnumNameVALue0"}, + }, + { + input: [][]string{{"MyEnumName", "TitleValue"}, {"MyEnumName", "title_value"}, {"MyEnumName", "title_Value"}, {"MyEnumName", "Title_Value"}}, + expected: []string{"myEnumNameTitleValue", "myEnumNametitle_value", "myEnumNametitle_Value", "myEnumNameTitle_Value"}, + }, + { + input: [][]string{{"MyEnumName", "TitleValue", "OtherValue"}}, + expected: []string{"myEnumNameTitleValueOtherValue"}, + }, + { + input: [][]string{{"MyEnumName", "TitleValue", "OtherValue"}, {"MyEnumName", "title_value", "OtherValue"}}, + expected: []string{"myEnumNameTitleValueOtherValue", "myEnumNametitle_valueOtherValue"}, + }, + } + + for ti, at := range theTests { + resetModelNames() + t.Run(fmt.Sprintf("modelname-%d", ti), func(t *testing.T) { + at := at + for i, n := range at.input { + require.Equal(t, at.expected[i], ToGoPrivateModelName(n...)) + } + }) + } +} + +func Test_wordWalker(t *testing.T) { + makeInput := func(str string) []*wordInfo { + resultList := make([]*wordInfo, 0) + wordWalker(str, func(info *wordInfo) { + resultList = append(resultList, info) + }) + return resultList + } + + type aTest struct { + expected []*wordInfo + input []*wordInfo + } + + theTests := []aTest{ + { + input: makeInput("TO_CAMEL"), + expected: []*wordInfo{{Word: "TO"}, {WordOffset: 1, Word: "CAMEL"}}, + }, + { + input: makeInput("to_camel"), + expected: []*wordInfo{{Word: "to"}, {WordOffset: 1, Word: "camel"}}, + }, + { + input: makeInput("toCamel"), + expected: []*wordInfo{{Word: "to"}, {WordOffset: 1, Word: "Camel"}}, + }, + { + input: makeInput("ToCamel"), + expected: []*wordInfo{{Word: "To"}, {WordOffset: 1, Word: "Camel"}}, + }, + { + input: makeInput("to-camel"), + expected: []*wordInfo{{Word: "to"}, {WordOffset: 1, Word: "camel"}}, + }, + { + input: makeInput("RelatedURLs"), + expected: []*wordInfo{{Word: "Related"}, {WordOffset: 1, Word: "URLs", HasCommonInitial: true}}, + }, + { + input: makeInput("ImageIDs"), + expected: []*wordInfo{{Word: "Image"}, {WordOffset: 1, Word: "IDs", HasCommonInitial: true}}, + }, + { + input: makeInput("FooID"), + expected: []*wordInfo{{Word: "Foo"}, {WordOffset: 1, Word: "ID", HasCommonInitial: true, MatchCommonInitial: true}}, + }, + { + input: makeInput("IDFoo"), + expected: []*wordInfo{{Word: "ID", HasCommonInitial: true, MatchCommonInitial: true}, {WordOffset: 1, Word: "Foo"}}, + }, + { + input: makeInput("FooASCII"), + expected: []*wordInfo{{Word: "Foo"}, {WordOffset: 1, Word: "ASCII", HasCommonInitial: true, MatchCommonInitial: true}}, + }, + { + input: makeInput("ASCIIFoo"), + expected: []*wordInfo{{Word: "ASCII", HasCommonInitial: true, MatchCommonInitial: true}, {WordOffset: 1, Word: "Foo"}}, + }, + { + input: makeInput("FooUTF8"), + expected: []*wordInfo{{Word: "Foo"}, {WordOffset: 1, Word: "UTF8", HasCommonInitial: true, MatchCommonInitial: true}}, + }, + { + input: makeInput("UTF8Foo"), + expected: []*wordInfo{{Word: "UTF8", HasCommonInitial: true, MatchCommonInitial: true}, {WordOffset: 1, Word: "Foo"}}, + }, + { + input: makeInput("A"), + expected: []*wordInfo{{Word: "A"}}, + }, + { + input: makeInput("ID"), + expected: []*wordInfo{{Word: "ID", HasCommonInitial: true, MatchCommonInitial: true}}, + }, + { + input: makeInput("id"), + expected: []*wordInfo{{Word: "id", HasCommonInitial: true, MatchCommonInitial: true}}, + }, + { + input: makeInput(""), + expected: make([]*wordInfo, 0), + }, + { + input: makeInput("RelatedUrls"), + expected: []*wordInfo{{Word: "Related"}, {WordOffset: 1, Word: "Urls"}}, + }, + { + input: makeInput("ITicket"), + expected: []*wordInfo{{Word: "ITicket"}}, + }, + } + + for i, at := range theTests { + t.Run(fmt.Sprintf("wordWalker-%d", i), func(t *testing.T) { + require.Equal(t, at.input, at.expected) + }) + } +} + +func TestCenter(t *testing.T) { + require.Equal(t, "fffff", center(3, "#", "fffff")) + require.Equal(t, "##fffff###", center(10, "#", "fffff")) + require.Equal(t, "###fffff###", center(11, "#", "fffff")) +} + +func TestTemplateOverride(t *testing.T) { + f, err := os.CreateTemp("", "gqlgen") + if err != nil { + t.Fatal(err) + } + defer f.Close() + defer os.RemoveAll(f.Name()) + err = Render(Options{Template: "hello", Filename: f.Name(), Packages: code.NewPackages()}) + if err != nil { + t.Fatal(err) + } +} + +func TestRenderFS(t *testing.T) { + + tempDir := t.TempDir() + + outDir := filepath.Join(tempDir, "output") + + _ = os.Mkdir(outDir, 0o755) + + f, err := os.CreateTemp(outDir, "gqlgen.go") + if err != nil { + t.Fatal(err) + } + defer f.Close() + defer os.RemoveAll(f.Name()) + err = Render(Options{TemplateFS: templateFS, Filename: f.Name(), Packages: code.NewPackages()}) + if err != nil { + t.Fatal(err) + } + + expectedString := "package \n\nimport (\n)\nthis is my test package" + actualContents, _ := os.ReadFile(f.Name()) + actualContentsStr := string(actualContents) + + // don't look at last character since it's \n on Linux and \r\n on Windows + assert.Equal(t, expectedString, actualContentsStr[:len(expectedString)]) +} diff --git a/codegen/templates/test.gotpl b/codegen/templates/test.gotpl new file mode 100644 index 0000000..07b8462 --- /dev/null +++ b/codegen/templates/test.gotpl @@ -0,0 +1 @@ +this is my test package diff --git a/codegen/templates/test_.gotpl b/codegen/templates/test_.gotpl new file mode 100644 index 0000000..c74258f --- /dev/null +++ b/codegen/templates/test_.gotpl @@ -0,0 +1 @@ +this will not be included diff --git a/codegen/templates/testdata/a/bar/bar.go b/codegen/templates/testdata/a/bar/bar.go new file mode 100644 index 0000000..ddac0fa --- /dev/null +++ b/codegen/templates/testdata/a/bar/bar.go @@ -0,0 +1 @@ +package bar diff --git a/codegen/templates/testdata/b/bar/bar.go b/codegen/templates/testdata/b/bar/bar.go new file mode 100644 index 0000000..ddac0fa --- /dev/null +++ b/codegen/templates/testdata/b/bar/bar.go @@ -0,0 +1 @@ +package bar diff --git a/codegen/templates/testdata/pkg_mismatch/turtles.go b/codegen/templates/testdata/pkg_mismatch/turtles.go new file mode 100644 index 0000000..a90e707 --- /dev/null +++ b/codegen/templates/testdata/pkg_mismatch/turtles.go @@ -0,0 +1 @@ +package turtles diff --git a/codegen/testserver/empty.go b/codegen/testserver/empty.go new file mode 100644 index 0000000..e46955d --- /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 0000000..7f69b75 --- /dev/null +++ b/codegen/testserver/followschema/builtinscalar.generated.go @@ -0,0 +1,125 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "strconv" + "sync/atomic" + + "github.com/niko0xdev/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) { + fc, err := ec.fieldContext_Map_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Map_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Map", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +// 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Map") + case "id": + out.Values[i] = ec._Map_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +// endregion ***************************** type.gotpl ***************************** diff --git a/codegen/testserver/followschema/builtinscalar.graphql b/codegen/testserver/followschema/builtinscalar.graphql new file mode 100644 index 0000000..deb8a9f --- /dev/null +++ b/codegen/testserver/followschema/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/followschema/bytes.go b/codegen/testserver/followschema/bytes.go new file mode 100644 index 0000000..948d584 --- /dev/null +++ b/codegen/testserver/followschema/bytes.go @@ -0,0 +1,27 @@ +package followschema + +import ( + "fmt" + "io" + + "github.com/niko0xdev/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 0000000..24abeaa --- /dev/null +++ b/codegen/testserver/followschema/complexity.generated.go @@ -0,0 +1,351 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "strconv" + "sync/atomic" + + "github.com/niko0xdev/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) { + fc, err := ec.fieldContext_OverlappingFields_oneFoo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_OverlappingFields_oneFoo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "OverlappingFields", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _OverlappingFields_twoFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_OverlappingFields_twoFoo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_OverlappingFields_twoFoo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "OverlappingFields", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _OverlappingFields_oldFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_OverlappingFields_oldFoo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_OverlappingFields_oldFoo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "OverlappingFields", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _OverlappingFields_newFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_OverlappingFields_newFoo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_OverlappingFields_newFoo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "OverlappingFields", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _OverlappingFields_new_foo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_OverlappingFields_new_foo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_OverlappingFields_new_foo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "OverlappingFields", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +// 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("OverlappingFields") + case "oneFoo": + out.Values[i] = ec._OverlappingFields_oneFoo(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "twoFoo": + out.Values[i] = ec._OverlappingFields_twoFoo(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "oldFoo": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "newFoo": + out.Values[i] = ec._OverlappingFields_newFoo(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "new_foo": + out.Values[i] = ec._OverlappingFields_new_foo(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) marshalOOverlappingFields2ᚖgithubᚗcomᚋniko0xdevᚋ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/followschema/complexity.graphql b/codegen/testserver/followschema/complexity.graphql new file mode 100644 index 0000000..c6a1868 --- /dev/null +++ b/codegen/testserver/followschema/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/followschema/complexity_test.go b/codegen/testserver/followschema/complexity_test.go new file mode 100644 index 0000000..77e1a43 --- /dev/null +++ b/codegen/testserver/followschema/complexity_test.go @@ -0,0 +1,120 @@ +package followschema + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/handler/extension" +) + +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 0000000..a5bd31e --- /dev/null +++ b/codegen/testserver/followschema/defaults.generated.go @@ -0,0 +1,583 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "fmt" + "strconv" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +type MutationResolver interface { + DefaultInput(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error) + OverrideValueViaInput(ctx context.Context, input FieldsOrderInput) (*FieldsOrderPayload, 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["input"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_overrideValueViaInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 FieldsOrderInput + if tmp, ok := rawArgs["input"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) + arg0, err = ec.unmarshalNFieldsOrderInput2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFieldsOrderInput(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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) { + fc, err := ec.fieldContext_DefaultParametersMirror_falsyBoolean(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_DefaultParametersMirror_falsyBoolean(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "DefaultParametersMirror", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _DefaultParametersMirror_truthyBoolean(ctx context.Context, field graphql.CollectedField, obj *DefaultParametersMirror) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_DefaultParametersMirror_truthyBoolean(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_DefaultParametersMirror_truthyBoolean(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "DefaultParametersMirror", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Mutation_defaultInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_defaultInput(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultParametersMirror(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_defaultInput(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "falsyBoolean": + return ec.fieldContext_DefaultParametersMirror_falsyBoolean(ctx, field) + case "truthyBoolean": + return ec.fieldContext_DefaultParametersMirror_truthyBoolean(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type DefaultParametersMirror", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_defaultInput_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_overrideValueViaInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_overrideValueViaInput(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().OverrideValueViaInput(rctx, fc.Args["input"].(FieldsOrderInput)) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*FieldsOrderPayload) + fc.Result = res + return ec.marshalNFieldsOrderPayload2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFieldsOrderPayload(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_overrideValueViaInput(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "firstFieldValue": + return ec.fieldContext_FieldsOrderPayload_firstFieldValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type FieldsOrderPayload", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_overrideValueViaInput_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_updateSomething(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateSomething(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Mutation_updateSomething(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_updateSomething_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_updatePtrToPtr(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updatePtrToPtr(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrOuter(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_updatePtrToPtr(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_PtrToPtrOuter_name(ctx, field) + case "inner": + return ec.fieldContext_PtrToPtrOuter_inner(ctx, field) + case "stupidInner": + return ec.fieldContext_PtrToPtrOuter_stupidInner(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PtrToPtrOuter", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_updatePtrToPtr_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +// 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 + } + + fieldsInOrder := [...]string{"falsyBoolean", "truthyBoolean"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "falsyBoolean": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("falsyBoolean")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.FalsyBoolean = data + case "truthyBoolean": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("truthyBoolean")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.TruthyBoolean = data + } + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("DefaultParametersMirror") + case "falsyBoolean": + out.Values[i] = ec._DefaultParametersMirror_falsyBoolean(ctx, field, obj) + case "truthyBoolean": + out.Values[i] = ec._DefaultParametersMirror_truthyBoolean(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_defaultInput(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "overrideValueViaInput": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_overrideValueViaInput(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "updateSomething": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_updateSomething(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "updatePtrToPtr": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_updatePtrToPtr(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) unmarshalNDefaultInput2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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 0000000..1c9a9eb --- /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 0000000..646dbf4 --- /dev/null +++ b/codegen/testserver/followschema/defaults_test.go @@ -0,0 +1,69 @@ +package followschema + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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/defer.generated.go b/codegen/testserver/followschema/defer.generated.go new file mode 100644 index 0000000..2bf8c2e --- /dev/null +++ b/codegen/testserver/followschema/defer.generated.go @@ -0,0 +1,317 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "strconv" + "sync" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +type DeferModelResolver interface { + Values(ctx context.Context, obj *DeferModel) ([]string, error) +} + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +// endregion ***************************** args.gotpl ***************************** + +// region ************************** directives.gotpl ************************** + +// endregion ************************** directives.gotpl ************************** + +// region **************************** field.gotpl ***************************** + +func (ec *executionContext) _DeferModel_id(ctx context.Context, field graphql.CollectedField, obj *DeferModel) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_DeferModel_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_DeferModel_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "DeferModel", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _DeferModel_name(ctx context.Context, field graphql.CollectedField, obj *DeferModel) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_DeferModel_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_DeferModel_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "DeferModel", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _DeferModel_values(ctx context.Context, field graphql.CollectedField, obj *DeferModel) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_DeferModel_values(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.DeferModel().Values(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.marshalNString2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_DeferModel_values(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "DeferModel", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var deferModelImplementors = []string{"DeferModel"} + +func (ec *executionContext) _DeferModel(ctx context.Context, sel ast.SelectionSet, obj *DeferModel) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, deferModelImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("DeferModel") + case "id": + out.Values[i] = ec._DeferModel_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "name": + out.Values[i] = ec._DeferModel_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "values": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._DeferModel_values(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) marshalNDeferModel2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDeferModel(ctx context.Context, sel ast.SelectionSet, v *DeferModel) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._DeferModel(ctx, sel, v) +} + +func (ec *executionContext) marshalODeferModel2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDeferModelᚄ(ctx context.Context, sel ast.SelectionSet, v []*DeferModel) 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.marshalNDeferModel2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDeferModel(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) marshalODeferModel2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDeferModel(ctx context.Context, sel ast.SelectionSet, v *DeferModel) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._DeferModel(ctx, sel, v) +} + +// endregion ***************************** type.gotpl ***************************** diff --git a/codegen/testserver/followschema/defer.graphql b/codegen/testserver/followschema/defer.graphql new file mode 100644 index 0000000..c31e0de --- /dev/null +++ b/codegen/testserver/followschema/defer.graphql @@ -0,0 +1,10 @@ +extend type Query { + deferCase1: DeferModel + deferCase2: [DeferModel!] +} + +type DeferModel { + id: ID! + name: String! + values: [String!]! @goField(forceResolver: true) +} diff --git a/codegen/testserver/followschema/directive.generated.go b/codegen/testserver/followschema/directive.generated.go new file mode 100644 index 0000000..852dbf6 --- /dev/null +++ b/codegen/testserver/followschema/directive.generated.go @@ -0,0 +1,748 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "fmt" + "strconv" + "sync/atomic" + + "github.com/niko0xdev/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) { + fc, err := ec.fieldContext_ObjectDirectives_text(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ObjectDirectives_text(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ObjectDirectives", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ObjectDirectives_nullableText(ctx context.Context, field graphql.CollectedField, obj *ObjectDirectives) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ObjectDirectives_nullableText(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ObjectDirectives_nullableText(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ObjectDirectives", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ObjectDirectives_order(ctx context.Context, field graphql.CollectedField, obj *ObjectDirectives) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ObjectDirectives_order(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ObjectDirectives_order(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ObjectDirectives", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ObjectDirectivesWithCustomGoModel_nullableText(ctx context.Context, field graphql.CollectedField, obj *ObjectDirectivesWithCustomGoModel) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ObjectDirectivesWithCustomGoModel_nullableText(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) +} + +func (ec *executionContext) fieldContext_ObjectDirectivesWithCustomGoModel_nullableText(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ObjectDirectivesWithCustomGoModel", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// 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 + } + + fieldsInOrder := [...]string{"message"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "message": + 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 + } + + fieldsInOrder := [...]string{"text", "nullableText", "inner", "innerNullable", "thirdParty"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "text": + 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": + 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": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inner")) + directive0 := func(ctx context.Context) (interface{}, error) { + return ec.unmarshalNInnerDirectives2ᚖgithubᚗcomᚋniko0xdevᚋ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/niko0xdev/gqlgen/codegen/testserver/followschema.InnerDirectives`, tmp) + return it, graphql.ErrorOnPath(ctx, err) + } + case "innerNullable": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("innerNullable")) + directive0 := func(ctx context.Context) (interface{}, error) { + return ec.unmarshalOInnerDirectives2ᚖgithubᚗcomᚋniko0xdevᚋ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/niko0xdev/gqlgen/codegen/testserver/followschema.InnerDirectives`, tmp) + return it, graphql.ErrorOnPath(ctx, err) + } + case "thirdParty": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("thirdParty")) + directive0 := func(ctx context.Context) (interface{}, error) { + return ec.unmarshalOThirdParty2ᚖgithubᚗcomᚋniko0xdevᚋ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/niko0xdev/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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ObjectDirectives") + case "text": + out.Values[i] = ec._ObjectDirectives_text(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "nullableText": + out.Values[i] = ec._ObjectDirectives_nullableText(ctx, field, obj) + case "order": + out.Values[i] = ec._ObjectDirectives_order(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ObjectDirectivesWithCustomGoModel") + case "nullableText": + out.Values[i] = ec._ObjectDirectivesWithCustomGoModel_nullableText(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) unmarshalNInnerDirectives2ᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/followschema/directive.graphql b/codegen/testserver/followschema/directive.graphql new file mode 100644 index 0000000..8cf2470 --- /dev/null +++ b/codegen/testserver/followschema/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/followschema/directive_test.go b/codegen/testserver/followschema/directive_test.go new file mode 100644 index 0000000..1fcffa5 --- /dev/null +++ b/codegen/testserver/followschema/directive_test.go @@ -0,0 +1,466 @@ +package followschema + +import ( + "context" + "fmt" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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 0000000..7c57721 --- /dev/null +++ b/codegen/testserver/followschema/embedded.generated.go @@ -0,0 +1,306 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "strconv" + "sync/atomic" + + "github.com/niko0xdev/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) { + fc, err := ec.fieldContext_EmbeddedCase1_exportedEmbeddedPointerExportedMethod(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_EmbeddedCase1_exportedEmbeddedPointerExportedMethod(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "EmbeddedCase1", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(ctx context.Context, field graphql.CollectedField, obj *EmbeddedCase2) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "EmbeddedCase2", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod(ctx context.Context, field graphql.CollectedField, obj *EmbeddedCase3) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) +} + +func (ec *executionContext) fieldContext_EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "EmbeddedCase3", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("EmbeddedCase1") + case "exportedEmbeddedPointerExportedMethod": + out.Values[i] = ec._EmbeddedCase1_exportedEmbeddedPointerExportedMethod(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("EmbeddedCase2") + case "unexportedEmbeddedPointerExportedMethod": + out.Values[i] = ec._EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("EmbeddedCase3") + case "unexportedEmbeddedInterfaceExportedMethod": + out.Values[i] = ec._EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) marshalOEmbeddedCase12ᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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 0000000..f22f83b --- /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 0000000..e707a23 --- /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 0000000..cfe08b7 --- /dev/null +++ b/codegen/testserver/followschema/embedded_test.go @@ -0,0 +1,67 @@ +package followschema + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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 0000000..7550b57 --- /dev/null +++ b/codegen/testserver/followschema/enum.generated.go @@ -0,0 +1,87 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + + "github.com/niko0xdev/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 + } + + fieldsInOrder := [...]string{"enum"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "enum": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("enum")) + data, err := ec.unmarshalNEnumTest2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEnumTest(ctx, v) + if err != nil { + return it, err + } + it.Enum = data + } + } + + 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ᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEnumTest(ctx context.Context, sel ast.SelectionSet, v EnumTest) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalOInputWithEnumValue2ᚖgithubᚗcomᚋniko0xdevᚋ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/followschema/enum.graphql b/codegen/testserver/followschema/enum.graphql new file mode 100644 index 0000000..08559b6 --- /dev/null +++ b/codegen/testserver/followschema/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/followschema/enums_test.go b/codegen/testserver/followschema/enums_test.go new file mode 100644 index 0000000..07fec86 --- /dev/null +++ b/codegen/testserver/followschema/enums_test.go @@ -0,0 +1,53 @@ +package followschema + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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":"Value \"INVALID\" does not exist in \"EnumTest!\" enum.","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/fields_order.generated.go b/codegen/testserver/followschema/fields_order.generated.go new file mode 100644 index 0000000..740c5f3 --- /dev/null +++ b/codegen/testserver/followschema/fields_order.generated.go @@ -0,0 +1,178 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "strconv" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +type FieldsOrderInputResolver interface { + OverrideFirstField(ctx context.Context, obj *FieldsOrderInput, data *string) error +} + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +// endregion ***************************** args.gotpl ***************************** + +// region ************************** directives.gotpl ************************** + +// endregion ************************** directives.gotpl ************************** + +// region **************************** field.gotpl ***************************** + +func (ec *executionContext) _FieldsOrderPayload_firstFieldValue(ctx context.Context, field graphql.CollectedField, obj *FieldsOrderPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_FieldsOrderPayload_firstFieldValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.FirstFieldValue, nil + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_FieldsOrderPayload_firstFieldValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "FieldsOrderPayload", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputFieldsOrderInput(ctx context.Context, obj interface{}) (FieldsOrderInput, error) { + var it FieldsOrderInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"firstField", "overrideFirstField"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "firstField": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("firstField")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.FirstField = data + case "overrideFirstField": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("overrideFirstField")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + if err = ec.resolvers.FieldsOrderInput().OverrideFirstField(ctx, &it, data); err != nil { + return it, err + } + } + } + + return it, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var fieldsOrderPayloadImplementors = []string{"FieldsOrderPayload"} + +func (ec *executionContext) _FieldsOrderPayload(ctx context.Context, sel ast.SelectionSet, obj *FieldsOrderPayload) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, fieldsOrderPayloadImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("FieldsOrderPayload") + case "firstFieldValue": + out.Values[i] = ec._FieldsOrderPayload_firstFieldValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) unmarshalNFieldsOrderInput2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFieldsOrderInput(ctx context.Context, v interface{}) (FieldsOrderInput, error) { + res, err := ec.unmarshalInputFieldsOrderInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNFieldsOrderPayload2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFieldsOrderPayload(ctx context.Context, sel ast.SelectionSet, v FieldsOrderPayload) graphql.Marshaler { + return ec._FieldsOrderPayload(ctx, sel, &v) +} + +func (ec *executionContext) marshalNFieldsOrderPayload2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFieldsOrderPayload(ctx context.Context, sel ast.SelectionSet, v *FieldsOrderPayload) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._FieldsOrderPayload(ctx, sel, v) +} + +// endregion ***************************** type.gotpl ***************************** diff --git a/codegen/testserver/followschema/fields_order.go b/codegen/testserver/followschema/fields_order.go new file mode 100644 index 0000000..8c540d3 --- /dev/null +++ b/codegen/testserver/followschema/fields_order.go @@ -0,0 +1,5 @@ +package followschema + +type FieldsOrderInput struct { + FirstField *string `json:"firstField"` +} diff --git a/codegen/testserver/followschema/fields_order.graphql b/codegen/testserver/followschema/fields_order.graphql new file mode 100644 index 0000000..7be4328 --- /dev/null +++ b/codegen/testserver/followschema/fields_order.graphql @@ -0,0 +1,12 @@ +type FieldsOrderPayload { + firstFieldValue: String +} + +input FieldsOrderInput { + firstField: String + overrideFirstField: String +} + +extend type Mutation { + overrideValueViaInput(input: FieldsOrderInput!): FieldsOrderPayload! +} diff --git a/codegen/testserver/followschema/fields_order_test.go b/codegen/testserver/followschema/fields_order_test.go new file mode 100644 index 0000000..535c1b4 --- /dev/null +++ b/codegen/testserver/followschema/fields_order_test.go @@ -0,0 +1,66 @@ +package followschema + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +type FieldsOrderPayloadResults struct { + OverrideValueViaInput struct { + FirstFieldValue *string `json:"firstFieldValue"` + } `json:"overrideValueViaInput"` +} + +func TestFieldsOrder(t *testing.T) { + resolvers := &Stub{} + + c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))) + resolvers.FieldsOrderInputResolver.OverrideFirstField = func(ctx context.Context, in *FieldsOrderInput, data *string) error { + if data != nil { + in.FirstField = data + } + return nil + } + resolvers.MutationResolver.OverrideValueViaInput = func(ctx context.Context, in FieldsOrderInput) (ret *FieldsOrderPayload, err error) { + ret = &FieldsOrderPayload{ + FirstFieldValue: in.FirstField, + } + return ret, nil + } + + t.Run("firstField", func(t *testing.T) { + var resp FieldsOrderPayloadResults + + err := c.Post(`mutation { + overrideValueViaInput(input: { firstField:"newName" }) { + firstFieldValue + } + }`, &resp) + require.NoError(t, err) + + require.NotNil(t, resp.OverrideValueViaInput.FirstFieldValue) + require.Equal(t, "newName", *resp.OverrideValueViaInput.FirstFieldValue) + }) + + t.Run("firstField/override", func(t *testing.T) { + var resp FieldsOrderPayloadResults + + err := c.Post(`mutation { overrideValueViaInput(input: { + firstField:"newName", + overrideFirstField: "override" + }) { + firstFieldValue + } + }`, &resp) + require.NoError(t, err) + + require.NotNil(t, resp.OverrideValueViaInput.FirstFieldValue) + require.NotEqual(t, "newName", *resp.OverrideValueViaInput.FirstFieldValue) + require.Equal(t, "override", *resp.OverrideValueViaInput.FirstFieldValue) + }) +} diff --git a/codegen/testserver/followschema/generated_test.go b/codegen/testserver/followschema/generated_test.go new file mode 100644 index 0000000..2f222c3 --- /dev/null +++ b/codegen/testserver/followschema/generated_test.go @@ -0,0 +1,81 @@ +//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/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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 0000000..8a56acc --- /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/niko0xdev/gqlgen/codegen/testserver" + - "github.com/niko0xdev/gqlgen/codegen/testserver/followschema" + - "github.com/niko0xdev/gqlgen/codegen/testserver/followschema/introspection" + - "github.com/niko0xdev/gqlgen/codegen/testserver/followschema/invalid-packagename" + +models: + Email: + model: "github.com/niko0xdev/gqlgen/codegen/testserver/followschema.Email" + StringFromContextFunction: + model: "github.com/niko0xdev/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 0000000..3f3f014 --- /dev/null +++ b/codegen/testserver/followschema/input_test.go @@ -0,0 +1,342 @@ +package followschema + +import ( + "context" + "strconv" + "testing" + "time" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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":"String cannot represent a non string value: 1","locations":[{"line":1,"column":32}],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}},{"message":"String cannot represent a non string value: 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) + }) +} + +func TestInputOmittable(t *testing.T) { + resolvers := &Stub{} + srv := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})) + c := client.New(srv) + + t.Run("id field", func(t *testing.T) { + resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { + value, isSet := arg.ID.ValueOK() + if !isSet { + return "", nil + } + + if value == nil { + return "", nil + } + + return *value, nil + } + + var resp struct { + InputOmittable string + } + var err error + + err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { id: null }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { id: "foo" }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "foo", resp.InputOmittable) + }) + + t.Run("bool field", func(t *testing.T) { + resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { + value, isSet := arg.Bool.ValueOK() + if !isSet { + return "", nil + } + + if value == nil { + return "", nil + } + + return strconv.FormatBool(*value), nil + } + + var resp struct { + InputOmittable string + } + var err error + + err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { bool: null }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { bool: false }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "false", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { bool: true }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "true", resp.InputOmittable) + }) + + t.Run("str field", func(t *testing.T) { + resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { + value, isSet := arg.Str.ValueOK() + if !isSet { + return "", nil + } + + if value == nil { + return "", nil + } + + return *value, nil + } + + var resp struct { + InputOmittable string + } + var err error + + err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { str: null }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { str: "bar" }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "bar", resp.InputOmittable) + }) + + t.Run("int field", func(t *testing.T) { + resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { + value, isSet := arg.Int.ValueOK() + if !isSet { + return "", nil + } + + if value == nil { + return "", nil + } + + return strconv.Itoa(*value), nil + } + + var resp struct { + InputOmittable string + } + var err error + + err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { int: null }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { int: 42 }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "42", resp.InputOmittable) + }) + + t.Run("time field", func(t *testing.T) { + resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { + value, isSet := arg.Time.ValueOK() + if !isSet { + return "", nil + } + + if value == nil { + return "", nil + } + + return value.UTC().Format(time.RFC3339), nil + } + + var resp struct { + InputOmittable string + } + var err error + + err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { time: null }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { time: "2011-04-05T16:01:33Z" }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "2011-04-05T16:01:33Z", resp.InputOmittable) + }) + + t.Run("enum field", func(t *testing.T) { + resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { + value, isSet := arg.Enum.ValueOK() + if !isSet { + return "", nil + } + + if value == nil { + return "", nil + } + + return value.String(), nil + } + + var resp struct { + InputOmittable string + } + var err error + + err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { enum: null }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { enum: OK }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "OK", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { enum: ERROR }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "ERROR", resp.InputOmittable) + }) + + t.Run("scalar field", func(t *testing.T) { + resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { + value, isSet := arg.Scalar.ValueOK() + if !isSet { + return "", nil + } + + if value == nil { + return "", nil + } + + return value.str, nil + } + + var resp struct { + InputOmittable string + } + var err error + + err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { scalar: null }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { scalar: "baz" }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "baz", resp.InputOmittable) + }) + + t.Run("object field", func(t *testing.T) { + resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { + value, isSet := arg.Object.ValueOK() + if !isSet { + return "", nil + } + + if value == nil { + return "", nil + } + + return strconv.Itoa(value.Inner.ID), nil + } + + var resp struct { + InputOmittable string + } + var err error + + err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { object: null }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { object: { inner: { id: 21 } } }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "21", resp.InputOmittable) + }) +} diff --git a/codegen/testserver/followschema/interfaces.generated.go b/codegen/testserver/followschema/interfaces.generated.go new file mode 100644 index 0000000..0bb21d5 --- /dev/null +++ b/codegen/testserver/followschema/interfaces.generated.go @@ -0,0 +1,1916 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + + "github.com/niko0xdev/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) { + fc, err := ec.fieldContext_BackedByInterface_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_BackedByInterface_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "BackedByInterface", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _BackedByInterface_thisShouldBind(ctx context.Context, field graphql.CollectedField, obj BackedByInterface) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BackedByInterface_thisShouldBind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_BackedByInterface_thisShouldBind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "BackedByInterface", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _BackedByInterface_thisShouldBindWithError(ctx context.Context, field graphql.CollectedField, obj BackedByInterface) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BackedByInterface_thisShouldBindWithError(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_BackedByInterface_thisShouldBindWithError(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "BackedByInterface", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Cat_species(ctx context.Context, field graphql.CollectedField, obj *Cat) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Cat_species(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Cat_species(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Cat", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Cat_size(ctx context.Context, field graphql.CollectedField, obj *Cat) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Cat_size(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Size, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*Size) + fc.Result = res + return ec.marshalNSize2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSize(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Cat_size(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Cat", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "height": + return ec.fieldContext_Size_height(ctx, field) + case "weight": + return ec.fieldContext_Size_weight(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Size", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Cat_catBreed(ctx context.Context, field graphql.CollectedField, obj *Cat) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Cat_catBreed(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Cat_catBreed(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Cat", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Circle_radius(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Circle_radius(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Circle", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Circle_area(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Circle_area(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Circle", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Circle_coordinates(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Circle_coordinates(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCoordinates(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Circle_coordinates(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Circle", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "x": + return ec.fieldContext_Coordinates_x(ctx, field) + case "y": + return ec.fieldContext_Coordinates_y(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Coordinates", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _ConcreteNodeA_id(ctx context.Context, field graphql.CollectedField, obj *ConcreteNodeA) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ConcreteNodeA_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ConcreteNodeA_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ConcreteNodeA", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ConcreteNodeA_child(ctx context.Context, field graphql.CollectedField, obj *ConcreteNodeA) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ConcreteNodeA_child(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNode(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ConcreteNodeA_child(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ConcreteNodeA", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + }, + } + return fc, nil +} + +func (ec *executionContext) _ConcreteNodeA_name(ctx context.Context, field graphql.CollectedField, obj *ConcreteNodeA) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ConcreteNodeA_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ConcreteNodeA_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ConcreteNodeA", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ConcreteNodeInterface_id(ctx context.Context, field graphql.CollectedField, obj ConcreteNodeInterface) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ConcreteNodeInterface_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ConcreteNodeInterface_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ConcreteNodeInterface", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ConcreteNodeInterface_child(ctx context.Context, field graphql.CollectedField, obj ConcreteNodeInterface) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ConcreteNodeInterface_child(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNode(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ConcreteNodeInterface_child(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ConcreteNodeInterface", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + }, + } + return fc, nil +} + +func (ec *executionContext) _Coordinates_x(ctx context.Context, field graphql.CollectedField, obj *Coordinates) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Coordinates_x(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Coordinates_x(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Coordinates", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Coordinates_y(ctx context.Context, field graphql.CollectedField, obj *Coordinates) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Coordinates_y(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Coordinates_y(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Coordinates", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Dog_species(ctx context.Context, field graphql.CollectedField, obj *Dog) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Dog_species(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Dog_species(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Dog", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Dog_size(ctx context.Context, field graphql.CollectedField, obj *Dog) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Dog_size(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Size, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*Size) + fc.Result = res + return ec.marshalNSize2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSize(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Dog_size(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Dog", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "height": + return ec.fieldContext_Size_height(ctx, field) + case "weight": + return ec.fieldContext_Size_weight(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Size", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Dog_dogBreed(ctx context.Context, field graphql.CollectedField, obj *Dog) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Dog_dogBreed(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Dog_dogBreed(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Dog", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Horse_species(ctx context.Context, field graphql.CollectedField, obj *Horse) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Horse_species(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Horse_species(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Horse", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Horse_size(ctx context.Context, field graphql.CollectedField, obj *Horse) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Horse_size(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Size, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*Size) + fc.Result = res + return ec.marshalNSize2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSize(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Horse_size(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Horse", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "height": + return ec.fieldContext_Size_height(ctx, field) + case "weight": + return ec.fieldContext_Size_weight(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Size", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Horse_horseBreed(ctx context.Context, field graphql.CollectedField, obj *Horse) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Horse_horseBreed(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.HorseBreed, 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) fieldContext_Horse_horseBreed(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Horse", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Rectangle_length(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Rectangle_length(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Rectangle", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Rectangle_width(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Rectangle_width(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Rectangle", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Rectangle_area(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Rectangle_area(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Rectangle", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Rectangle_coordinates(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Rectangle_coordinates(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCoordinates(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Rectangle_coordinates(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Rectangle", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "x": + return ec.fieldContext_Coordinates_x(ctx, field) + case "y": + return ec.fieldContext_Coordinates_y(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Coordinates", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Size_height(ctx context.Context, field graphql.CollectedField, obj *Size) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Size_height(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Height, 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) fieldContext_Size_height(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Size", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Size_weight(ctx context.Context, field graphql.CollectedField, obj *Size) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Size_weight(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Weight, 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) fieldContext_Size_weight(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Size", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +// 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 Horse: + return ec._Horse(ctx, sel, &obj) + case *Horse: + if obj == nil { + return graphql.Null + } + return ec._Horse(ctx, sel, obj) + 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) + case Mammalian: + if obj == nil { + return graphql.Null + } + return ec._Mammalian(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +func (ec *executionContext) _Mammalian(ctx context.Context, sel ast.SelectionSet, obj Mammalian) graphql.Marshaler { + switch obj := (obj).(type) { + case nil: + return graphql.Null + case Horse: + return ec._Horse(ctx, sel, &obj) + case *Horse: + if obj == nil { + return graphql.Null + } + return ec._Horse(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) + deferred := make(map[string]*graphql.FieldSet) + 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, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "thisShouldBind": + out.Values[i] = ec._BackedByInterface_thisShouldBind(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "thisShouldBindWithError": + out.Values[i] = ec._BackedByInterface_thisShouldBindWithError(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Cat") + case "species": + out.Values[i] = ec._Cat_species(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "size": + out.Values[i] = ec._Cat_size(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "catBreed": + out.Values[i] = ec._Cat_catBreed(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Circle") + case "radius": + out.Values[i] = ec._Circle_radius(ctx, field, obj) + case "area": + out.Values[i] = ec._Circle_area(ctx, field, obj) + case "coordinates": + out.Values[i] = ec._Circle_coordinates(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ConcreteNodeA") + case "id": + out.Values[i] = ec._ConcreteNodeA_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "child": + out.Values[i] = ec._ConcreteNodeA_child(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec._ConcreteNodeA_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ConcreteNodeInterface") + case "id": + out.Values[i] = ec._ConcreteNodeInterface_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "child": + out.Values[i] = ec._ConcreteNodeInterface_child(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Coordinates") + case "x": + out.Values[i] = ec._Coordinates_x(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "y": + out.Values[i] = ec._Coordinates_y(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Dog") + case "species": + out.Values[i] = ec._Dog_species(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "size": + out.Values[i] = ec._Dog_size(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "dogBreed": + out.Values[i] = ec._Dog_dogBreed(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var horseImplementors = []string{"Horse", "Mammalian", "Animal"} + +func (ec *executionContext) _Horse(ctx context.Context, sel ast.SelectionSet, obj *Horse) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, horseImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Horse") + case "species": + out.Values[i] = ec._Horse_species(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "size": + out.Values[i] = ec._Horse_size(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "horseBreed": + out.Values[i] = ec._Horse_horseBreed(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Rectangle") + case "length": + out.Values[i] = ec._Rectangle_length(ctx, field, obj) + case "width": + out.Values[i] = ec._Rectangle_width(ctx, field, obj) + case "area": + out.Values[i] = ec._Rectangle_area(ctx, field, obj) + case "coordinates": + out.Values[i] = ec._Rectangle_coordinates(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var sizeImplementors = []string{"Size"} + +func (ec *executionContext) _Size(ctx context.Context, sel ast.SelectionSet, obj *Size) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, sizeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Size") + case "height": + out.Values[i] = ec._Size_height(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "weight": + out.Values[i] = ec._Size_weight(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) marshalNNode2githubᚗcomᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Node(ctx, sel, v) +} + +func (ec *executionContext) marshalNShapeUnion2githubᚗcomᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._ShapeUnion(ctx, sel, v) +} + +func (ec *executionContext) marshalNSize2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSize(ctx context.Context, sel ast.SelectionSet, v *Size) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Size(ctx, sel, v) +} + +func (ec *executionContext) marshalOAnimal2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCoordinates(ctx context.Context, sel ast.SelectionSet, v Coordinates) graphql.Marshaler { + return ec._Coordinates(ctx, sel, &v) +} + +func (ec *executionContext) marshalODog2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDog(ctx context.Context, sel ast.SelectionSet, v *Dog) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Dog(ctx, sel, v) +} + +func (ec *executionContext) marshalOShape2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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 0000000..77475f3 --- /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 0000000..b354162 --- /dev/null +++ b/codegen/testserver/followschema/interfaces.graphql @@ -0,0 +1,91 @@ +extend type Query { + shapes: [Shape] + noShape: Shape @makeNil + node: Node! + noShapeTypedNil: Shape @makeTypedNil + animal: Animal @makeTypedNil + notAnInterface: BackedByInterface + dog: Dog +} + +interface Animal { + species: String! + size: Size! +} + +type Size { + height: Int! + weight: Int! +} + +type BackedByInterface { + id: String! + thisShouldBind: String! + thisShouldBindWithError: String! +} + +type Dog implements Animal { + species: String! + size: Size! + dogBreed: String! +} + +type Cat implements Animal { + species: String! + size: Size! + 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! +} + +interface Mammalian implements Animal { + species: String! + size: Size! +} + +# Types with multiple interfaces are evaluated first in the case statement +type Horse implements Mammalian & Animal { + species: String! + size: Size! + horseBreed: String! +} diff --git a/codegen/testserver/followschema/interfaces_test.go b/codegen/testserver/followschema/interfaces_test.go new file mode 100644 index 0000000..5bddec8 --- /dev/null +++ b/codegen/testserver/followschema/interfaces_test.go @@ -0,0 +1,298 @@ +package followschema + +import ( + "context" + "fmt" + "reflect" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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) + }) + + t.Run("fragment on interface must return merged fields", func(t *testing.T) { + resolvers := &Stub{} + resolvers.QueryResolver.Dog = func(ctx context.Context) (dog *Dog, err error) { + return &Dog{ + Size: &Size{ + Height: 100, + Weight: 35, + }, + }, nil + } + + c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))) + var resp struct { + Dog struct { + Size struct { + Height int + Weight int + } + } + } + + c.MustPost(` + { + dog { + size { + height + } + ...AnimalWeight + } + } + fragment AnimalWeight on Animal { + size { + weight + } + } + `, &resp) + + require.Equal(t, 100, resp.Dog.Size.Height) + require.Equal(t, 35, resp.Dog.Size.Weight) + }) +} diff --git a/codegen/testserver/followschema/introspection/it.go b/codegen/testserver/followschema/introspection/it.go new file mode 100644 index 0000000..e184968 --- /dev/null +++ b/codegen/testserver/followschema/introspection/it.go @@ -0,0 +1,5 @@ +package introspection + +type It struct { + ID string +} diff --git a/codegen/testserver/followschema/introspection_test.go b/codegen/testserver/followschema/introspection_test.go new file mode 100644 index 0000000..0e31bd0 --- /dev/null +++ b/codegen/testserver/followschema/introspection_test.go @@ -0,0 +1,80 @@ +package followschema + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" + "github.com/niko0xdev/gqlgen/graphql/introspection" +) + +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/followschema/invalid-packagename/invalid-identifier.go b/codegen/testserver/followschema/invalid-packagename/invalid-identifier.go new file mode 100644 index 0000000..fe0feb7 --- /dev/null +++ b/codegen/testserver/followschema/invalid-packagename/invalid-identifier.go @@ -0,0 +1,5 @@ +package invalid_packagename + +type InvalidIdentifier struct { + ID int +} diff --git a/codegen/testserver/followschema/issue896.generated.go b/codegen/testserver/followschema/issue896.generated.go new file mode 100644 index 0000000..4e40561 --- /dev/null +++ b/codegen/testserver/followschema/issue896.generated.go @@ -0,0 +1,225 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "strconv" + "sync" + "sync/atomic" + + "github.com/niko0xdev/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) { + fc, err := ec.fieldContext_CheckIssue896_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) +} + +func (ec *executionContext) fieldContext_CheckIssue896_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CheckIssue896", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +// 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("CheckIssue896") + case "id": + out.Values[i] = ec._CheckIssue896_id(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) marshalNCheckIssue8962ᚖgithubᚗcomᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._CheckIssue896(ctx, sel, v) +} + +func (ec *executionContext) marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/followschema/issue896.graphql b/codegen/testserver/followschema/issue896.graphql new file mode 100644 index 0000000..4cfe79e --- /dev/null +++ b/codegen/testserver/followschema/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/niko0xdev/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/followschema/loops.generated.go b/codegen/testserver/followschema/loops.generated.go new file mode 100644 index 0000000..971ee70 --- /dev/null +++ b/codegen/testserver/followschema/loops.generated.go @@ -0,0 +1,233 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "fmt" + "strconv" + "sync/atomic" + + "github.com/niko0xdev/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) { + fc, err := ec.fieldContext_LoopA_b(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐLoopB(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_LoopA_b(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "LoopA", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "a": + return ec.fieldContext_LoopB_a(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type LoopB", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _LoopB_a(ctx context.Context, field graphql.CollectedField, obj *LoopB) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_LoopB_a(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐLoopA(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_LoopB_a(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "LoopB", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "b": + return ec.fieldContext_LoopA_b(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type LoopA", field.Name) + }, + } + return fc, nil +} + +// 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("LoopA") + case "b": + out.Values[i] = ec._LoopA_b(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("LoopB") + case "a": + out.Values[i] = ec._LoopB_a(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) marshalNLoopA2ᚖgithubᚗcomᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._LoopA(ctx, sel, v) +} + +func (ec *executionContext) marshalNLoopB2ᚖgithubᚗcomᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._LoopB(ctx, sel, v) +} + +// endregion ***************************** type.gotpl ***************************** diff --git a/codegen/testserver/followschema/loops.graphql b/codegen/testserver/followschema/loops.graphql new file mode 100644 index 0000000..0254ef4 --- /dev/null +++ b/codegen/testserver/followschema/loops.graphql @@ -0,0 +1,7 @@ +type LoopA { + b: LoopB! +} + +type LoopB { + a: LoopA! +} diff --git a/codegen/testserver/followschema/maps.generated.go b/codegen/testserver/followschema/maps.generated.go new file mode 100644 index 0000000..46dfa45 --- /dev/null +++ b/codegen/testserver/followschema/maps.generated.go @@ -0,0 +1,526 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "fmt" + "strconv" + "sync/atomic" + + "github.com/niko0xdev/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) _MapNested_value(ctx context.Context, field graphql.CollectedField, obj *MapNested) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MapNested_value(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.(CustomScalar) + fc.Result = res + return ec.marshalNCustomScalar2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MapNested_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MapNested", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type CustomScalar does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MapStringInterfaceType_a(ctx context.Context, field graphql.CollectedField, obj map[string]interface{}) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MapStringInterfaceType_a(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_MapStringInterfaceType_a(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MapStringInterfaceType", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MapStringInterfaceType_b(ctx context.Context, field graphql.CollectedField, obj map[string]interface{}) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MapStringInterfaceType_b(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) +} + +func (ec *executionContext) fieldContext_MapStringInterfaceType_b(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MapStringInterfaceType", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MapStringInterfaceType_c(ctx context.Context, field graphql.CollectedField, obj map[string]interface{}) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MapStringInterfaceType_c(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + switch v := obj["c"].(type) { + case *CustomScalar: + return v, nil + case CustomScalar: + return &v, nil + case nil: + return (*CustomScalar)(nil), nil + default: + return nil, fmt.Errorf("unexpected type %T for field %s", v, "c") + } + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*CustomScalar) + fc.Result = res + return ec.marshalOCustomScalar2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MapStringInterfaceType_c(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MapStringInterfaceType", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type CustomScalar does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MapStringInterfaceType_nested(ctx context.Context, field graphql.CollectedField, obj map[string]interface{}) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MapStringInterfaceType_nested(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + switch v := obj["nested"].(type) { + case *MapNested: + return v, nil + case MapNested: + return &v, nil + case nil: + return (*MapNested)(nil), nil + default: + return nil, fmt.Errorf("unexpected type %T for field %s", v, "nested") + } + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*MapNested) + fc.Result = res + return ec.marshalOMapNested2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMapNested(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MapStringInterfaceType_nested(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MapStringInterfaceType", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "value": + return ec.fieldContext_MapNested_value(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type MapNested", field.Name) + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputMapNestedInput(ctx context.Context, obj interface{}) (MapNested, error) { + var it MapNested + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"value"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "value": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("value")) + data, err := ec.unmarshalNCustomScalar2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar(ctx, v) + if err != nil { + return it, err + } + it.Value = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputMapStringInterfaceInput(ctx context.Context, obj interface{}) (map[string]interface{}, error) { + it := make(map[string]interface{}, len(obj.(map[string]interface{}))) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"a", "b", "c", "nested"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "a": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("a")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it["a"] = data + case "b": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("b")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it["b"] = data + case "c": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("c")) + data, err := ec.unmarshalOCustomScalar2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar(ctx, v) + if err != nil { + return it, err + } + it["c"] = data + case "nested": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nested")) + data, err := ec.unmarshalOMapNestedInput2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMapNested(ctx, v) + if err != nil { + return it, err + } + it["nested"] = data + } + } + + return it, nil +} + +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 + } + + fieldsInOrder := [...]string{"map"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "map": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("map")) + data, err := ec.unmarshalOMapStringInterfaceInput2map(ctx, v) + if err != nil { + return it, err + } + it.Map = data + } + } + + return it, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var mapNestedImplementors = []string{"MapNested"} + +func (ec *executionContext) _MapNested(ctx context.Context, sel ast.SelectionSet, obj *MapNested) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, mapNestedImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("MapNested") + case "value": + out.Values[i] = ec._MapNested_value(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("MapStringInterfaceType") + case "a": + out.Values[i] = ec._MapStringInterfaceType_a(ctx, field, obj) + case "b": + out.Values[i] = ec._MapStringInterfaceType_b(ctx, field, obj) + case "c": + out.Values[i] = ec._MapStringInterfaceType_c(ctx, field, obj) + case "nested": + out.Values[i] = ec._MapStringInterfaceType_nested(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) unmarshalNCustomScalar2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar(ctx context.Context, v interface{}) (CustomScalar, error) { + var res CustomScalar + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNCustomScalar2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar(ctx context.Context, sel ast.SelectionSet, v CustomScalar) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalOCustomScalar2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar(ctx context.Context, v interface{}) (*CustomScalar, error) { + if v == nil { + return nil, nil + } + var res = new(CustomScalar) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOCustomScalar2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar(ctx context.Context, sel ast.SelectionSet, v *CustomScalar) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) marshalOMapNested2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMapNested(ctx context.Context, sel ast.SelectionSet, v *MapNested) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._MapNested(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOMapNestedInput2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMapNested(ctx context.Context, v interface{}) (*MapNested, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMapNestedInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalOMapStringInterfaceInput2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMapStringInterfaceInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +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ᚋniko0xdevᚋ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/followschema/maps.go b/codegen/testserver/followschema/maps.go new file mode 100644 index 0000000..871aabf --- /dev/null +++ b/codegen/testserver/followschema/maps.go @@ -0,0 +1,28 @@ +package followschema + +import ( + "io" + "strconv" +) + +type MapNested struct { + Value CustomScalar +} + +type CustomScalar struct { + value int64 +} + +func (s *CustomScalar) UnmarshalGQL(v interface{}) (err error) { + switch v := v.(type) { + case string: + s.value, err = strconv.ParseInt(v, 10, 64) + case int64: + s.value = v + } + return +} + +func (s CustomScalar) MarshalGQL(w io.Writer) { + _, _ = w.Write([]byte(strconv.Quote(strconv.FormatInt(s.value, 10)))) +} diff --git a/codegen/testserver/followschema/maps.graphql b/codegen/testserver/followschema/maps.graphql new file mode 100644 index 0000000..51eac07 --- /dev/null +++ b/codegen/testserver/followschema/maps.graphql @@ -0,0 +1,32 @@ +extend type Query { + mapStringInterface(in: MapStringInterfaceInput): MapStringInterfaceType + mapNestedStringInterface(in: NestedMapInput): MapStringInterfaceType +} + +type MapStringInterfaceType @goModel(model: "map[string]interface{}") { + a: String + b: Int + c: CustomScalar + nested: MapNested +} + +type MapNested @goModel(model: "followschema.MapNested") { + value: CustomScalar! +} + +input MapStringInterfaceInput @goModel(model: "map[string]interface{}") { + a: String! + b: Int + c: CustomScalar + nested: MapNestedInput +} + +input MapNestedInput @goModel(model: "followschema.MapNested") { + value: CustomScalar! +} + +scalar CustomScalar @goModel(model: "followschema.CustomScalar") + +input NestedMapInput { + map: MapStringInterfaceInput +} diff --git a/codegen/testserver/followschema/maps_test.go b/codegen/testserver/followschema/maps_test.go new file mode 100644 index 0000000..2f4aeae --- /dev/null +++ b/codegen/testserver/followschema/maps_test.go @@ -0,0 +1,101 @@ +package followschema + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +func TestMaps(t *testing.T) { + resolver := &Stub{} + resolver.QueryResolver.MapStringInterface = func(ctx context.Context, in map[string]interface{}) (i map[string]interface{}, e error) { + validateMapItemsType(t, in) + return in, nil + } + resolver.QueryResolver.MapNestedStringInterface = func(ctx context.Context, in *NestedMapInput) (i map[string]interface{}, e error) { + if in == nil { + return nil, nil + } + validateMapItemsType(t, in.Map) + 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, c, nested { value } } }`, &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, c, nested { value } } }`, &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($value: CustomScalar!) { mapStringInterface(in: { a: "a", b: null, c: 42, nested: { value: $value } }) { a, b, c, nested { value } } }`, &resp, client.Var("value", "17")) + require.NoError(t, err) + require.Equal(t, "a", resp.MapStringInterface["a"]) + require.Nil(t, resp.MapStringInterface["b"]) + require.Equal(t, "42", resp.MapStringInterface["c"]) + require.NotNil(t, resp.MapStringInterface["nested"]) + require.IsType(t, map[string]interface{}{}, resp.MapStringInterface["nested"]) + require.Equal(t, "17", (resp.MapStringInterface["nested"].(map[string]interface{}))["value"]) + }) + + t.Run("nested", func(t *testing.T) { + var resp struct { + MapNestedStringInterface map[string]interface{} + } + err := c.Post(`query { mapNestedStringInterface(in: { map: { a: "a", c: "42", nested: { value: 31 } } }) { a, b, c, nested { value } } }`, &resp) + require.NoError(t, err) + require.Equal(t, "a", resp.MapNestedStringInterface["a"]) + require.Nil(t, resp.MapNestedStringInterface["b"]) + require.Equal(t, "42", resp.MapNestedStringInterface["c"]) + require.NotNil(t, resp.MapNestedStringInterface["nested"]) + require.IsType(t, map[string]interface{}{}, resp.MapNestedStringInterface["nested"]) + require.Equal(t, "31", (resp.MapNestedStringInterface["nested"].(map[string]interface{}))["value"]) + }) + + 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, c, nested { value } } }`, &resp) + require.NoError(t, err) + require.Nil(t, resp.MapNestedStringInterface) + }) +} + +func validateMapItemsType(t *testing.T, in map[string]interface{}) { + for k, v := range in { + switch k { + case "a": + require.IsType(t, "", v) + case "b": + require.IsType(t, new(int), v) + case "c": + require.IsType(t, new(CustomScalar), v) + case "nested": + require.IsType(t, new(MapNested), v) + default: + require.Failf(t, "unexpected key in map", "key %q was not expected in map", k) + } + } +} diff --git a/codegen/testserver/followschema/middleware_test.go b/codegen/testserver/followschema/middleware_test.go new file mode 100644 index 0000000..9fceb1e --- /dev/null +++ b/codegen/testserver/followschema/middleware_test.go @@ -0,0 +1,109 @@ +package followschema + +import ( + "context" + "sync" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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 0000000..13dc82e --- /dev/null +++ b/codegen/testserver/followschema/modelmethod_test.go @@ -0,0 +1,45 @@ +package followschema + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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 0000000..9a5a31e --- /dev/null +++ b/codegen/testserver/followschema/models-gen.go @@ -0,0 +1,374 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "fmt" + "io" + "strconv" + "time" + + "github.com/niko0xdev/gqlgen/graphql" +) + +type Animal interface { + IsAnimal() + GetSpecies() string + GetSize() *Size +} + +type ContentChild interface { + IsContentChild() +} + +type Mammalian interface { + IsAnimal() + IsMammalian() + GetSpecies() string + GetSize() *Size +} + +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"` + Size *Size `json:"size"` + CatBreed string `json:"catBreed"` +} + +func (Cat) IsAnimal() {} +func (this Cat) GetSpecies() string { return this.Species } +func (this Cat) GetSize() *Size { return this.Size } + +type CheckIssue896 struct { + ID *int `json:"id,omitempty"` +} + +type ContentPost struct { + Foo *string `json:"foo,omitempty"` +} + +func (ContentPost) IsContentChild() {} + +type ContentUser struct { + Foo *string `json:"foo,omitempty"` +} + +func (ContentUser) IsContentChild() {} + +type Coordinates struct { + X float64 `json:"x"` + Y float64 `json:"y"` +} + +type DefaultInput struct { + FalsyBoolean *bool `json:"falsyBoolean,omitempty"` + TruthyBoolean *bool `json:"truthyBoolean,omitempty"` +} + +type DefaultParametersMirror struct { + FalsyBoolean *bool `json:"falsyBoolean,omitempty"` + TruthyBoolean *bool `json:"truthyBoolean,omitempty"` +} + +type DeferModel struct { + ID string `json:"id"` + Name string `json:"name"` + Values []string `json:"values"` +} + +type Dog struct { + Species string `json:"species"` + Size *Size `json:"size"` + DogBreed string `json:"dogBreed"` +} + +func (Dog) IsAnimal() {} +func (this Dog) GetSpecies() string { return this.Species } +func (this Dog) GetSize() *Size { return this.Size } + +type EmbeddedDefaultScalar struct { + Value *string `json:"value,omitempty"` +} + +type FieldsOrderPayload struct { + FirstFieldValue *string `json:"firstFieldValue,omitempty"` +} + +type Horse struct { + Species string `json:"species"` + Size *Size `json:"size"` + HorseBreed string `json:"horseBreed"` +} + +func (Horse) IsMammalian() {} +func (this Horse) GetSpecies() string { return this.Species } +func (this Horse) GetSize() *Size { return this.Size } + +func (Horse) IsAnimal() {} + +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,omitempty"` + Inner *InnerDirectives `json:"inner"` + InnerNullable *InnerDirectives `json:"innerNullable,omitempty"` + ThirdParty *ThirdParty `json:"thirdParty,omitempty"` +} + +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 Mutation struct { +} + +type NestedInput struct { + Field Email `json:"field"` +} + +type NestedMapInput struct { + Map map[string]interface{} `json:"map,omitempty"` +} + +type ObjectDirectives struct { + Text string `json:"text"` + NullableText *string `json:"nullableText,omitempty"` + Order []string `json:"order"` +} + +type OmittableInput struct { + ID graphql.Omittable[*string] `json:"id,omitempty"` + Bool graphql.Omittable[*bool] `json:"bool,omitempty"` + Str graphql.Omittable[*string] `json:"str,omitempty"` + Int graphql.Omittable[*int] `json:"int,omitempty"` + Time graphql.Omittable[*time.Time] `json:"time,omitempty"` + Enum graphql.Omittable[*Status] `json:"enum,omitempty"` + Scalar graphql.Omittable[*ThirdParty] `json:"scalar,omitempty"` + Object graphql.Omittable[*OuterInput] `json:"object,omitempty"` +} + +type OuterInput struct { + Inner *InnerInput `json:"inner"` +} + +type OuterObject struct { + Inner *InnerObject `json:"inner"` +} + +type Pet struct { + ID int `json:"id"` + Friends []*Pet `json:"friends,omitempty"` +} + +type Query struct { +} + +type Size struct { + Height int `json:"height"` + Weight int `json:"weight"` +} + +type Slices struct { + Test1 []*string `json:"test1,omitempty"` + Test2 []string `json:"test2,omitempty"` + Test3 []*string `json:"test3"` + Test4 []string `json:"test4"` +} + +type SpecialInput struct { + Nesting *NestedInput `json:"nesting"` +} + +type Subscription struct { +} + +type User struct { + ID int `json:"id"` + Friends []*User `json:"friends"` + Created time.Time `json:"created"` + Updated *time.Time `json:"updated,omitempty"` + Pets []*Pet `json:"pets,omitempty"` +} + +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 0000000..fa3a80c --- /dev/null +++ b/codegen/testserver/followschema/models.go @@ -0,0 +1,104 @@ +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 0000000..512541a --- /dev/null +++ b/codegen/testserver/followschema/mutation_with_custom_scalar.generated.go @@ -0,0 +1,116 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + + "github.com/niko0xdev/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 + } + + fieldsInOrder := [...]string{"field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "field": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + data, err := ec.unmarshalNEmail2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEmail(ctx, v) + if err != nil { + return it, err + } + it.Field = data + } + } + + 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 + } + + fieldsInOrder := [...]string{"nesting"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "nesting": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nesting")) + data, err := ec.unmarshalNNestedInput2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNestedInput(ctx, v) + if err != nil { + return it, err + } + it.Nesting = data + } + } + + 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ᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEmail(ctx context.Context, sel ast.SelectionSet, v Email) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalNNestedInput2ᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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 0000000..6245a5f --- /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/followschema/mutation_with_custom_scalar.graphql b/codegen/testserver/followschema/mutation_with_custom_scalar.graphql new file mode 100644 index 0000000..e9896dd --- /dev/null +++ b/codegen/testserver/followschema/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/followschema/mutation_with_custom_scalar_test.go b/codegen/testserver/followschema/mutation_with_custom_scalar_test.go new file mode 100644 index 0000000..ef1b974 --- /dev/null +++ b/codegen/testserver/followschema/mutation_with_custom_scalar_test.go @@ -0,0 +1,51 @@ +package followschema + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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 0000000..b3ff9bd --- /dev/null +++ b/codegen/testserver/followschema/nulls.generated.go @@ -0,0 +1,852 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + + "github.com/niko0xdev/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) { + fc, err := ec.fieldContext_Error_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Error_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Error", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Error_errorOnNonRequiredField(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Error", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Error_errorOnRequiredField(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Error_errorOnRequiredField(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Error", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Error_nilOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Error_nilOnRequiredField(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Error_nilOnRequiredField(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Error", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Errors_a(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Errors_a(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Errors_a(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Errors", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Error_id(ctx, field) + case "errorOnNonRequiredField": + return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) + case "errorOnRequiredField": + return ec.fieldContext_Error_errorOnRequiredField(ctx, field) + case "nilOnRequiredField": + return ec.fieldContext_Error_nilOnRequiredField(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Errors_b(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Errors_b(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Errors_b(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Errors", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Error_id(ctx, field) + case "errorOnNonRequiredField": + return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) + case "errorOnRequiredField": + return ec.fieldContext_Error_errorOnRequiredField(ctx, field) + case "nilOnRequiredField": + return ec.fieldContext_Error_nilOnRequiredField(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Errors_c(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Errors_c(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Errors_c(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Errors", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Error_id(ctx, field) + case "errorOnNonRequiredField": + return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) + case "errorOnRequiredField": + return ec.fieldContext_Error_errorOnRequiredField(ctx, field) + case "nilOnRequiredField": + return ec.fieldContext_Error_nilOnRequiredField(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Errors_d(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Errors_d(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Errors_d(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Errors", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Error_id(ctx, field) + case "errorOnNonRequiredField": + return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) + case "errorOnRequiredField": + return ec.fieldContext_Error_errorOnRequiredField(ctx, field) + case "nilOnRequiredField": + return ec.fieldContext_Error_nilOnRequiredField(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Errors_e(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Errors_e(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Errors_e(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Errors", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Error_id(ctx, field) + case "errorOnNonRequiredField": + return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) + case "errorOnRequiredField": + return ec.fieldContext_Error_errorOnRequiredField(ctx, field) + case "nilOnRequiredField": + return ec.fieldContext_Error_nilOnRequiredField(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) + }, + } + return fc, nil +} + +// 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Error") + case "id": + out.Values[i] = ec._Error_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "errorOnNonRequiredField": + out.Values[i] = ec._Error_errorOnNonRequiredField(ctx, field, obj) + case "errorOnRequiredField": + out.Values[i] = ec._Error_errorOnRequiredField(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "nilOnRequiredField": + out.Values[i] = ec._Error_nilOnRequiredField(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "b": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "c": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "d": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "e": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) marshalNError2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Error(ctx, sel, v) +} + +func (ec *executionContext) marshalOError2ᚕᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/followschema/nulls.graphql b/codegen/testserver/followschema/nulls.graphql new file mode 100644 index 0000000..23dd965 --- /dev/null +++ b/codegen/testserver/followschema/nulls.graphql @@ -0,0 +1,27 @@ +extend type Query { + errorBubble: Error + errorBubbleList: [Error!] + errorList: [Error] + errors: Errors + valid: String! + invalid: String! +} + +extend type Subscription { + errorRequired: Error! +} + +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/followschema/nulls_test.go b/codegen/testserver/followschema/nulls_test.go new file mode 100644 index 0000000..7c9c704 --- /dev/null +++ b/codegen/testserver/followschema/nulls_test.go @@ -0,0 +1,148 @@ +package followschema + +import ( + "context" + "errors" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +func TestNullBubbling(t *testing.T) { + resolvers := &Stub{} + resolvers.QueryResolver.Valid = func(ctx context.Context) (s string, e error) { + return "Ok", nil + } + resolvers.QueryResolver.Invalid = func(ctx context.Context) (s string, e error) { + return "Ok", errors.New("ERROR") + } + 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{{ID: "1"}, nil, 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":"the requested element is null which the schema does not allow","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.Contains(t, err.Error(), `{"message":"the requested element is null which the schema does not allow","path":["errorBubbleList",2]}`) + require.Contains(t, err.Error(), `{"message":"the requested element is null which the schema does not allow","path":["errorBubbleList",1]}`) + 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(), "the requested element is null which the schema does not allow") + }) + + t.Run("when non-nullable field returns content while error occurred", func(t *testing.T) { + var resp any + err := c.Post(`query { invalid }`, &resp) + require.Nil(t, resp) + require.NotNil(t, err) + require.Contains(t, err.Error(), `{"message":"ERROR","path":["invalid"]}`) + }) +} diff --git a/codegen/testserver/followschema/otherpkg/model.go b/codegen/testserver/followschema/otherpkg/model.go new file mode 100644 index 0000000..f2cc202 --- /dev/null +++ b/codegen/testserver/followschema/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/followschema/panics.generated.go b/codegen/testserver/followschema/panics.generated.go new file mode 100644 index 0000000..7afe7e6 --- /dev/null +++ b/codegen/testserver/followschema/panics.generated.go @@ -0,0 +1,417 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "strconv" + "sync/atomic" + + "github.com/niko0xdev/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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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) { + fc, err := ec.fieldContext_Panics_fieldScalarMarshal(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanicᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Panics_fieldScalarMarshal(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Panics", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type MarshalPanic does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Panics_fieldFuncMarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Panics_fieldFuncMarshal(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.FieldFuncMarshal(ctx, fc.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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanicᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Panics_fieldFuncMarshal(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Panics", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type MarshalPanic does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Panics_fieldFuncMarshal_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Panics_argUnmarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Panics_argUnmarshal(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) +} + +func (ec *executionContext) fieldContext_Panics_argUnmarshal(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Panics", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Panics_argUnmarshal_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +// 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) + deferred := make(map[string]*graphql.FieldSet) + 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, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "fieldFuncMarshal": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "argUnmarshal": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) unmarshalNMarshalPanic2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanic(ctx context.Context, sel ast.SelectionSet, v MarshalPanic) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalNMarshalPanic2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanicᚄ(ctx context.Context, v interface{}) ([]MarshalPanic, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanic(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalNMarshalPanic2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/followschema/panics.graphql b/codegen/testserver/followschema/panics.graphql new file mode 100644 index 0000000..8895fca --- /dev/null +++ b/codegen/testserver/followschema/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/followschema/panics_test.go b/codegen/testserver/followschema/panics_test.go new file mode 100644 index 0000000..9cd1f39 --- /dev/null +++ b/codegen/testserver/followschema/panics_test.go @@ -0,0 +1,69 @@ +package followschema + +import ( + "context" + "fmt" + "testing" + + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/v2/gqlerror" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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 0000000..6964f37 --- /dev/null +++ b/codegen/testserver/followschema/prelude.generated.go @@ -0,0 +1,2894 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/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) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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 { + vSlice = graphql.CoerceList(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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + res := graphql.MarshalString(*v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + 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) unmarshalOID2ᚖstring(ctx context.Context, v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalID(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOID2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := graphql.MarshalID(*v) + return 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 { + vSlice = graphql.CoerceList(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 { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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 0000000..df3ea3d --- /dev/null +++ b/codegen/testserver/followschema/primitive_objects.generated.go @@ -0,0 +1,542 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "strconv" + "sync" + "sync/atomic" + + "github.com/niko0xdev/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) { + fc, err := ec.fieldContext_Primitive_value(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Primitive_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Primitive", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Primitive_squared(ctx context.Context, field graphql.CollectedField, obj *Primitive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Primitive_squared(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Primitive_squared(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Primitive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PrimitiveString_value(ctx context.Context, field graphql.CollectedField, obj *PrimitiveString) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PrimitiveString_value(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_PrimitiveString_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PrimitiveString", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PrimitiveString_doubled(ctx context.Context, field graphql.CollectedField, obj *PrimitiveString) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PrimitiveString_doubled(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_PrimitiveString_doubled(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PrimitiveString", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PrimitiveString_len(ctx context.Context, field graphql.CollectedField, obj *PrimitiveString) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PrimitiveString_len(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) +} + +func (ec *executionContext) fieldContext_PrimitiveString_len(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PrimitiveString", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +// 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) + deferred := make(map[string]*graphql.FieldSet) + 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, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "squared": + out.Values[i] = ec._Primitive_squared(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "doubled": + out.Values[i] = ec._PrimitiveString_doubled(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "len": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) marshalNPrimitive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/followschema/primitive_objects.graphql b/codegen/testserver/followschema/primitive_objects.graphql new file mode 100644 index 0000000..c53702c --- /dev/null +++ b/codegen/testserver/followschema/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/followschema/primitive_objects_test.go b/codegen/testserver/followschema/primitive_objects_test.go new file mode 100644 index 0000000..419d4f6 --- /dev/null +++ b/codegen/testserver/followschema/primitive_objects_test.go @@ -0,0 +1,74 @@ +package followschema + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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_any.generated.go b/codegen/testserver/followschema/ptr_to_any.generated.go new file mode 100644 index 0000000..c4e8e9b --- /dev/null +++ b/codegen/testserver/followschema/ptr_to_any.generated.go @@ -0,0 +1,201 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "strconv" + "sync/atomic" + + "github.com/niko0xdev/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) _PtrToAnyContainer_ptrToAny(ctx context.Context, field graphql.CollectedField, obj *PtrToAnyContainer) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PtrToAnyContainer_ptrToAny(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PtrToAny, nil + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*any) + fc.Result = res + return ec.marshalOAny2ᚖinterface(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PtrToAnyContainer_ptrToAny(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PtrToAnyContainer", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Any does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PtrToAnyContainer_binding(ctx context.Context, field graphql.CollectedField, obj *PtrToAnyContainer) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PtrToAnyContainer_binding(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Binding(), nil + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*any) + fc.Result = res + return ec.marshalOAny2ᚖinterface(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PtrToAnyContainer_binding(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PtrToAnyContainer", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Any does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var ptrToAnyContainerImplementors = []string{"PtrToAnyContainer"} + +func (ec *executionContext) _PtrToAnyContainer(ctx context.Context, sel ast.SelectionSet, obj *PtrToAnyContainer) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, ptrToAnyContainerImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("PtrToAnyContainer") + case "ptrToAny": + out.Values[i] = ec._PtrToAnyContainer_ptrToAny(ctx, field, obj) + case "binding": + out.Values[i] = ec._PtrToAnyContainer_binding(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) marshalNPtrToAnyContainer2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToAnyContainer(ctx context.Context, sel ast.SelectionSet, v PtrToAnyContainer) graphql.Marshaler { + return ec._PtrToAnyContainer(ctx, sel, &v) +} + +func (ec *executionContext) marshalNPtrToAnyContainer2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToAnyContainer(ctx context.Context, sel ast.SelectionSet, v *PtrToAnyContainer) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._PtrToAnyContainer(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOAny2interface(ctx context.Context, v interface{}) (any, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalAny(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOAny2interface(ctx context.Context, sel ast.SelectionSet, v any) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := graphql.MarshalAny(v) + return res +} + +func (ec *executionContext) unmarshalOAny2ᚖinterface(ctx context.Context, v interface{}) (*any, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOAny2interface(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOAny2ᚖinterface(ctx context.Context, sel ast.SelectionSet, v *any) graphql.Marshaler { + return ec.marshalOAny2interface(ctx, sel, *v) +} + +// endregion ***************************** type.gotpl ***************************** diff --git a/codegen/testserver/followschema/ptr_to_any.go b/codegen/testserver/followschema/ptr_to_any.go new file mode 100644 index 0000000..655fcb6 --- /dev/null +++ b/codegen/testserver/followschema/ptr_to_any.go @@ -0,0 +1,9 @@ +package followschema + +type PtrToAnyContainer struct { + PtrToAny *any +} + +func (c *PtrToAnyContainer) Binding() *any { + return c.PtrToAny +} diff --git a/codegen/testserver/followschema/ptr_to_any.graphql b/codegen/testserver/followschema/ptr_to_any.graphql new file mode 100644 index 0000000..c86bf38 --- /dev/null +++ b/codegen/testserver/followschema/ptr_to_any.graphql @@ -0,0 +1,10 @@ +scalar Any + +type PtrToAnyContainer { + ptrToAny: Any + binding: Any +} + +extend type Query { + ptrToAnyContainer: PtrToAnyContainer! +} diff --git a/codegen/testserver/followschema/ptr_to_any_test.go b/codegen/testserver/followschema/ptr_to_any_test.go new file mode 100644 index 0000000..e7c6ce6 --- /dev/null +++ b/codegen/testserver/followschema/ptr_to_any_test.go @@ -0,0 +1,38 @@ +package followschema + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +func TestPtrToAny(t *testing.T) { + resolvers := &Stub{} + + c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))) + + var a any = `{"some":"thing"}` + resolvers.QueryResolver.PtrToAnyContainer = func(ctx context.Context) (wrappedStruct *PtrToAnyContainer, e error) { + ptrToAnyContainer := PtrToAnyContainer{ + PtrToAny: &a, + } + return &ptrToAnyContainer, nil + } + + t.Run("binding to pointer to any", func(t *testing.T) { + var resp struct { + PtrToAnyContainer struct { + Binding *any + } + } + + err := c.Post(`query { ptrToAnyContainer { binding }}`, &resp) + require.NoError(t, err) + + require.Equal(t, &a, resp.PtrToAnyContainer.Binding) + }) +} 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 0000000..59070e1 --- /dev/null +++ b/codegen/testserver/followschema/ptr_to_ptr_input.generated.go @@ -0,0 +1,579 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "fmt" + "strconv" + "sync/atomic" + + "github.com/niko0xdev/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) { + fc, err := ec.fieldContext_PtrToPtrInner_key(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_PtrToPtrInner_key(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PtrToPtrInner", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PtrToPtrInner_value(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrInner) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PtrToPtrInner_value(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_PtrToPtrInner_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PtrToPtrInner", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PtrToPtrOuter_name(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrOuter) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PtrToPtrOuter_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_PtrToPtrOuter_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PtrToPtrOuter", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PtrToPtrOuter_inner(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrOuter) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PtrToPtrOuter_inner(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PtrToPtrOuter_inner(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PtrToPtrOuter", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "key": + return ec.fieldContext_PtrToPtrInner_key(ctx, field) + case "value": + return ec.fieldContext_PtrToPtrInner_value(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PtrToPtrInner", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _PtrToPtrOuter_stupidInner(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrOuter) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PtrToPtrOuter_stupidInner(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PtrToPtrOuter_stupidInner(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PtrToPtrOuter", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "key": + return ec.fieldContext_PtrToPtrInner_key(ctx, field) + case "value": + return ec.fieldContext_PtrToPtrInner_value(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PtrToPtrInner", field.Name) + }, + } + return fc, nil +} + +// 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 + } + + fieldsInOrder := [...]string{"key", "value"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "key": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("key")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Key = data + case "value": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("value")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Value = data + } + } + + 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 + } + + fieldsInOrder := [...]string{"name", "inner", "stupidInner"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Name = data + case "inner": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inner")) + data, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx, v) + if err != nil { + return it, err + } + it.Inner = data + case "stupidInner": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("stupidInner")) + data, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx, v) + if err != nil { + return it, err + } + it.StupidInner = data + } + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("PtrToPtrInner") + case "key": + out.Values[i] = ec._PtrToPtrInner_key(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "value": + out.Values[i] = ec._PtrToPtrInner_value(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("PtrToPtrOuter") + case "name": + out.Values[i] = ec._PtrToPtrOuter_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "inner": + out.Values[i] = ec._PtrToPtrOuter_inner(ctx, field, obj) + case "stupidInner": + out.Values[i] = ec._PtrToPtrOuter_stupidInner(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) marshalNPtrToPtrOuter2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._PtrToPtrOuter(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNUpdatePtrToPtrOuter2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx, sel, *v) +} + +func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx, sel, *v) +} + +func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx, sel, *v) +} + +func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx, sel, *v) +} + +func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx, sel, *v) +} + +func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx, sel, *v) +} + +func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (**UpdatePtrToPtrInner, error) { + var pres *UpdatePtrToPtrInner + if v != nil { + res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (***UpdatePtrToPtrInner, error) { + var pres **UpdatePtrToPtrInner + if v != nil { + res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (****UpdatePtrToPtrInner, error) { + var pres ***UpdatePtrToPtrInner + if v != nil { + res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (*****UpdatePtrToPtrInner, error) { + var pres ****UpdatePtrToPtrInner + if v != nil { + res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (******UpdatePtrToPtrInner, error) { + var pres *****UpdatePtrToPtrInner + if v != nil { + res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (*******UpdatePtrToPtrInner, error) { + var pres ******UpdatePtrToPtrInner + if v != nil { + res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (********UpdatePtrToPtrInner, error) { + var pres *******UpdatePtrToPtrInner + if v != nil { + res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋniko0xdevᚋ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 0000000..c4c082b --- /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 0000000..c34b5c5 --- /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 0000000..84e6ed7 --- /dev/null +++ b/codegen/testserver/followschema/ptr_to_ptr_input_test.go @@ -0,0 +1,175 @@ +package followschema + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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 ret, err + } + + 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 0000000..c230261 --- /dev/null +++ b/codegen/testserver/followschema/ptr_to_slice.generated.go @@ -0,0 +1,133 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "strconv" + "sync/atomic" + + "github.com/niko0xdev/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) { + fc, err := ec.fieldContext_PtrToSliceContainer_ptrToSlice(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_PtrToSliceContainer_ptrToSlice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PtrToSliceContainer", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("PtrToSliceContainer") + case "ptrToSlice": + out.Values[i] = ec._PtrToSliceContainer_ptrToSlice(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) marshalNPtrToSliceContainer2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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 0000000..8cdd22d --- /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 0000000..b773d83 --- /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 0000000..3975655 --- /dev/null +++ b/codegen/testserver/followschema/ptr_to_slice_test.go @@ -0,0 +1,37 @@ +package followschema + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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 0000000..b5c096f --- /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 0000000..874ba15 --- /dev/null +++ b/codegen/testserver/followschema/resolver.go @@ -0,0 +1,597 @@ +package followschema + +// THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES. + +import ( + "context" + + introspection1 "github.com/niko0xdev/gqlgen/codegen/testserver/followschema/introspection" + invalid_packagename "github.com/niko0xdev/gqlgen/codegen/testserver/followschema/invalid-packagename" + "github.com/niko0xdev/gqlgen/codegen/testserver/followschema/otherpkg" +) + +type Resolver struct{} + +// ID is the resolver for the id field. +func (r *backedByInterfaceResolver) ID(ctx context.Context, obj BackedByInterface) (string, error) { + panic("not implemented") +} + +// Values is the resolver for the values field. +func (r *deferModelResolver) Values(ctx context.Context, obj *DeferModel) ([]string, error) { + panic("not implemented") +} + +// A is the resolver for the a field. +func (r *errorsResolver) A(ctx context.Context, obj *Errors) (*Error, error) { + panic("not implemented") +} + +// B is the resolver for the b field. +func (r *errorsResolver) B(ctx context.Context, obj *Errors) (*Error, error) { + panic("not implemented") +} + +// C is the resolver for the c field. +func (r *errorsResolver) C(ctx context.Context, obj *Errors) (*Error, error) { + panic("not implemented") +} + +// D is the resolver for the d field. +func (r *errorsResolver) D(ctx context.Context, obj *Errors) (*Error, error) { + panic("not implemented") +} + +// E is the resolver for the e field. +func (r *errorsResolver) E(ctx context.Context, obj *Errors) (*Error, error) { + panic("not implemented") +} + +// Field is the resolver for the field field. +func (r *forcedResolverResolver) Field(ctx context.Context, obj *ForcedResolver) (*Circle, error) { + panic("not implemented") +} + +// ResolverField is the resolver for the resolverField field. +func (r *modelMethodsResolver) ResolverField(ctx context.Context, obj *ModelMethods) (bool, error) { + panic("not implemented") +} + +// DefaultInput is the resolver for the defaultInput field. +func (r *mutationResolver) DefaultInput(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error) { + panic("not implemented") +} + +// OverrideValueViaInput is the resolver for the overrideValueViaInput field. +func (r *mutationResolver) OverrideValueViaInput(ctx context.Context, input FieldsOrderInput) (*FieldsOrderPayload, error) { + panic("not implemented") +} + +// UpdateSomething is the resolver for the updateSomething field. +func (r *mutationResolver) UpdateSomething(ctx context.Context, input SpecialInput) (string, error) { + panic("not implemented") +} + +// UpdatePtrToPtr is the resolver for the updatePtrToPtr field. +func (r *mutationResolver) UpdatePtrToPtr(ctx context.Context, input UpdatePtrToPtrOuter) (*PtrToPtrOuter, error) { + panic("not implemented") +} + +// OldFoo is the resolver for the oldFoo field. +func (r *overlappingFieldsResolver) OldFoo(ctx context.Context, obj *OverlappingFields) (int, error) { + panic("not implemented") +} + +// FieldScalarMarshal is the resolver for the fieldScalarMarshal field. +func (r *panicsResolver) FieldScalarMarshal(ctx context.Context, obj *Panics) ([]MarshalPanic, error) { + panic("not implemented") +} + +// ArgUnmarshal is the resolver for the argUnmarshal field. +func (r *panicsResolver) ArgUnmarshal(ctx context.Context, obj *Panics, u []MarshalPanic) (bool, error) { + panic("not implemented") +} + +// Friends is the resolver for the friends field. +func (r *petResolver) Friends(ctx context.Context, obj *Pet, limit *int) ([]*Pet, error) { + panic("not implemented") +} + +// Value is the resolver for the value field. +func (r *primitiveResolver) Value(ctx context.Context, obj *Primitive) (int, error) { + panic("not implemented") +} + +// Value is the resolver for the value field. +func (r *primitiveStringResolver) Value(ctx context.Context, obj *PrimitiveString) (string, error) { + panic("not implemented") +} + +// Len is the resolver for the len field. +func (r *primitiveStringResolver) Len(ctx context.Context, obj *PrimitiveString) (int, error) { + panic("not implemented") +} + +// InvalidIdentifier is the resolver for the invalidIdentifier field. +func (r *queryResolver) InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) { + panic("not implemented") +} + +// Collision is the resolver for the collision field. +func (r *queryResolver) Collision(ctx context.Context) (*introspection1.It, error) { + panic("not implemented") +} + +// MapInput is the resolver for the mapInput field. +func (r *queryResolver) MapInput(ctx context.Context, input map[string]interface{}) (*bool, error) { + panic("not implemented") +} + +// Recursive is the resolver for the recursive field. +func (r *queryResolver) Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error) { + panic("not implemented") +} + +// NestedInputs is the resolver for the nestedInputs field. +func (r *queryResolver) NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error) { + panic("not implemented") +} + +// NestedOutputs is the resolver for the nestedOutputs field. +func (r *queryResolver) NestedOutputs(ctx context.Context) ([][]*OuterObject, error) { + panic("not implemented") +} + +// ModelMethods is the resolver for the modelMethods field. +func (r *queryResolver) ModelMethods(ctx context.Context) (*ModelMethods, error) { + panic("not implemented") +} + +// User is the resolver for the user field. +func (r *queryResolver) User(ctx context.Context, id int) (*User, error) { + panic("not implemented") +} + +// NullableArg is the resolver for the nullableArg field. +func (r *queryResolver) NullableArg(ctx context.Context, arg *int) (*string, error) { + panic("not implemented") +} + +// InputSlice is the resolver for the inputSlice field. +func (r *queryResolver) InputSlice(ctx context.Context, arg []string) (bool, error) { + panic("not implemented") +} + +// InputNullableSlice is the resolver for the inputNullableSlice field. +func (r *queryResolver) InputNullableSlice(ctx context.Context, arg []string) (bool, error) { + panic("not implemented") +} + +// InputOmittable is the resolver for the inputOmittable field. +func (r *queryResolver) InputOmittable(ctx context.Context, arg OmittableInput) (string, error) { + panic("not implemented") +} + +// ShapeUnion is the resolver for the shapeUnion field. +func (r *queryResolver) ShapeUnion(ctx context.Context) (ShapeUnion, error) { + panic("not implemented") +} + +// Autobind is the resolver for the autobind field. +func (r *queryResolver) Autobind(ctx context.Context) (*Autobind, error) { + panic("not implemented") +} + +// DeprecatedField is the resolver for the deprecatedField field. +func (r *queryResolver) DeprecatedField(ctx context.Context) (string, error) { + panic("not implemented") +} + +// Overlapping is the resolver for the overlapping field. +func (r *queryResolver) Overlapping(ctx context.Context) (*OverlappingFields, error) { + panic("not implemented") +} + +// DefaultParameters is the resolver for the defaultParameters field. +func (r *queryResolver) DefaultParameters(ctx context.Context, falsyBoolean *bool, truthyBoolean *bool) (*DefaultParametersMirror, error) { + panic("not implemented") +} + +// DeferCase1 is the resolver for the deferCase1 field. +func (r *queryResolver) DeferCase1(ctx context.Context) (*DeferModel, error) { + panic("not implemented") +} + +// DeferCase2 is the resolver for the deferCase2 field. +func (r *queryResolver) DeferCase2(ctx context.Context) ([]*DeferModel, error) { + panic("not implemented") +} + +// DirectiveArg is the resolver for the directiveArg field. +func (r *queryResolver) DirectiveArg(ctx context.Context, arg string) (*string, error) { + panic("not implemented") +} + +// DirectiveNullableArg is the resolver for the directiveNullableArg field. +func (r *queryResolver) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (*string, error) { + panic("not implemented") +} + +// DirectiveInputNullable is the resolver for the directiveInputNullable field. +func (r *queryResolver) DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) { + panic("not implemented") +} + +// DirectiveInput is the resolver for the directiveInput field. +func (r *queryResolver) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) { + panic("not implemented") +} + +// DirectiveInputType is the resolver for the directiveInputType field. +func (r *queryResolver) DirectiveInputType(ctx context.Context, arg InnerInput) (*string, error) { + panic("not implemented") +} + +// DirectiveObject is the resolver for the directiveObject field. +func (r *queryResolver) DirectiveObject(ctx context.Context) (*ObjectDirectives, error) { + panic("not implemented") +} + +// DirectiveObjectWithCustomGoModel is the resolver for the directiveObjectWithCustomGoModel field. +func (r *queryResolver) DirectiveObjectWithCustomGoModel(ctx context.Context) (*ObjectDirectivesWithCustomGoModel, error) { + panic("not implemented") +} + +// DirectiveFieldDef is the resolver for the directiveFieldDef field. +func (r *queryResolver) DirectiveFieldDef(ctx context.Context, ret string) (string, error) { + panic("not implemented") +} + +// DirectiveField is the resolver for the directiveField field. +func (r *queryResolver) DirectiveField(ctx context.Context) (*string, error) { + panic("not implemented") +} + +// DirectiveDouble is the resolver for the directiveDouble field. +func (r *queryResolver) DirectiveDouble(ctx context.Context) (*string, error) { + panic("not implemented") +} + +// DirectiveUnimplemented is the resolver for the directiveUnimplemented field. +func (r *queryResolver) DirectiveUnimplemented(ctx context.Context) (*string, error) { + panic("not implemented") +} + +// EmbeddedCase1 is the resolver for the embeddedCase1 field. +func (r *queryResolver) EmbeddedCase1(ctx context.Context) (*EmbeddedCase1, error) { + panic("not implemented") +} + +// EmbeddedCase2 is the resolver for the embeddedCase2 field. +func (r *queryResolver) EmbeddedCase2(ctx context.Context) (*EmbeddedCase2, error) { + panic("not implemented") +} + +// EmbeddedCase3 is the resolver for the embeddedCase3 field. +func (r *queryResolver) EmbeddedCase3(ctx context.Context) (*EmbeddedCase3, error) { + panic("not implemented") +} + +// EnumInInput is the resolver for the enumInInput field. +func (r *queryResolver) EnumInInput(ctx context.Context, input *InputWithEnumValue) (EnumTest, error) { + panic("not implemented") +} + +// Shapes is the resolver for the shapes field. +func (r *queryResolver) Shapes(ctx context.Context) ([]Shape, error) { + panic("not implemented") +} + +// NoShape is the resolver for the noShape field. +func (r *queryResolver) NoShape(ctx context.Context) (Shape, error) { + panic("not implemented") +} + +// Node is the resolver for the node field. +func (r *queryResolver) Node(ctx context.Context) (Node, error) { + panic("not implemented") +} + +// NoShapeTypedNil is the resolver for the noShapeTypedNil field. +func (r *queryResolver) NoShapeTypedNil(ctx context.Context) (Shape, error) { + panic("not implemented") +} + +// Animal is the resolver for the animal field. +func (r *queryResolver) Animal(ctx context.Context) (Animal, error) { + panic("not implemented") +} + +// NotAnInterface is the resolver for the notAnInterface field. +func (r *queryResolver) NotAnInterface(ctx context.Context) (BackedByInterface, error) { + panic("not implemented") +} + +// Dog is the resolver for the dog field. +func (r *queryResolver) Dog(ctx context.Context) (*Dog, error) { + panic("not implemented") +} + +// Issue896a is the resolver for the issue896a field. +func (r *queryResolver) Issue896a(ctx context.Context) ([]*CheckIssue896, error) { + panic("not implemented") +} + +// MapStringInterface is the resolver for the mapStringInterface field. +func (r *queryResolver) MapStringInterface(ctx context.Context, in map[string]interface{}) (map[string]interface{}, error) { + panic("not implemented") +} + +// MapNestedStringInterface is the resolver for the mapNestedStringInterface field. +func (r *queryResolver) MapNestedStringInterface(ctx context.Context, in *NestedMapInput) (map[string]interface{}, error) { + panic("not implemented") +} + +// ErrorBubble is the resolver for the errorBubble field. +func (r *queryResolver) ErrorBubble(ctx context.Context) (*Error, error) { + panic("not implemented") +} + +// ErrorBubbleList is the resolver for the errorBubbleList field. +func (r *queryResolver) ErrorBubbleList(ctx context.Context) ([]*Error, error) { + panic("not implemented") +} + +// ErrorList is the resolver for the errorList field. +func (r *queryResolver) ErrorList(ctx context.Context) ([]*Error, error) { + panic("not implemented") +} + +// Errors is the resolver for the errors field. +func (r *queryResolver) Errors(ctx context.Context) (*Errors, error) { + panic("not implemented") +} + +// Valid is the resolver for the valid field. +func (r *queryResolver) Valid(ctx context.Context) (string, error) { + panic("not implemented") +} + +// Invalid is the resolver for the invalid field. +func (r *queryResolver) Invalid(ctx context.Context) (string, error) { + panic("not implemented") +} + +// Panics is the resolver for the panics field. +func (r *queryResolver) Panics(ctx context.Context) (*Panics, error) { + panic("not implemented") +} + +// PrimitiveObject is the resolver for the primitiveObject field. +func (r *queryResolver) PrimitiveObject(ctx context.Context) ([]Primitive, error) { + panic("not implemented") +} + +// PrimitiveStringObject is the resolver for the primitiveStringObject field. +func (r *queryResolver) PrimitiveStringObject(ctx context.Context) ([]PrimitiveString, error) { + panic("not implemented") +} + +// PtrToAnyContainer is the resolver for the ptrToAnyContainer field. +func (r *queryResolver) PtrToAnyContainer(ctx context.Context) (*PtrToAnyContainer, error) { + panic("not implemented") +} + +// PtrToSliceContainer is the resolver for the ptrToSliceContainer field. +func (r *queryResolver) PtrToSliceContainer(ctx context.Context) (*PtrToSliceContainer, error) { + panic("not implemented") +} + +// Infinity is the resolver for the infinity field. +func (r *queryResolver) Infinity(ctx context.Context) (float64, error) { + panic("not implemented") +} + +// StringFromContextInterface is the resolver for the stringFromContextInterface field. +func (r *queryResolver) StringFromContextInterface(ctx context.Context) (*StringFromContextInterface, error) { + panic("not implemented") +} + +// StringFromContextFunction is the resolver for the stringFromContextFunction field. +func (r *queryResolver) StringFromContextFunction(ctx context.Context) (string, error) { + panic("not implemented") +} + +// DefaultScalar is the resolver for the defaultScalar field. +func (r *queryResolver) DefaultScalar(ctx context.Context, arg string) (string, error) { + panic("not implemented") +} + +// Slices is the resolver for the slices field. +func (r *queryResolver) Slices(ctx context.Context) (*Slices, error) { + panic("not implemented") +} + +// ScalarSlice is the resolver for the scalarSlice field. +func (r *queryResolver) ScalarSlice(ctx context.Context) ([]byte, error) { + panic("not implemented") +} + +// Fallback is the resolver for the fallback field. +func (r *queryResolver) Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) { + panic("not implemented") +} + +// OptionalUnion is the resolver for the optionalUnion field. +func (r *queryResolver) OptionalUnion(ctx context.Context) (TestUnion, error) { + panic("not implemented") +} + +// VOkCaseValue is the resolver for the vOkCaseValue field. +func (r *queryResolver) VOkCaseValue(ctx context.Context) (*VOkCaseValue, error) { + panic("not implemented") +} + +// VOkCaseNil is the resolver for the vOkCaseNil field. +func (r *queryResolver) VOkCaseNil(ctx context.Context) (*VOkCaseNil, error) { + panic("not implemented") +} + +// ValidType is the resolver for the validType field. +func (r *queryResolver) ValidType(ctx context.Context) (*ValidType, error) { + panic("not implemented") +} + +// VariadicModel is the resolver for the variadicModel field. +func (r *queryResolver) VariadicModel(ctx context.Context) (*VariadicModel, error) { + panic("not implemented") +} + +// WrappedStruct is the resolver for the wrappedStruct field. +func (r *queryResolver) WrappedStruct(ctx context.Context) (*WrappedStruct, error) { + panic("not implemented") +} + +// WrappedScalar is the resolver for the wrappedScalar field. +func (r *queryResolver) WrappedScalar(ctx context.Context) (otherpkg.Scalar, error) { + panic("not implemented") +} + +// WrappedMap is the resolver for the wrappedMap field. +func (r *queryResolver) WrappedMap(ctx context.Context) (WrappedMap, error) { + panic("not implemented") +} + +// WrappedSlice is the resolver for the wrappedSlice field. +func (r *queryResolver) WrappedSlice(ctx context.Context) (WrappedSlice, error) { + panic("not implemented") +} + +// Updated is the resolver for the updated field. +func (r *subscriptionResolver) Updated(ctx context.Context) (<-chan string, error) { + panic("not implemented") +} + +// InitPayload is the resolver for the initPayload field. +func (r *subscriptionResolver) InitPayload(ctx context.Context) (<-chan string, error) { + panic("not implemented") +} + +// DirectiveArg is the resolver for the directiveArg field. +func (r *subscriptionResolver) DirectiveArg(ctx context.Context, arg string) (<-chan *string, error) { + panic("not implemented") +} + +// DirectiveNullableArg is the resolver for the directiveNullableArg field. +func (r *subscriptionResolver) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (<-chan *string, error) { + panic("not implemented") +} + +// DirectiveDouble is the resolver for the directiveDouble field. +func (r *subscriptionResolver) DirectiveDouble(ctx context.Context) (<-chan *string, error) { + panic("not implemented") +} + +// DirectiveUnimplemented is the resolver for the directiveUnimplemented field. +func (r *subscriptionResolver) DirectiveUnimplemented(ctx context.Context) (<-chan *string, error) { + panic("not implemented") +} + +// Issue896b is the resolver for the issue896b field. +func (r *subscriptionResolver) Issue896b(ctx context.Context) (<-chan []*CheckIssue896, error) { + panic("not implemented") +} + +// ErrorRequired is the resolver for the errorRequired field. +func (r *subscriptionResolver) ErrorRequired(ctx context.Context) (<-chan *Error, error) { + panic("not implemented") +} + +// Friends is the resolver for the friends field. +func (r *userResolver) Friends(ctx context.Context, obj *User) ([]*User, error) { + panic("not implemented") +} + +// Pets is the resolver for the pets field. +func (r *userResolver) Pets(ctx context.Context, obj *User, limit *int) ([]*Pet, error) { + panic("not implemented") +} + +// Get is the resolver for the get field. +func (r *wrappedMapResolver) Get(ctx context.Context, obj WrappedMap, key string) (string, error) { + panic("not implemented") +} + +// Get is the resolver for the get field. +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} +} + +// DeferModel returns DeferModelResolver implementation. +func (r *Resolver) DeferModel() DeferModelResolver { return &deferModelResolver{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} } + +// Pet returns PetResolver implementation. +func (r *Resolver) Pet() PetResolver { return &petResolver{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 deferModelResolver 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 petResolver 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 0000000..d1431d3 --- /dev/null +++ b/codegen/testserver/followschema/response_extension_test.go @@ -0,0 +1,34 @@ +package followschema + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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 0000000..9b1a01a --- /dev/null +++ b/codegen/testserver/followschema/root_.generated.go @@ -0,0 +1,2321 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "bytes" + "context" + "embed" + "errors" + "fmt" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/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{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + BackedByInterface() BackedByInterfaceResolver + DeferModel() DeferModelResolver + Errors() ErrorsResolver + ForcedResolver() ForcedResolverResolver + ModelMethods() ModelMethodsResolver + Mutation() MutationResolver + OverlappingFields() OverlappingFieldsResolver + Panics() PanicsResolver + Pet() PetResolver + Primitive() PrimitiveResolver + PrimitiveString() PrimitiveStringResolver + Query() QueryResolver + Subscription() SubscriptionResolver + User() UserResolver + WrappedMap() WrappedMapResolver + WrappedSlice() WrappedSliceResolver + FieldsOrderInput() FieldsOrderInputResolver +} + +type DirectiveRoot struct { + Custom func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + Defer func(ctx context.Context, obj interface{}, next graphql.Resolver, ifArg *bool, label *string) (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 + Size 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 + } + + DeferModel struct { + ID func(childComplexity int) int + Name func(childComplexity int) int + Values func(childComplexity int) int + } + + Dog struct { + DogBreed func(childComplexity int) int + Size 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 + } + + FieldsOrderPayload struct { + FirstFieldValue func(childComplexity int) int + } + + ForcedResolver struct { + Field func(childComplexity int) int + } + + Horse struct { + HorseBreed func(childComplexity int) int + Size func(childComplexity int) int + Species 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 + } + + MapNested struct { + Value func(childComplexity int) int + } + + MapStringInterfaceType struct { + A func(childComplexity int) int + B func(childComplexity int) int + C func(childComplexity int) int + Nested 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 + OverrideValueViaInput func(childComplexity int, input FieldsOrderInput) 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 + } + + Pet struct { + Friends func(childComplexity int, limit *int) int + ID 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 + } + + PtrToAnyContainer struct { + Binding func(childComplexity int) int + PtrToAny 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 + DeferCase1 func(childComplexity int) int + DeferCase2 func(childComplexity int) 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 + Dog 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 + InputOmittable func(childComplexity int, arg OmittableInput) int + InputSlice func(childComplexity int, arg []string) int + Invalid func(childComplexity int) 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 + PtrToAnyContainer 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 + VariadicModel 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 + } + + Size struct { + Height func(childComplexity int) int + Weight 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 + ErrorRequired 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 + Pets func(childComplexity int, limit *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 + } + + VariadicModel struct { + Value func(childComplexity int, rank int) 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 { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = 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.size": + if e.complexity.Cat.Size == nil { + break + } + + return e.complexity.Cat.Size(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 "DeferModel.id": + if e.complexity.DeferModel.ID == nil { + break + } + + return e.complexity.DeferModel.ID(childComplexity), true + + case "DeferModel.name": + if e.complexity.DeferModel.Name == nil { + break + } + + return e.complexity.DeferModel.Name(childComplexity), true + + case "DeferModel.values": + if e.complexity.DeferModel.Values == nil { + break + } + + return e.complexity.DeferModel.Values(childComplexity), true + + case "Dog.dogBreed": + if e.complexity.Dog.DogBreed == nil { + break + } + + return e.complexity.Dog.DogBreed(childComplexity), true + + case "Dog.size": + if e.complexity.Dog.Size == nil { + break + } + + return e.complexity.Dog.Size(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 "FieldsOrderPayload.firstFieldValue": + if e.complexity.FieldsOrderPayload.FirstFieldValue == nil { + break + } + + return e.complexity.FieldsOrderPayload.FirstFieldValue(childComplexity), true + + case "ForcedResolver.field": + if e.complexity.ForcedResolver.Field == nil { + break + } + + return e.complexity.ForcedResolver.Field(childComplexity), true + + case "Horse.horseBreed": + if e.complexity.Horse.HorseBreed == nil { + break + } + + return e.complexity.Horse.HorseBreed(childComplexity), true + + case "Horse.size": + if e.complexity.Horse.Size == nil { + break + } + + return e.complexity.Horse.Size(childComplexity), true + + case "Horse.species": + if e.complexity.Horse.Species == nil { + break + } + + return e.complexity.Horse.Species(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 "MapNested.value": + if e.complexity.MapNested.Value == nil { + break + } + + return e.complexity.MapNested.Value(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 "MapStringInterfaceType.c": + if e.complexity.MapStringInterfaceType.C == nil { + break + } + + return e.complexity.MapStringInterfaceType.C(childComplexity), true + + case "MapStringInterfaceType.nested": + if e.complexity.MapStringInterfaceType.Nested == nil { + break + } + + return e.complexity.MapStringInterfaceType.Nested(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.overrideValueViaInput": + if e.complexity.Mutation.OverrideValueViaInput == nil { + break + } + + args, err := ec.field_Mutation_overrideValueViaInput_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.OverrideValueViaInput(childComplexity, args["input"].(FieldsOrderInput)), 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 "Pet.friends": + if e.complexity.Pet.Friends == nil { + break + } + + args, err := ec.field_Pet_friends_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Pet.Friends(childComplexity, args["limit"].(*int)), true + + case "Pet.id": + if e.complexity.Pet.ID == nil { + break + } + + return e.complexity.Pet.ID(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 "PtrToAnyContainer.binding": + if e.complexity.PtrToAnyContainer.Binding == nil { + break + } + + return e.complexity.PtrToAnyContainer.Binding(childComplexity), true + + case "PtrToAnyContainer.ptrToAny": + if e.complexity.PtrToAnyContainer.PtrToAny == nil { + break + } + + return e.complexity.PtrToAnyContainer.PtrToAny(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.deferCase1": + if e.complexity.Query.DeferCase1 == nil { + break + } + + return e.complexity.Query.DeferCase1(childComplexity), true + + case "Query.deferCase2": + if e.complexity.Query.DeferCase2 == nil { + break + } + + return e.complexity.Query.DeferCase2(childComplexity), 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.dog": + if e.complexity.Query.Dog == nil { + break + } + + return e.complexity.Query.Dog(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.inputOmittable": + if e.complexity.Query.InputOmittable == nil { + break + } + + args, err := ec.field_Query_inputOmittable_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.InputOmittable(childComplexity, args["arg"].(OmittableInput)), 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.invalid": + if e.complexity.Query.Invalid == nil { + break + } + + return e.complexity.Query.Invalid(childComplexity), 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.ptrToAnyContainer": + if e.complexity.Query.PtrToAnyContainer == nil { + break + } + + return e.complexity.Query.PtrToAnyContainer(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.variadicModel": + if e.complexity.Query.VariadicModel == nil { + break + } + + return e.complexity.Query.VariadicModel(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 "Size.height": + if e.complexity.Size.Height == nil { + break + } + + return e.complexity.Size.Height(childComplexity), true + + case "Size.weight": + if e.complexity.Size.Weight == nil { + break + } + + return e.complexity.Size.Weight(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.errorRequired": + if e.complexity.Subscription.ErrorRequired == nil { + break + } + + return e.complexity.Subscription.ErrorRequired(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.pets": + if e.complexity.User.Pets == nil { + break + } + + args, err := ec.field_User_pets_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.User.Pets(childComplexity, args["limit"].(*int)), 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 "VariadicModel.value": + if e.complexity.VariadicModel.Value == nil { + break + } + + args, err := ec.field_VariadicModel_value_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.VariadicModel.Value(childComplexity, args["rank"].(int)), 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, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap( + ec.unmarshalInputChanges, + ec.unmarshalInputDefaultInput, + ec.unmarshalInputFieldsOrderInput, + ec.unmarshalInputInnerDirectives, + ec.unmarshalInputInnerInput, + ec.unmarshalInputInputDirectives, + ec.unmarshalInputInputWithEnumValue, + ec.unmarshalInputMapNestedInput, + ec.unmarshalInputMapStringInterfaceInput, + ec.unmarshalInputNestedInput, + ec.unmarshalInputNestedMapInput, + ec.unmarshalInputOmittableInput, + ec.unmarshalInputOuterInput, + ec.unmarshalInputRecursiveInputSlice, + ec.unmarshalInputSpecialInput, + ec.unmarshalInputUpdatePtrToPtrInner, + ec.unmarshalInputUpdatePtrToPtrOuter, + ec.unmarshalInputValidInput, + ) + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + case ast.Mutation: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + 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(ctx) + + 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 + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + +//go:embed "builtinscalar.graphql" "complexity.graphql" "defaults.graphql" "defer.graphql" "directive.graphql" "embedded.graphql" "enum.graphql" "fields_order.graphql" "interfaces.graphql" "issue896.graphql" "loops.graphql" "maps.graphql" "mutation_with_custom_scalar.graphql" "nulls.graphql" "panics.graphql" "primitive_objects.graphql" "ptr_to_any.graphql" "ptr_to_ptr_input.graphql" "ptr_to_slice.graphql" "scalar_context.graphql" "scalar_default.graphql" "schema.graphql" "slices.graphql" "typefallback.graphql" "useptr.graphql" "v-ok.graphql" "validtypes.graphql" "variadic.graphql" "weird_type_cases.graphql" "wrapped_type.graphql" +var sourcesFS embed.FS + +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) +} + +var sources = []*ast.Source{ + {Name: "builtinscalar.graphql", Input: sourceData("builtinscalar.graphql"), BuiltIn: false}, + {Name: "complexity.graphql", Input: sourceData("complexity.graphql"), BuiltIn: false}, + {Name: "defaults.graphql", Input: sourceData("defaults.graphql"), BuiltIn: false}, + {Name: "defer.graphql", Input: sourceData("defer.graphql"), BuiltIn: false}, + {Name: "directive.graphql", Input: sourceData("directive.graphql"), BuiltIn: false}, + {Name: "embedded.graphql", Input: sourceData("embedded.graphql"), BuiltIn: false}, + {Name: "enum.graphql", Input: sourceData("enum.graphql"), BuiltIn: false}, + {Name: "fields_order.graphql", Input: sourceData("fields_order.graphql"), BuiltIn: false}, + {Name: "interfaces.graphql", Input: sourceData("interfaces.graphql"), BuiltIn: false}, + {Name: "issue896.graphql", Input: sourceData("issue896.graphql"), BuiltIn: false}, + {Name: "loops.graphql", Input: sourceData("loops.graphql"), BuiltIn: false}, + {Name: "maps.graphql", Input: sourceData("maps.graphql"), BuiltIn: false}, + {Name: "mutation_with_custom_scalar.graphql", Input: sourceData("mutation_with_custom_scalar.graphql"), BuiltIn: false}, + {Name: "nulls.graphql", Input: sourceData("nulls.graphql"), BuiltIn: false}, + {Name: "panics.graphql", Input: sourceData("panics.graphql"), BuiltIn: false}, + {Name: "primitive_objects.graphql", Input: sourceData("primitive_objects.graphql"), BuiltIn: false}, + {Name: "ptr_to_any.graphql", Input: sourceData("ptr_to_any.graphql"), BuiltIn: false}, + {Name: "ptr_to_ptr_input.graphql", Input: sourceData("ptr_to_ptr_input.graphql"), BuiltIn: false}, + {Name: "ptr_to_slice.graphql", Input: sourceData("ptr_to_slice.graphql"), BuiltIn: false}, + {Name: "scalar_context.graphql", Input: sourceData("scalar_context.graphql"), BuiltIn: false}, + {Name: "scalar_default.graphql", Input: sourceData("scalar_default.graphql"), BuiltIn: false}, + {Name: "schema.graphql", Input: sourceData("schema.graphql"), BuiltIn: false}, + {Name: "slices.graphql", Input: sourceData("slices.graphql"), BuiltIn: false}, + {Name: "typefallback.graphql", Input: sourceData("typefallback.graphql"), BuiltIn: false}, + {Name: "useptr.graphql", Input: sourceData("useptr.graphql"), BuiltIn: false}, + {Name: "v-ok.graphql", Input: sourceData("v-ok.graphql"), BuiltIn: false}, + {Name: "validtypes.graphql", Input: sourceData("validtypes.graphql"), BuiltIn: false}, + {Name: "variadic.graphql", Input: sourceData("variadic.graphql"), BuiltIn: false}, + {Name: "weird_type_cases.graphql", Input: sourceData("weird_type_cases.graphql"), BuiltIn: false}, + {Name: "wrapped_type.graphql", Input: sourceData("wrapped_type.graphql"), 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 0000000..73f319b --- /dev/null +++ b/codegen/testserver/followschema/scalar_context.generated.go @@ -0,0 +1,83 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + + "github.com/niko0xdev/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, "the requested element is null which the schema does not allow") + } + } + return graphql.WrapContextMarshaler(ctx, res) +} + +func (ec *executionContext) unmarshalNStringFromContextInterface2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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 0000000..ca1f141 --- /dev/null +++ b/codegen/testserver/followschema/scalar_context.go @@ -0,0 +1,39 @@ +package followschema + +import ( + "context" + "io" + "strconv" + + "github.com/niko0xdev/gqlgen/graphql" +) + +type StringFromContextInterface struct { + OperationName string +} + +var ( + _ graphql.ContextMarshaler = StringFromContextInterface{} + _ 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 0000000..f49fa55 --- /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 0000000..7654163 --- /dev/null +++ b/codegen/testserver/followschema/scalar_context_test.go @@ -0,0 +1,52 @@ +package followschema + +import ( + "context" + "math" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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 0000000..ab3e181 --- /dev/null +++ b/codegen/testserver/followschema/scalar_default.generated.go @@ -0,0 +1,150 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "strconv" + "sync/atomic" + + "github.com/niko0xdev/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) { + fc, err := ec.fieldContext_EmbeddedDefaultScalar_value(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) +} + +func (ec *executionContext) fieldContext_EmbeddedDefaultScalar_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "EmbeddedDefaultScalar", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type DefaultScalarImplementation does not have child fields") + }, + } + return fc, nil +} + +// 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("EmbeddedDefaultScalar") + case "value": + out.Values[i] = ec._EmbeddedDefaultScalar_value(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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, "the requested element is null which the schema does not allow") + } + } + 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/followschema/scalar_default.graphql b/codegen/testserver/followschema/scalar_default.graphql new file mode 100644 index 0000000..5e3a9c0 --- /dev/null +++ b/codegen/testserver/followschema/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/followschema/scalar_default_test.go b/codegen/testserver/followschema/scalar_default_test.go new file mode 100644 index 0000000..0b5c7d4 --- /dev/null +++ b/codegen/testserver/followschema/scalar_default_test.go @@ -0,0 +1,33 @@ +package followschema + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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 0000000..d294407 --- /dev/null +++ b/codegen/testserver/followschema/schema.generated.go @@ -0,0 +1,8528 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "fmt" + "io" + "strconv" + "sync" + "sync/atomic" + "time" + + introspection1 "github.com/niko0xdev/gqlgen/codegen/testserver/followschema/introspection" + invalid_packagename "github.com/niko0xdev/gqlgen/codegen/testserver/followschema/invalid-packagename" + "github.com/niko0xdev/gqlgen/codegen/testserver/followschema/otherpkg" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/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 PetResolver interface { + Friends(ctx context.Context, obj *Pet, limit *int) ([]*Pet, 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) + InputOmittable(ctx context.Context, arg OmittableInput) (string, 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) + DeferCase1(ctx context.Context) (*DeferModel, error) + DeferCase2(ctx context.Context) ([]*DeferModel, 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) + Dog(ctx context.Context) (*Dog, 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) + Invalid(ctx context.Context) (string, error) + Panics(ctx context.Context) (*Panics, error) + PrimitiveObject(ctx context.Context) ([]Primitive, error) + PrimitiveStringObject(ctx context.Context) ([]PrimitiveString, error) + PtrToAnyContainer(ctx context.Context) (*PtrToAnyContainer, 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) + VariadicModel(ctx context.Context) (*VariadicModel, 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) + ErrorRequired(ctx context.Context) (<-chan *Error, error) +} +type UserResolver interface { + Friends(ctx context.Context, obj *User) ([]*User, error) + + Pets(ctx context.Context, obj *User, limit *int) ([]*Pet, error) +} + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (ec *executionContext) dir_defer_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["if"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("if")) + arg0, err = ec.unmarshalOBoolean2ᚖbool(ctx, tmp) + if err != nil { + return nil, err + } + } + args["if"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["label"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("label")) + arg1, err = ec.unmarshalOString2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["label"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Pet_friends_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["limit"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("limit")) + arg0, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["limit"] = arg0 + return args, nil +} + +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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/niko0xdev/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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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_inputOmittable_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 OmittableInput + if tmp, ok := rawArgs["arg"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("arg")) + arg0, err = ec.unmarshalNOmittableInput2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOmittableInput(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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 +} + +func (ec *executionContext) field_User_pets_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["limit"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("limit")) + arg0, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["limit"] = arg0 + 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) { + fc, err := ec.fieldContext_Autobind_int(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Autobind_int(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Autobind", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Autobind_int32(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Autobind_int32(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Autobind_int32(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Autobind", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Autobind_int64(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Autobind_int64(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Autobind_int64(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Autobind", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Autobind_idStr(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Autobind_idStr(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Autobind_idStr(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Autobind", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Autobind_idInt(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Autobind_idInt(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Autobind_idInt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Autobind", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _EmbeddedPointer_ID(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_EmbeddedPointer_ID(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_EmbeddedPointer_ID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "EmbeddedPointer", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _EmbeddedPointer_Title(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_EmbeddedPointer_Title(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_EmbeddedPointer_Title(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "EmbeddedPointer", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field graphql.CollectedField, obj *ForcedResolver) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ForcedResolver_field(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCircle(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ForcedResolver_field(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ForcedResolver", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "radius": + return ec.fieldContext_Circle_radius(ctx, field) + case "area": + return ec.fieldContext_Circle_area(ctx, field) + case "coordinates": + return ec.fieldContext_Circle_coordinates(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Circle", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.CollectedField, obj *InnerObject) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_InnerObject_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_InnerObject_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "InnerObject", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field graphql.CollectedField, obj *invalid_packagename.InvalidIdentifier) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_InvalidIdentifier_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_InvalidIdentifier_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "InvalidIdentifier", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedField, obj *introspection1.It) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_It_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_It_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "It", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ModelMethods_resolverField(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ModelMethods_resolverField(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ModelMethods_resolverField(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ModelMethods", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ModelMethods_noContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ModelMethods_noContext(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ModelMethods_noContext(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ModelMethods", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ModelMethods_withContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ModelMethods_withContext(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ModelMethods_withContext(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ModelMethods", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphql.CollectedField, obj *OuterObject) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_OuterObject_inner(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInnerObject(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_OuterObject_inner(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "OuterObject", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_InnerObject_id(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type InnerObject", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Pet_id(ctx context.Context, field graphql.CollectedField, obj *Pet) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Pet_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Pet_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Pet", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Pet_friends(ctx context.Context, field graphql.CollectedField, obj *Pet) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Pet_friends(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Pet().Friends(rctx, obj, fc.Args["limit"].(*int)) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*Pet) + fc.Result = res + return ec.marshalOPet2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPetᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Pet_friends(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Pet", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Pet_id(ctx, field) + case "friends": + return ec.fieldContext_Pet_friends(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Pet", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Pet_friends_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_invalidIdentifier(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_invalidIdentifier(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_InvalidIdentifier_id(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type InvalidIdentifier", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_collision(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_collision(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋintrospectionᚐIt(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_collision(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_It_id(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type It", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_mapInput(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_mapInput(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_mapInput_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_recursive(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_recursive(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_recursive_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_nestedInputs(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_nestedInputs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_nestedInputs_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_nestedOutputs(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterObject(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_nestedOutputs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "inner": + return ec.fieldContext_OuterObject_inner(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type OuterObject", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_modelMethods(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_modelMethods(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐModelMethods(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_modelMethods(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "resolverField": + return ec.fieldContext_ModelMethods_resolverField(ctx, field) + case "noContext": + return ec.fieldContext_ModelMethods_noContext(ctx, field) + case "withContext": + return ec.fieldContext_ModelMethods_withContext(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ModelMethods", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_user(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "friends": + return ec.fieldContext_User_friends(ctx, field) + case "created": + return ec.fieldContext_User_created(ctx, field) + case "updated": + return ec.fieldContext_User_updated(ctx, field) + case "pets": + return ec.fieldContext_User_pets(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_user_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_nullableArg(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_nullableArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_nullableArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_inputSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_inputSlice(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_inputSlice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_inputSlice_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_inputNullableSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_inputNullableSlice(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_inputNullableSlice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_inputNullableSlice_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_inputOmittable(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_inputOmittable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().InputOmittable(rctx, fc.Args["arg"].(OmittableInput)) + }) + + 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) fieldContext_Query_inputOmittable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_inputOmittable_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_shapeUnion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_shapeUnion(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShapeUnion(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_shapeUnion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ShapeUnion does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_autobind(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_autobind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐAutobind(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_autobind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "int": + return ec.fieldContext_Autobind_int(ctx, field) + case "int32": + return ec.fieldContext_Autobind_int32(ctx, field) + case "int64": + return ec.fieldContext_Autobind_int64(ctx, field) + case "idStr": + return ec.fieldContext_Autobind_idStr(ctx, field) + case "idInt": + return ec.fieldContext_Autobind_idInt(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Autobind", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_deprecatedField(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_deprecatedField(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Query_deprecatedField(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_overlapping(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_overlapping(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOverlappingFields(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_overlapping(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "oneFoo": + return ec.fieldContext_OverlappingFields_oneFoo(ctx, field) + case "twoFoo": + return ec.fieldContext_OverlappingFields_twoFoo(ctx, field) + case "oldFoo": + return ec.fieldContext_OverlappingFields_oldFoo(ctx, field) + case "newFoo": + return ec.fieldContext_OverlappingFields_newFoo(ctx, field) + case "new_foo": + return ec.fieldContext_OverlappingFields_new_foo(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type OverlappingFields", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_defaultParameters(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_defaultParameters(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.Args["falsyBoolean"].(*bool), fc.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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultParametersMirror(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_defaultParameters(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "falsyBoolean": + return ec.fieldContext_DefaultParametersMirror_falsyBoolean(ctx, field) + case "truthyBoolean": + return ec.fieldContext_DefaultParametersMirror_truthyBoolean(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type DefaultParametersMirror", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_defaultParameters_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_deferCase1(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_deferCase1(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().DeferCase1(rctx) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*DeferModel) + fc.Result = res + return ec.marshalODeferModel2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDeferModel(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_deferCase1(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_DeferModel_id(ctx, field) + case "name": + return ec.fieldContext_DeferModel_name(ctx, field) + case "values": + return ec.fieldContext_DeferModel_values(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type DeferModel", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_deferCase2(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_deferCase2(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().DeferCase2(rctx) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*DeferModel) + fc.Result = res + return ec.marshalODeferModel2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDeferModelᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_deferCase2(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_DeferModel_id(ctx, field) + case "name": + return ec.fieldContext_DeferModel_name(ctx, field) + case "values": + return ec.fieldContext_DeferModel_values(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type DeferModel", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_directiveArg(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_directiveArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_directiveArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_directiveNullableArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_directiveNullableArg(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.Args["arg"].(*int), fc.Args["arg2"].(*int), fc.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) fieldContext_Query_directiveNullableArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_directiveNullableArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_directiveInputNullable(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_directiveInputNullable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_directiveInputNullable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_directiveInputNullable_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_directiveInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_directiveInput(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_directiveInput(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_directiveInput_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_directiveInputType(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_directiveInputType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_directiveInputType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_directiveInputType_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_directiveObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_directiveObject(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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/niko0xdev/gqlgen/codegen/testserver/followschema.ObjectDirectives`, tmp) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*ObjectDirectives) + fc.Result = res + return ec.marshalOObjectDirectives2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐObjectDirectives(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_directiveObject(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "text": + return ec.fieldContext_ObjectDirectives_text(ctx, field) + case "nullableText": + return ec.fieldContext_ObjectDirectives_nullableText(ctx, field) + case "order": + return ec.fieldContext_ObjectDirectives_order(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ObjectDirectives", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_directiveObjectWithCustomGoModel(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_directiveObjectWithCustomGoModel(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐObjectDirectivesWithCustomGoModel(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_directiveObjectWithCustomGoModel(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "nullableText": + return ec.fieldContext_ObjectDirectivesWithCustomGoModel_nullableText(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ObjectDirectivesWithCustomGoModel", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_directiveFieldDef(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_directiveFieldDef(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_directiveFieldDef(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_directiveFieldDef_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_directiveField(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_directiveField(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Query_directiveField(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_directiveDouble(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_directiveDouble(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Query_directiveDouble(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_directiveUnimplemented(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_directiveUnimplemented(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Query_directiveUnimplemented(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_embeddedCase1(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_embeddedCase1(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEmbeddedCase1(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_embeddedCase1(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "exportedEmbeddedPointerExportedMethod": + return ec.fieldContext_EmbeddedCase1_exportedEmbeddedPointerExportedMethod(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type EmbeddedCase1", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_embeddedCase2(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_embeddedCase2(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEmbeddedCase2(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_embeddedCase2(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "unexportedEmbeddedPointerExportedMethod": + return ec.fieldContext_EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type EmbeddedCase2", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_embeddedCase3(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_embeddedCase3(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEmbeddedCase3(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_embeddedCase3(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "unexportedEmbeddedInterfaceExportedMethod": + return ec.fieldContext_EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type EmbeddedCase3", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_enumInInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_enumInInput(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEnumTest(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_enumInInput(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type EnumTest does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_enumInInput_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_shapes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_shapes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_noShape(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_noShape(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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/niko0xdev/gqlgen/codegen/testserver/followschema.Shape`, tmp) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(Shape) + fc.Result = res + return ec.marshalOShape2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_noShape(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNode(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_noShapeTypedNil(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_noShapeTypedNil(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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/niko0xdev/gqlgen/codegen/testserver/followschema.Shape`, tmp) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(Shape) + fc.Result = res + return ec.marshalOShape2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_noShapeTypedNil(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_animal(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_animal(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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/niko0xdev/gqlgen/codegen/testserver/followschema.Animal`, tmp) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(Animal) + fc.Result = res + return ec.marshalOAnimal2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐAnimal(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_animal(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_notAnInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_notAnInterface(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐBackedByInterface(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_notAnInterface(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_BackedByInterface_id(ctx, field) + case "thisShouldBind": + return ec.fieldContext_BackedByInterface_thisShouldBind(ctx, field) + case "thisShouldBindWithError": + return ec.fieldContext_BackedByInterface_thisShouldBindWithError(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type BackedByInterface", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_dog(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_dog(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Dog(rctx) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Dog) + fc.Result = res + return ec.marshalODog2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDog(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_dog(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "species": + return ec.fieldContext_Dog_species(ctx, field) + case "size": + return ec.fieldContext_Dog_size(ctx, field) + case "dogBreed": + return ec.fieldContext_Dog_dogBreed(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Dog", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_issue896a(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_issue896a(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCheckIssue896ᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_issue896a(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_CheckIssue896_id(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CheckIssue896", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_mapStringInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_mapStringInterface(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_mapStringInterface(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "a": + return ec.fieldContext_MapStringInterfaceType_a(ctx, field) + case "b": + return ec.fieldContext_MapStringInterfaceType_b(ctx, field) + case "c": + return ec.fieldContext_MapStringInterfaceType_c(ctx, field) + case "nested": + return ec.fieldContext_MapStringInterfaceType_nested(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type MapStringInterfaceType", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_mapStringInterface_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_mapNestedStringInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_mapNestedStringInterface(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_mapNestedStringInterface(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "a": + return ec.fieldContext_MapStringInterfaceType_a(ctx, field) + case "b": + return ec.fieldContext_MapStringInterfaceType_b(ctx, field) + case "c": + return ec.fieldContext_MapStringInterfaceType_c(ctx, field) + case "nested": + return ec.fieldContext_MapStringInterfaceType_nested(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type MapStringInterfaceType", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_mapNestedStringInterface_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_errorBubble(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_errorBubble(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Error_id(ctx, field) + case "errorOnNonRequiredField": + return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) + case "errorOnRequiredField": + return ec.fieldContext_Error_errorOnRequiredField(ctx, field) + case "nilOnRequiredField": + return ec.fieldContext_Error_nilOnRequiredField(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_errorBubbleList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_errorBubbleList(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐErrorᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_errorBubbleList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Error_id(ctx, field) + case "errorOnNonRequiredField": + return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) + case "errorOnRequiredField": + return ec.fieldContext_Error_errorOnRequiredField(ctx, field) + case "nilOnRequiredField": + return ec.fieldContext_Error_nilOnRequiredField(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_errorList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_errorList(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_errorList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Error_id(ctx, field) + case "errorOnNonRequiredField": + return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) + case "errorOnRequiredField": + return ec.fieldContext_Error_errorOnRequiredField(ctx, field) + case "nilOnRequiredField": + return ec.fieldContext_Error_nilOnRequiredField(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_errors(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_errors(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐErrors(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_errors(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "a": + return ec.fieldContext_Errors_a(ctx, field) + case "b": + return ec.fieldContext_Errors_b(ctx, field) + case "c": + return ec.fieldContext_Errors_c(ctx, field) + case "d": + return ec.fieldContext_Errors_d(ctx, field) + case "e": + return ec.fieldContext_Errors_e(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Errors", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_valid(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Query_valid(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_invalid(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_invalid(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Invalid(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) fieldContext_Query_invalid(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_panics(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_panics(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPanics(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_panics(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "fieldScalarMarshal": + return ec.fieldContext_Panics_fieldScalarMarshal(ctx, field) + case "fieldFuncMarshal": + return ec.fieldContext_Panics_fieldFuncMarshal(ctx, field) + case "argUnmarshal": + return ec.fieldContext_Panics_argUnmarshal(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Panics", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_primitiveObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_primitiveObject(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPrimitiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_primitiveObject(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "value": + return ec.fieldContext_Primitive_value(ctx, field) + case "squared": + return ec.fieldContext_Primitive_squared(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Primitive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_primitiveStringObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_primitiveStringObject(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPrimitiveStringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_primitiveStringObject(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "value": + return ec.fieldContext_PrimitiveString_value(ctx, field) + case "doubled": + return ec.fieldContext_PrimitiveString_doubled(ctx, field) + case "len": + return ec.fieldContext_PrimitiveString_len(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PrimitiveString", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_ptrToAnyContainer(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_ptrToAnyContainer(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().PtrToAnyContainer(rctx) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*PtrToAnyContainer) + fc.Result = res + return ec.marshalNPtrToAnyContainer2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToAnyContainer(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_ptrToAnyContainer(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "ptrToAny": + return ec.fieldContext_PtrToAnyContainer_ptrToAny(ctx, field) + case "binding": + return ec.fieldContext_PtrToAnyContainer_binding(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PtrToAnyContainer", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_ptrToSliceContainer(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_ptrToSliceContainer(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToSliceContainer(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_ptrToSliceContainer(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "ptrToSlice": + return ec.fieldContext_PtrToSliceContainer_ptrToSlice(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PtrToSliceContainer", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_infinity(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_infinity(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Query_infinity(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_stringFromContextInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_stringFromContextInterface(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐStringFromContextInterface(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_stringFromContextInterface(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type StringFromContextInterface does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_stringFromContextFunction(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_stringFromContextFunction(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Query_stringFromContextFunction(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type StringFromContextFunction does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_defaultScalar(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_defaultScalar(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_defaultScalar(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type DefaultScalarImplementation does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_defaultScalar_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_slices(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_slices(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSlices(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_slices(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "test1": + return ec.fieldContext_Slices_test1(ctx, field) + case "test2": + return ec.fieldContext_Slices_test2(ctx, field) + case "test3": + return ec.fieldContext_Slices_test3(ctx, field) + case "test4": + return ec.fieldContext_Slices_test4(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Slices", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_scalarSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_scalarSlice(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Query_scalarSlice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Bytes does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_fallback(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_fallback(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFallbackToStringEncoding(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_fallback(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type FallbackToStringEncoding does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_fallback_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_optionalUnion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_optionalUnion(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐTestUnion(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_optionalUnion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type TestUnion does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_vOkCaseValue(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_vOkCaseValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐVOkCaseValue(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_vOkCaseValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "value": + return ec.fieldContext_VOkCaseValue_value(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type VOkCaseValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_vOkCaseNil(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_vOkCaseNil(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐVOkCaseNil(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_vOkCaseNil(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "value": + return ec.fieldContext_VOkCaseNil_value(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type VOkCaseNil", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_validType(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_validType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐValidType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_validType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "differentCase": + return ec.fieldContext_ValidType_differentCase(ctx, field) + case "different_case": + return ec.fieldContext_ValidType_different_case(ctx, field) + case "validInputKeywords": + return ec.fieldContext_ValidType_validInputKeywords(ctx, field) + case "validArgs": + return ec.fieldContext_ValidType_validArgs(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ValidType", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_variadicModel(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_variadicModel(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().VariadicModel(rctx) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*VariadicModel) + fc.Result = res + return ec.marshalOVariadicModel2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐVariadicModel(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_variadicModel(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "value": + return ec.fieldContext_VariadicModel_value(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type VariadicModel", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_wrappedStruct(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_wrappedStruct(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐWrappedStruct(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_wrappedStruct(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_WrappedStruct_name(ctx, field) + case "desc": + return ec.fieldContext_WrappedStruct_desc(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type WrappedStruct", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_wrappedScalar(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_wrappedScalar(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋotherpkgᚐScalar(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_wrappedScalar(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type WrappedScalar does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_wrappedMap(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_wrappedMap(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐWrappedMap(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_wrappedMap(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "get": + return ec.fieldContext_WrappedMap_get(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type WrappedMap", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_wrappedSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_wrappedSlice(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐWrappedSlice(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_wrappedSlice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "get": + return ec.fieldContext_WrappedSlice_get(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type WrappedSlice", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Subscription_updated(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { + fc, err := ec.fieldContext_Subscription_updated(ctx, field) + if err != nil { + return nil + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + 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(ctx context.Context) graphql.Marshaler { + select { + case 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{'}'}) + }) + case <-ctx.Done(): + return nil + } + } +} + +func (ec *executionContext) fieldContext_Subscription_updated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Subscription", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Subscription_initPayload(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { + fc, err := ec.fieldContext_Subscription_initPayload(ctx, field) + if err != nil { + return nil + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + 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(ctx context.Context) graphql.Marshaler { + select { + case 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{'}'}) + }) + case <-ctx.Done(): + return nil + } + } +} + +func (ec *executionContext) fieldContext_Subscription_initPayload(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Subscription", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Subscription_directiveArg(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { + fc, err := ec.fieldContext_Subscription_directiveArg(ctx, field) + if err != nil { + return nil + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + 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, fc.Args["arg"].(string)) + }) + + if resTmp == nil { + return nil + } + return func(ctx context.Context) graphql.Marshaler { + select { + case 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{'}'}) + }) + case <-ctx.Done(): + return nil + } + } +} + +func (ec *executionContext) fieldContext_Subscription_directiveArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Subscription", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Subscription_directiveArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Subscription_directiveNullableArg(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { + fc, err := ec.fieldContext_Subscription_directiveNullableArg(ctx, field) + if err != nil { + return nil + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + 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, fc.Args["arg"].(*int), fc.Args["arg2"].(*int), fc.Args["arg3"].(*string)) + }) + + if resTmp == nil { + return nil + } + return func(ctx context.Context) graphql.Marshaler { + select { + case 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{'}'}) + }) + case <-ctx.Done(): + return nil + } + } +} + +func (ec *executionContext) fieldContext_Subscription_directiveNullableArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Subscription", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Subscription_directiveNullableArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Subscription_directiveDouble(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { + fc, err := ec.fieldContext_Subscription_directiveDouble(ctx, field) + if err != nil { + return nil + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + 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(ctx context.Context) graphql.Marshaler { + select { + case 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{'}'}) + }) + case <-ctx.Done(): + return nil + } + } +} + +func (ec *executionContext) fieldContext_Subscription_directiveDouble(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Subscription", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Subscription_directiveUnimplemented(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { + fc, err := ec.fieldContext_Subscription_directiveUnimplemented(ctx, field) + if err != nil { + return nil + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + 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(ctx context.Context) graphql.Marshaler { + select { + case 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{'}'}) + }) + case <-ctx.Done(): + return nil + } + } +} + +func (ec *executionContext) fieldContext_Subscription_directiveUnimplemented(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Subscription", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Subscription_issue896b(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { + fc, err := ec.fieldContext_Subscription_issue896b(ctx, field) + if err != nil { + return nil + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + 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(ctx context.Context) graphql.Marshaler { + select { + case 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCheckIssue896(ctx, field.Selections, res).MarshalGQL(w) + w.Write([]byte{'}'}) + }) + case <-ctx.Done(): + return nil + } + } +} + +func (ec *executionContext) fieldContext_Subscription_issue896b(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Subscription", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_CheckIssue896_id(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CheckIssue896", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Subscription_errorRequired(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { + fc, err := ec.fieldContext_Subscription_errorRequired(ctx, field) + if err != nil { + return nil + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Subscription().ErrorRequired(rctx) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return nil + } + return func(ctx context.Context) graphql.Marshaler { + select { + case res, ok := <-resTmp.(<-chan *Error): + if !ok { + return nil + } + return graphql.WriterFunc(func(w io.Writer) { + w.Write([]byte{'{'}) + graphql.MarshalString(field.Alias).MarshalGQL(w) + w.Write([]byte{':'}) + ec.marshalNError2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, field.Selections, res).MarshalGQL(w) + w.Write([]byte{'}'}) + }) + case <-ctx.Done(): + return nil + } + } +} + +func (ec *executionContext) fieldContext_Subscription_errorRequired(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Subscription", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Error_id(ctx, field) + case "errorOnNonRequiredField": + return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) + case "errorOnRequiredField": + return ec.fieldContext_Error_errorOnRequiredField(ctx, field) + case "nilOnRequiredField": + return ec.fieldContext_Error_nilOnRequiredField(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_User_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_friends(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_friends(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUserᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_friends(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "friends": + return ec.fieldContext_User_friends(ctx, field) + case "created": + return ec.fieldContext_User_created(ctx, field) + case "updated": + return ec.fieldContext_User_updated(ctx, field) + case "pets": + return ec.fieldContext_User_pets(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _User_created(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_created(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_User_created(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_updated(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_updated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) +} + +func (ec *executionContext) fieldContext_User_updated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_pets(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_pets(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.User().Pets(rctx, obj, fc.Args["limit"].(*int)) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*Pet) + fc.Result = res + return ec.marshalOPet2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPetᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_pets(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Pet_id(ctx, field) + case "friends": + return ec.fieldContext_Pet_friends(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Pet", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_User_pets_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputChanges(ctx context.Context, obj interface{}) (map[string]interface{}, error) { + it := make(map[string]interface{}, len(obj.(map[string]interface{}))) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"a", "b"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "a": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("a")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it["a"] = data + case "b": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("b")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it["b"] = data + } + } + + return it, nil +} + +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 + } + + fieldsInOrder := [...]string{"id"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalNInt2int(ctx, v) + if err != nil { + return it, err + } + it.ID = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputOmittableInput(ctx context.Context, obj interface{}) (OmittableInput, error) { + var it OmittableInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"id", "bool", "str", "int", "time", "enum", "scalar", "object"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ID = graphql.OmittableOf(data) + case "bool": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("bool")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.Bool = graphql.OmittableOf(data) + case "str": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("str")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Str = graphql.OmittableOf(data) + case "int": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("int")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.Int = graphql.OmittableOf(data) + case "time": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("time")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.Time = graphql.OmittableOf(data) + case "enum": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("enum")) + data, err := ec.unmarshalOStatus2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐStatus(ctx, v) + if err != nil { + return it, err + } + it.Enum = graphql.OmittableOf(data) + case "scalar": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("scalar")) + data, err := ec.unmarshalOThirdParty2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐThirdParty(ctx, v) + if err != nil { + return it, err + } + it.Scalar = graphql.OmittableOf(data) + case "object": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("object")) + data, err := ec.unmarshalOOuterInput2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterInput(ctx, v) + if err != nil { + return it, err + } + it.Object = graphql.OmittableOf(data) + } + } + + 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 + } + + fieldsInOrder := [...]string{"inner"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "inner": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inner")) + data, err := ec.unmarshalNInnerInput2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInnerInput(ctx, v) + if err != nil { + return it, err + } + it.Inner = data + } + } + + 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 + } + + fieldsInOrder := [...]string{"self"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "self": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("self")) + data, err := ec.unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐRecursiveInputSliceᚄ(ctx, v) + if err != nil { + return it, err + } + it.Self = data + } + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Autobind") + case "int": + out.Values[i] = ec._Autobind_int(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "int32": + out.Values[i] = ec._Autobind_int32(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "int64": + out.Values[i] = ec._Autobind_int64(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "idStr": + out.Values[i] = ec._Autobind_idStr(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "idInt": + out.Values[i] = ec._Autobind_idInt(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("EmbeddedPointer") + case "ID": + out.Values[i] = ec._EmbeddedPointer_ID(ctx, field, obj) + case "Title": + out.Values[i] = ec._EmbeddedPointer_Title(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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, fs *graphql.FieldSet) (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 + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("InnerObject") + case "id": + out.Values[i] = ec._InnerObject_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("InvalidIdentifier") + case "id": + out.Values[i] = ec._InvalidIdentifier_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("It") + case "id": + out.Values[i] = ec._It_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "noContext": + out.Values[i] = ec._ModelMethods_noContext(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "withContext": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("OuterObject") + case "inner": + out.Values[i] = ec._OuterObject_inner(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var petImplementors = []string{"Pet"} + +func (ec *executionContext) _Pet(ctx context.Context, sel ast.SelectionSet, obj *Pet) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, petImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Pet") + case "id": + out.Values[i] = ec._Pet_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "friends": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Pet_friends(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "collision": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "mapInput": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "recursive": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "nestedInputs": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "nestedOutputs": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "modelMethods": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "user": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "nullableArg": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "inputSlice": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "inputNullableSlice": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "inputOmittable": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_inputOmittable(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "shapeUnion": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "autobind": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "deprecatedField": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "overlapping": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "defaultParameters": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "deferCase1": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_deferCase1(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "deferCase2": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_deferCase2(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "directiveArg": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "directiveNullableArg": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "directiveInputNullable": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "directiveInput": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "directiveInputType": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "directiveObject": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "directiveObjectWithCustomGoModel": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "directiveFieldDef": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "directiveField": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "directiveDouble": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "directiveUnimplemented": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "embeddedCase1": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "embeddedCase2": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "embeddedCase3": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "enumInInput": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "shapes": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "noShape": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "node": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "noShapeTypedNil": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "animal": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "notAnInterface": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "dog": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_dog(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "issue896a": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "mapStringInterface": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "mapNestedStringInterface": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "errorBubble": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "errorBubbleList": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "errorList": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "errors": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "valid": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "invalid": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_invalid(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "panics": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "primitiveObject": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "primitiveStringObject": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "ptrToAnyContainer": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_ptrToAnyContainer(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "ptrToSliceContainer": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "infinity": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "stringFromContextInterface": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "stringFromContextFunction": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "defaultScalar": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "slices": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "scalarSlice": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "fallback": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "optionalUnion": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "vOkCaseValue": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "vOkCaseNil": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "validType": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "variadicModel": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_variadicModel(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "wrappedStruct": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "wrappedScalar": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "wrappedMap": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "wrappedSlice": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var subscriptionImplementors = []string{"Subscription"} + +func (ec *executionContext) _Subscription(ctx context.Context, sel ast.SelectionSet) func(ctx context.Context) 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]) + case "errorRequired": + return ec._Subscription_errorRequired(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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("User") + case "id": + out.Values[i] = ec._User_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "friends": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "created": + out.Values[i] = ec._User_created(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "updated": + out.Values[i] = ec._User_updated(ctx, field, obj) + case "pets": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._User_pets(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) unmarshalNInnerInput2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._InnerObject(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNOmittableInput2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOmittableInput(ctx context.Context, v interface{}) (OmittableInput, error) { + res, err := ec.unmarshalInputOmittableInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNPet2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPet(ctx context.Context, sel ast.SelectionSet, v *Pet) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Pet(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNRecursiveInputSlice2githubᚗcomᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNUser2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._User(ctx, sel, v) +} + +func (ec *executionContext) marshalOAutobind2ᚖgithubᚗcomᚋniko0xdevᚋ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 + } + res, err := ec.unmarshalInputChanges(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOInvalidIdentifier2ᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterInput(ctx context.Context, v interface{}) ([][]*OuterInput, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOOuterInput2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterInput(ctx context.Context, v interface{}) ([]*OuterInput, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOOuterInput2ᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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) marshalOPet2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPetᚄ(ctx context.Context, sel ast.SelectionSet, v []*Pet) 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.marshalNPet2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPet(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) unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐRecursiveInputSliceᚄ(ctx context.Context, v interface{}) ([]RecursiveInputSlice, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐRecursiveInputSlice(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalORecursiveInputSlice2ᚖgithubᚗcomᚋniko0xdevᚋ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) unmarshalOStatus2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐStatus(ctx context.Context, v interface{}) (*Status, error) { + if v == nil { + return nil, nil + } + var res = new(Status) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOStatus2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐStatus(ctx context.Context, sel ast.SelectionSet, v *Status) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalOThirdParty2ᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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 0000000..fcbd29f --- /dev/null +++ b/codegen/testserver/followschema/schema.graphql @@ -0,0 +1,128 @@ +directive @goModel( + model: String + models: [String!] +) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION +directive @goField( + forceResolver: Boolean + name: String + omittable: Boolean +) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION +directive @defer( + if: Boolean = true + label: String +) on FRAGMENT_SPREAD | INLINE_FRAGMENT + +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! + inputOmittable(arg: OmittableInput!): String! + shapeUnion: ShapeUnion! + autobind: Autobind + deprecatedField: String! @deprecated(reason: "test deprecated directive") +} + +type Subscription { + updated: String! + initPayload: String! +} + +type Pet { + id: Int! + friends(limit: Int): [Pet!] @goField(forceResolver: true) +} + +type User { + id: Int! + friends: [User!]! @goField(forceResolver: true) + created: Time! + updated: Time + pets(limit: Int): [Pet!] @goField(forceResolver: true) +} + +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! +} + +input OmittableInput { + id: ID @goField(omittable: true) + bool: Boolean @goField(omittable: true) + str: String @goField(omittable: true) + int: Int @goField(omittable: true) + time: Time @goField(omittable: true) + enum: Status @goField(omittable: true) + scalar: ThirdParty @goField(omittable: true) + object: OuterInput @goField(omittable: true) +} + +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 0000000..ffc8a3d --- /dev/null +++ b/codegen/testserver/followschema/slices.generated.go @@ -0,0 +1,279 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "strconv" + "sync/atomic" + + "github.com/niko0xdev/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) { + fc, err := ec.fieldContext_Slices_test1(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Slices_test1(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Slices", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Slices_test2(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Slices_test2(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Slices_test2(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Slices", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Slices_test3(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Slices_test3(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Slices_test3(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Slices", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Slices_test4(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Slices_test4(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) +} + +func (ec *executionContext) fieldContext_Slices_test4(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Slices", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Slices") + case "test1": + out.Values[i] = ec._Slices_test1(ctx, field, obj) + case "test2": + out.Values[i] = ec._Slices_test2(ctx, field, obj) + case "test3": + out.Values[i] = ec._Slices_test3(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "test4": + out.Values[i] = ec._Slices_test4(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + res := MarshalBytes(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalOSlices2ᚖgithubᚗcomᚋniko0xdevᚋ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/followschema/slices.graphql b/codegen/testserver/followschema/slices.graphql new file mode 100644 index 0000000..b1265c5 --- /dev/null +++ b/codegen/testserver/followschema/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/followschema/slices_test.go b/codegen/testserver/followschema/slices_test.go new file mode 100644 index 0000000..914ced4 --- /dev/null +++ b/codegen/testserver/followschema/slices_test.go @@ -0,0 +1,44 @@ +package followschema + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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 0000000..4bb6044 --- /dev/null +++ b/codegen/testserver/followschema/stub.go @@ -0,0 +1,569 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + + introspection1 "github.com/niko0xdev/gqlgen/codegen/testserver/followschema/introspection" + invalid_packagename "github.com/niko0xdev/gqlgen/codegen/testserver/followschema/invalid-packagename" + "github.com/niko0xdev/gqlgen/codegen/testserver/followschema/otherpkg" +) + +type Stub struct { + BackedByInterfaceResolver struct { + ID func(ctx context.Context, obj BackedByInterface) (string, error) + } + DeferModelResolver struct { + Values func(ctx context.Context, obj *DeferModel) ([]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) + OverrideValueViaInput func(ctx context.Context, input FieldsOrderInput) (*FieldsOrderPayload, 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) + } + PetResolver struct { + Friends func(ctx context.Context, obj *Pet, limit *int) ([]*Pet, 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) + InputOmittable func(ctx context.Context, arg OmittableInput) (string, 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) + DeferCase1 func(ctx context.Context) (*DeferModel, error) + DeferCase2 func(ctx context.Context) ([]*DeferModel, 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) + Dog func(ctx context.Context) (*Dog, 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) + Invalid 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) + PtrToAnyContainer func(ctx context.Context) (*PtrToAnyContainer, 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) + VariadicModel func(ctx context.Context) (*VariadicModel, 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) + ErrorRequired func(ctx context.Context) (<-chan *Error, error) + } + UserResolver struct { + Friends func(ctx context.Context, obj *User) ([]*User, error) + Pets func(ctx context.Context, obj *User, limit *int) ([]*Pet, 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) + } + + FieldsOrderInputResolver struct { + OverrideFirstField func(ctx context.Context, obj *FieldsOrderInput, data *string) error + } +} + +func (r *Stub) BackedByInterface() BackedByInterfaceResolver { + return &stubBackedByInterface{r} +} +func (r *Stub) DeferModel() DeferModelResolver { + return &stubDeferModel{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) Pet() PetResolver { + return &stubPet{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} +} + +func (r *Stub) FieldsOrderInput() FieldsOrderInputResolver { + return &stubFieldsOrderInput{r} +} + +type stubBackedByInterface struct{ *Stub } + +func (r *stubBackedByInterface) ID(ctx context.Context, obj BackedByInterface) (string, error) { + return r.BackedByInterfaceResolver.ID(ctx, obj) +} + +type stubDeferModel struct{ *Stub } + +func (r *stubDeferModel) Values(ctx context.Context, obj *DeferModel) ([]string, error) { + return r.DeferModelResolver.Values(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) OverrideValueViaInput(ctx context.Context, input FieldsOrderInput) (*FieldsOrderPayload, error) { + return r.MutationResolver.OverrideValueViaInput(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 stubPet struct{ *Stub } + +func (r *stubPet) Friends(ctx context.Context, obj *Pet, limit *int) ([]*Pet, error) { + return r.PetResolver.Friends(ctx, obj, limit) +} + +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) InputOmittable(ctx context.Context, arg OmittableInput) (string, error) { + return r.QueryResolver.InputOmittable(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) DeferCase1(ctx context.Context) (*DeferModel, error) { + return r.QueryResolver.DeferCase1(ctx) +} +func (r *stubQuery) DeferCase2(ctx context.Context) ([]*DeferModel, error) { + return r.QueryResolver.DeferCase2(ctx) +} +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) Dog(ctx context.Context) (*Dog, error) { + return r.QueryResolver.Dog(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) Invalid(ctx context.Context) (string, error) { + return r.QueryResolver.Invalid(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) PtrToAnyContainer(ctx context.Context) (*PtrToAnyContainer, error) { + return r.QueryResolver.PtrToAnyContainer(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) VariadicModel(ctx context.Context) (*VariadicModel, error) { + return r.QueryResolver.VariadicModel(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) +} +func (r *stubSubscription) ErrorRequired(ctx context.Context) (<-chan *Error, error) { + return r.SubscriptionResolver.ErrorRequired(ctx) +} + +type stubUser struct{ *Stub } + +func (r *stubUser) Friends(ctx context.Context, obj *User) ([]*User, error) { + return r.UserResolver.Friends(ctx, obj) +} +func (r *stubUser) Pets(ctx context.Context, obj *User, limit *int) ([]*Pet, error) { + return r.UserResolver.Pets(ctx, obj, limit) +} + +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) +} + +type stubFieldsOrderInput struct{ *Stub } + +func (r *stubFieldsOrderInput) OverrideFirstField(ctx context.Context, obj *FieldsOrderInput, data *string) error { + return r.FieldsOrderInputResolver.OverrideFirstField(ctx, obj, data) +} diff --git a/codegen/testserver/followschema/subscription_test.go b/codegen/testserver/followschema/subscription_test.go new file mode 100644 index 0000000..a2da826 --- /dev/null +++ b/codegen/testserver/followschema/subscription_test.go @@ -0,0 +1,205 @@ +package followschema + +import ( + "context" + "fmt" + "runtime" + "sort" + "testing" + "time" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" +) + +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 + } + + errorTick := make(chan *Error, 1) + resolvers.SubscriptionResolver.ErrorRequired = func(ctx context.Context) (<-chan *Error, error) { + res := make(chan *Error, 1) + + go func() { + for { + select { + case t := <-errorTick: + res <- t + case <-ctx.Done(): + close(res) + return + } + } + }() + return res, 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) { + runtime.GC() // ensure no go-routines left from preceding tests + initialGoroutineCount := runtime.NumGoroutine() + + 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() + + // 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("websocket gets errors", func(t *testing.T) { + runtime.GC() // ensure no go-routines left from preceding tests + initialGoroutineCount := runtime.NumGoroutine() + + sub := c.Websocket(`subscription { errorRequired { id } }`) + + errorTick <- &Error{ID: "ID1234"} + + var msg struct { + resp struct { + ErrorRequired *struct { + Id string + } + } + } + + err := sub.Next(&msg.resp) + require.NoError(t, err) + require.Equal(t, "ID1234", msg.resp.ErrorRequired.Id) + + errorTick <- nil + err = sub.Next(&msg.resp) + require.Error(t, err) + + 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()) + }) +} diff --git a/codegen/testserver/followschema/thirdparty.go b/codegen/testserver/followschema/thirdparty.go new file mode 100644 index 0000000..1424a1e --- /dev/null +++ b/codegen/testserver/followschema/thirdparty.go @@ -0,0 +1,31 @@ +package followschema + +import ( + "fmt" + "io" + "strconv" + + "github.com/niko0xdev/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 0000000..1ef639d --- /dev/null +++ b/codegen/testserver/followschema/time_test.go @@ -0,0 +1,69 @@ +package followschema + +import ( + "context" + "testing" + "time" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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":"the requested element is null which the schema does not allow","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 0000000..0cd0f03 --- /dev/null +++ b/codegen/testserver/followschema/typefallback.generated.go @@ -0,0 +1,58 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + + "github.com/niko0xdev/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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +// endregion ***************************** type.gotpl ***************************** diff --git a/codegen/testserver/followschema/typefallback.graphql b/codegen/testserver/followschema/typefallback.graphql new file mode 100644 index 0000000..e1ff1a5 --- /dev/null +++ b/codegen/testserver/followschema/typefallback.graphql @@ -0,0 +1,9 @@ +extend type Query { + fallback(arg: FallbackToStringEncoding!): FallbackToStringEncoding! +} + +enum FallbackToStringEncoding { + A + B + C +} diff --git a/codegen/testserver/followschema/typefallback_test.go b/codegen/testserver/followschema/typefallback_test.go new file mode 100644 index 0000000..5e9a325 --- /dev/null +++ b/codegen/testserver/followschema/typefallback_test.go @@ -0,0 +1,29 @@ +package followschema + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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 0000000..807911f --- /dev/null +++ b/codegen/testserver/followschema/useptr.generated.go @@ -0,0 +1,236 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "fmt" + "strconv" + "sync/atomic" + + "github.com/niko0xdev/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) { + fc, err := ec.fieldContext_A_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_A_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "A", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _B_id(ctx context.Context, field graphql.CollectedField, obj *B) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_B_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_B_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "B", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +// 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("A") + case "id": + out.Values[i] = ec._A_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("B") + case "id": + out.Values[i] = ec._B_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) marshalOTestUnion2githubᚗcomᚋniko0xdevᚋ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/followschema/useptr.graphql b/codegen/testserver/followschema/useptr.graphql new file mode 100644 index 0000000..23c1af0 --- /dev/null +++ b/codegen/testserver/followschema/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/followschema/useptr_test.go b/codegen/testserver/followschema/useptr_test.go new file mode 100644 index 0000000..6fdf35c --- /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 0000000..d8ac136 --- /dev/null +++ b/codegen/testserver/followschema/v-ok.generated.go @@ -0,0 +1,215 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "strconv" + "sync/atomic" + + "github.com/niko0xdev/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) { + fc, err := ec.fieldContext_VOkCaseNil_value(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_VOkCaseNil_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VOkCaseNil", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _VOkCaseValue_value(ctx context.Context, field graphql.CollectedField, obj *VOkCaseValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VOkCaseValue_value(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_VOkCaseValue_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VOkCaseValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("VOkCaseNil") + case "value": + out.Values[i] = ec._VOkCaseNil_value(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("VOkCaseValue") + case "value": + out.Values[i] = ec._VOkCaseValue_value(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) marshalOVOkCaseNil2ᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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 0000000..7fac493 --- /dev/null +++ b/codegen/testserver/followschema/v-ok.go @@ -0,0 +1,15 @@ +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 0000000..9139cf8 --- /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 0000000..b8ed10c --- /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/niko0xdev/gqlgen/client" + "github.com/niko0xdev/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 0000000..c83827d --- /dev/null +++ b/codegen/testserver/followschema/validtypes.generated.go @@ -0,0 +1,929 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "fmt" + "strconv" + "sync/atomic" + + "github.com/niko0xdev/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ᚋniko0xdevᚋ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) { + fc, err := ec.fieldContext_Content_Post_foo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Content_Post_foo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Content_Post", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Content_User_foo(ctx context.Context, field graphql.CollectedField, obj *ContentUser) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Content_User_foo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Content_User_foo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Content_User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ValidType_differentCase(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ValidType_differentCase(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ValidType_differentCase(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ValidType", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ValidType_different_case(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ValidType_different_case(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ValidType_different_case(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ValidType", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ValidType_validInputKeywords(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ValidType_validInputKeywords(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ValidType_validInputKeywords(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ValidType", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_ValidType_validInputKeywords_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _ValidType_validArgs(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ValidType_validArgs(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) +} + +func (ec *executionContext) fieldContext_ValidType_validArgs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ValidType", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_ValidType_validArgs_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +// 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 + } + + fieldsInOrder := [...]string{"break", "default", "func", "interface", "select", "case", "defer", "go", "map", "struct", "chan", "else", "goto", "package", "switch", "const", "fallthrough", "if", "range", "type", "continue", "for", "import", "return", "var", "_"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "break": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("break")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Break = data + case "default": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("default")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Default = data + case "func": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("func")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Func = data + case "interface": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("interface")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Interface = data + case "select": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("select")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Select = data + case "case": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("case")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Case = data + case "defer": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("defer")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Defer = data + case "go": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("go")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Go = data + case "map": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("map")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Map = data + case "struct": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("struct")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Struct = data + case "chan": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chan")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Chan = data + case "else": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("else")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Else = data + case "goto": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("goto")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Goto = data + case "package": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("package")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Package = data + case "switch": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("switch")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Switch = data + case "const": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("const")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Const = data + case "fallthrough": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fallthrough")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Fallthrough = data + case "if": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("if")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.If = data + case "range": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("range")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Range = data + case "type": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("type")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Type = data + case "continue": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("continue")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Continue = data + case "for": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("for")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.For = data + case "import": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("import")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Import = data + case "return": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("return")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Return = data + case "var": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("var")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Var = data + case "_": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("_")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Underscore = data + } + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Content_Post") + case "foo": + out.Values[i] = ec._Content_Post_foo(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Content_User") + case "foo": + out.Values[i] = ec._Content_User_foo(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ValidType") + case "differentCase": + out.Values[i] = ec._ValidType_differentCase(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "different_case": + out.Values[i] = ec._ValidType_different_case(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "validInputKeywords": + out.Values[i] = ec._ValidType_validInputKeywords(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "validArgs": + out.Values[i] = ec._ValidType_validArgs(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) unmarshalOValidInput2ᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/followschema/validtypes.graphql b/codegen/testserver/followschema/validtypes.graphql new file mode 100644 index 0000000..f66a426 --- /dev/null +++ b/codegen/testserver/followschema/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/niko0xdev/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/followschema/validtypes_test.go b/codegen/testserver/followschema/validtypes_test.go new file mode 100644 index 0000000..3f72ded --- /dev/null +++ b/codegen/testserver/followschema/validtypes_test.go @@ -0,0 +1,37 @@ +package followschema + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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/variadic.generated.go b/codegen/testserver/followschema/variadic.generated.go new file mode 100644 index 0000000..f8fae29 --- /dev/null +++ b/codegen/testserver/followschema/variadic.generated.go @@ -0,0 +1,183 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "strconv" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (ec *executionContext) field_VariadicModel_value_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["rank"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("rank")) + arg0, err = ec.unmarshalNInt2int(ctx, tmp) + if err != nil { + return nil, err + } + } + args["rank"] = arg0 + return args, nil +} + +// endregion ***************************** args.gotpl ***************************** + +// region ************************** directives.gotpl ************************** + +// endregion ************************** directives.gotpl ************************** + +// region **************************** field.gotpl ***************************** + +func (ec *executionContext) _VariadicModel_value(ctx context.Context, field graphql.CollectedField, obj *VariadicModel) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VariadicModel_value(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Value(ctx, fc.Args["rank"].(int)) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalOString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VariadicModel_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VariadicModel", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_VariadicModel_value_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var variadicModelImplementors = []string{"VariadicModel"} + +func (ec *executionContext) _VariadicModel(ctx context.Context, sel ast.SelectionSet, obj *VariadicModel) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, variadicModelImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("VariadicModel") + case "value": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._VariadicModel_value(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) marshalOVariadicModel2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐVariadicModel(ctx context.Context, sel ast.SelectionSet, v *VariadicModel) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._VariadicModel(ctx, sel, v) +} + +// endregion ***************************** type.gotpl ***************************** diff --git a/codegen/testserver/followschema/variadic.go b/codegen/testserver/followschema/variadic.go new file mode 100644 index 0000000..218b0d6 --- /dev/null +++ b/codegen/testserver/followschema/variadic.go @@ -0,0 +1,14 @@ +package followschema + +import ( + "context" + "strconv" +) + +type VariadicModel struct{} + +type VariadicModelOption func(*VariadicModel) + +func (v VariadicModel) Value(ctx context.Context, rank int, opts ...VariadicModelOption) (string, error) { + return strconv.Itoa(rank), nil +} diff --git a/codegen/testserver/followschema/variadic.graphql b/codegen/testserver/followschema/variadic.graphql new file mode 100644 index 0000000..e58845d --- /dev/null +++ b/codegen/testserver/followschema/variadic.graphql @@ -0,0 +1,7 @@ +extend type Query { + variadicModel: VariadicModel +} + +type VariadicModel { + value(rank: Int!): String +} 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 0000000..b5def08 --- /dev/null +++ b/codegen/testserver/followschema/weird_type_cases.generated.go @@ -0,0 +1,525 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "strconv" + "sync/atomic" + + "github.com/niko0xdev/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) { + fc, err := ec.fieldContext_AIt_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_AIt_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "AIt", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _AbIt_id(ctx context.Context, field graphql.CollectedField, obj *AbIt) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_AbIt_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_AbIt_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "AbIt", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _XXIt_id(ctx context.Context, field graphql.CollectedField, obj *XXIt) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_XXIt_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_XXIt_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "XXIt", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _XxIt_id(ctx context.Context, field graphql.CollectedField, obj *XxIt) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_XxIt_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_XxIt_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "XxIt", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _asdfIt_id(ctx context.Context, field graphql.CollectedField, obj *AsdfIt) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_asdfIt_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_asdfIt_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "asdfIt", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _iIt_id(ctx context.Context, field graphql.CollectedField, obj *IIt) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_iIt_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_iIt_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "iIt", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +// 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("AIt") + case "id": + out.Values[i] = ec._AIt_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("AbIt") + case "id": + out.Values[i] = ec._AbIt_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("XXIt") + case "id": + out.Values[i] = ec._XXIt_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("XxIt") + case "id": + out.Values[i] = ec._XxIt_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("asdfIt") + case "id": + out.Values[i] = ec._asdfIt_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("iIt") + case "id": + out.Values[i] = ec._iIt_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +// endregion ***************************** type.gotpl ***************************** diff --git a/codegen/testserver/followschema/weird_type_cases.graphql b/codegen/testserver/followschema/weird_type_cases.graphql new file mode 100644 index 0000000..1e7eac1 --- /dev/null +++ b/codegen/testserver/followschema/weird_type_cases.graphql @@ -0,0 +1,8 @@ +# regression test for https://github.com/niko0xdev/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/followschema/wrapped_type.generated.go b/codegen/testserver/followschema/wrapped_type.generated.go new file mode 100644 index 0000000..3ef201d --- /dev/null +++ b/codegen/testserver/followschema/wrapped_type.generated.go @@ -0,0 +1,514 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package followschema + +import ( + "context" + "errors" + "strconv" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/codegen/testserver/followschema/otherpkg" + "github.com/niko0xdev/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) { + fc, err := ec.fieldContext_WrappedMap_get(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_WrappedMap_get(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "WrappedMap", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_WrappedMap_get_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _WrappedSlice_get(ctx context.Context, field graphql.CollectedField, obj WrappedSlice) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_WrappedSlice_get(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_WrappedSlice_get(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "WrappedSlice", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_WrappedSlice_get_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _WrappedStruct_name(ctx context.Context, field graphql.CollectedField, obj *WrappedStruct) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_WrappedStruct_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋotherpkgᚐScalar(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_WrappedStruct_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "WrappedStruct", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type WrappedScalar does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _WrappedStruct_desc(ctx context.Context, field graphql.CollectedField, obj *WrappedStruct) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_WrappedStruct_desc(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋotherpkgᚐScalar(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_WrappedStruct_desc(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "WrappedStruct", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type WrappedScalar does not have child fields") + }, + } + return fc, nil +} + +// 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) + deferred := make(map[string]*graphql.FieldSet) + 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, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("WrappedStruct") + case "name": + out.Values[i] = ec._WrappedStruct_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "desc": + out.Values[i] = ec._WrappedStruct_desc(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) marshalNWrappedMap2githubᚗcomᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._WrappedMap(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNWrappedScalar2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNWrappedSlice2githubᚗcomᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._WrappedSlice(ctx, sel, v) +} + +func (ec *executionContext) marshalNWrappedStruct2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._WrappedStruct(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOWrappedScalar2ᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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 0000000..2c06c34 --- /dev/null +++ b/codegen/testserver/followschema/wrapped_type.go @@ -0,0 +1,10 @@ +package followschema + +import "github.com/niko0xdev/gqlgen/codegen/testserver/followschema/otherpkg" + +type ( + WrappedScalar = otherpkg.Scalar + WrappedStruct otherpkg.Struct + WrappedMap otherpkg.Map + WrappedSlice otherpkg.Slice +) diff --git a/codegen/testserver/followschema/wrapped_type.graphql b/codegen/testserver/followschema/wrapped_type.graphql new file mode 100644 index 0000000..90b0c2e --- /dev/null +++ b/codegen/testserver/followschema/wrapped_type.graphql @@ -0,0 +1,13 @@ +# regression test for https://github.com/niko0xdev/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/followschema/wrapped_type_test.go b/codegen/testserver/followschema/wrapped_type_test.go new file mode 100644 index 0000000..a254df6 --- /dev/null +++ b/codegen/testserver/followschema/wrapped_type_test.go @@ -0,0 +1,99 @@ +package followschema + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/codegen/testserver/followschema/otherpkg" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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 new file mode 100644 index 0000000..bd5d369 --- /dev/null +++ b/codegen/testserver/generated_test.go @@ -0,0 +1,64 @@ +package testserver + +import ( + "fmt" + "go/ast" + "go/parser" + "go/token" + "os" + "path/filepath" + "strings" + "testing" + + eqgo "github.com/kevinmbeaulieu/eq-go/eq-go" + "github.com/stretchr/testify/require" +) + +func TestLayouts(t *testing.T) { + singlefileFSet := token.NewFileSet() + singlefilePkg := loadPackage("singlefile", singlefileFSet) + + followschemaFSet := token.NewFileSet() + followschemaPkg := loadPackage("followschema", followschemaFSet) + + 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 loadPackage(name string, fset *token.FileSet) *ast.Package { + path, err := filepath.Abs(name) + if err != nil { + panic(err) + } + files, err := os.ReadDir(path) + if err != nil { + panic(err) + } + + 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 + } + } + + return &pkg +} diff --git a/codegen/testserver/singlefile/builtinscalar.graphql b/codegen/testserver/singlefile/builtinscalar.graphql new file mode 100644 index 0000000..deb8a9f --- /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/singlefile/bytes.go b/codegen/testserver/singlefile/bytes.go new file mode 100644 index 0000000..b0e6991 --- /dev/null +++ b/codegen/testserver/singlefile/bytes.go @@ -0,0 +1,27 @@ +package singlefile + +import ( + "fmt" + "io" + + "github.com/niko0xdev/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/singlefile/complexity.graphql b/codegen/testserver/singlefile/complexity.graphql new file mode 100644 index 0000000..c6a1868 --- /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/singlefile/complexity_test.go b/codegen/testserver/singlefile/complexity_test.go new file mode 100644 index 0000000..659e262 --- /dev/null +++ b/codegen/testserver/singlefile/complexity_test.go @@ -0,0 +1,120 @@ +package singlefile + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/handler/extension" +) + +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/singlefile/defaults.graphql b/codegen/testserver/singlefile/defaults.graphql new file mode 100644 index 0000000..1c9a9eb --- /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 0000000..47be611 --- /dev/null +++ b/codegen/testserver/singlefile/defaults_test.go @@ -0,0 +1,69 @@ +package singlefile + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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/defer.graphql b/codegen/testserver/singlefile/defer.graphql new file mode 100644 index 0000000..c31e0de --- /dev/null +++ b/codegen/testserver/singlefile/defer.graphql @@ -0,0 +1,10 @@ +extend type Query { + deferCase1: DeferModel + deferCase2: [DeferModel!] +} + +type DeferModel { + id: ID! + name: String! + values: [String!]! @goField(forceResolver: true) +} diff --git a/codegen/testserver/singlefile/defer_test.go b/codegen/testserver/singlefile/defer_test.go new file mode 100644 index 0000000..e3ce2c7 --- /dev/null +++ b/codegen/testserver/singlefile/defer_test.go @@ -0,0 +1,285 @@ +package singlefile + +import ( + "context" + "encoding/json" + "math/rand" + "strconv" + "strings" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" +) + +func TestDefer(t *testing.T) { + resolvers := &Stub{} + + srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) + srv.AddTransport(transport.SSE{}) + + c := client.New(srv) + + resolvers.QueryResolver.DeferCase1 = func(ctx context.Context) (*DeferModel, error) { + return &DeferModel{ + ID: "1", + Name: "Defer test 1", + }, nil + } + + resolvers.QueryResolver.DeferCase2 = func(ctx context.Context) ([]*DeferModel, error) { + return []*DeferModel{ + { + ID: "1", + Name: "Defer test 1", + }, + { + ID: "2", + Name: "Defer test 2", + }, + { + ID: "3", + Name: "Defer test 3", + }, + }, nil + } + + resolvers.DeferModelResolver.Values = func(ctx context.Context, obj *DeferModel) ([]string, error) { + time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond) + return []string{ + "test defer 1", + "test defer 2", + "test defer 3", + }, nil + } + + t.Run("test deferCase1 using SSE", func(t *testing.T) { + sse := c.SSE(context.Background(), `query testDefer { + deferCase1 { + id + name + ... on DeferModel @defer(label: "values") { + values + } + } +}`) + + type response struct { + Data struct { + DeferCase1 struct { + Id string + Name string + Values []string + } + } + Label string `json:"label"` + Path []interface{} `json:"path"` + HasNext bool `json:"hasNext"` + Errors json.RawMessage `json:"errors"` + Extensions map[string]interface{} `json:"extensions"` + } + var resp response + + require.NoError(t, sse.Next(&resp)) + expectedInitialResponse := response{ + Data: struct { + DeferCase1 struct { + Id string + Name string + Values []string + } + }{ + DeferCase1: struct { + Id string + Name string + Values []string + }{ + Id: "1", + Name: "Defer test 1", + Values: nil, + }, + }, + HasNext: true, + } + assert.Equal(t, expectedInitialResponse, resp) + + type valuesResponse struct { + Data struct { + Values []string `json:"values"` + } + Label string `json:"label"` + Path []interface{} `json:"path"` + HasNext bool `json:"hasNext"` + Errors json.RawMessage `json:"errors"` + Extensions map[string]interface{} `json:"extensions"` + } + + var valueResp valuesResponse + expectedResponse := valuesResponse{ + Data: struct { + Values []string `json:"values"` + }{ + Values: []string{"test defer 1", "test defer 2", "test defer 3"}, + }, + Label: "values", + Path: []interface{}{"deferCase1"}, + } + + require.NoError(t, sse.Next(&valueResp)) + + assert.Equal(t, expectedResponse, valueResp) + + require.NoError(t, sse.Close()) + }) + + t.Run("test deferCase2 using SSE", func(t *testing.T) { + sse := c.SSE(context.Background(), `query testDefer { + deferCase2 { + id + name + ... on DeferModel @defer(label: "values") { + values + } + } +}`) + + type response struct { + Data struct { + DeferCase2 []struct { + Id string + Name string + Values []string + } + } + Label string `json:"label"` + Path []interface{} `json:"path"` + HasNext bool `json:"hasNext"` + Errors json.RawMessage `json:"errors"` + Extensions map[string]interface{} `json:"extensions"` + } + var resp response + + require.NoError(t, sse.Next(&resp)) + expectedInitialResponse := response{ + Data: struct { + DeferCase2 []struct { + Id string + Name string + Values []string + } + }{ + DeferCase2: []struct { + Id string + Name string + Values []string + }{ + { + Id: "1", + Name: "Defer test 1", + Values: nil, + }, + { + Id: "2", + Name: "Defer test 2", + Values: nil, + }, + { + Id: "3", + Name: "Defer test 3", + Values: nil, + }, + }, + }, + HasNext: true, + } + assert.Equal(t, expectedInitialResponse, resp) + + type valuesResponse struct { + Data struct { + Values []string `json:"values"` + } + Label string `json:"label"` + Path []interface{} `json:"path"` + HasNext bool `json:"hasNext"` + Errors json.RawMessage `json:"errors"` + Extensions map[string]interface{} `json:"extensions"` + } + + valuesByPath := make(map[string][]string, 2) + + for { + var valueResp valuesResponse + require.NoError(t, sse.Next(&valueResp)) + + var kb strings.Builder + for i, path := range valueResp.Path { + if i != 0 { + kb.WriteRune('.') + } + + switch pathValue := path.(type) { + case string: + kb.WriteString(pathValue) + case float64: + kb.WriteString(strconv.FormatFloat(pathValue, 'f', -1, 64)) + default: + t.Fatalf("unexpected path type: %T", pathValue) + } + } + + valuesByPath[kb.String()] = valueResp.Data.Values + if !valueResp.HasNext { + break + } + } + + assert.Equal(t, valuesByPath["deferCase2.0"], []string{"test defer 1", "test defer 2", "test defer 3"}) + assert.Equal(t, valuesByPath["deferCase2.1"], []string{"test defer 1", "test defer 2", "test defer 3"}) + assert.Equal(t, valuesByPath["deferCase2.2"], []string{"test defer 1", "test defer 2", "test defer 3"}) + + for i := range resp.Data.DeferCase2 { + resp.Data.DeferCase2[i].Values = valuesByPath["deferCase2."+strconv.FormatInt(int64(i), 10)] + } + + expectedDeferCase2Response := response{ + Data: struct { + DeferCase2 []struct { + Id string + Name string + Values []string + } + }{ + DeferCase2: []struct { + Id string + Name string + Values []string + }{ + { + Id: "1", + Name: "Defer test 1", + Values: []string{"test defer 1", "test defer 2", "test defer 3"}, + }, + { + Id: "2", + Name: "Defer test 2", + Values: []string{"test defer 1", "test defer 2", "test defer 3"}, + }, + { + Id: "3", + Name: "Defer test 3", + Values: []string{"test defer 1", "test defer 2", "test defer 3"}, + }, + }, + }, + HasNext: true, + } + assert.Equal(t, expectedDeferCase2Response, resp) + + require.NoError(t, sse.Close()) + }) +} diff --git a/codegen/testserver/singlefile/directive.graphql b/codegen/testserver/singlefile/directive.graphql new file mode 100644 index 0000000..8cf2470 --- /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/singlefile/directive_test.go b/codegen/testserver/singlefile/directive_test.go new file mode 100644 index 0000000..0adb255 --- /dev/null +++ b/codegen/testserver/singlefile/directive_test.go @@ -0,0 +1,469 @@ +package singlefile + +import ( + "context" + "fmt" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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.NoError(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.NoError(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.NoError(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.NoError(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.NoError(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.NoError(t, err) + require.NotNil(t, resp.DirectiveNullableArg) + 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.NoError(t, err) + require.NotNil(t, resp.DirectiveNullableArg) + 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.NoError(t, err) + require.NotNil(t, resp.DirectiveArg) + require.Equal(t, "Ok", *resp.DirectiveArg) + }) + }) + }) +} diff --git a/codegen/testserver/singlefile/embedded.go b/codegen/testserver/singlefile/embedded.go new file mode 100644 index 0000000..7620673 --- /dev/null +++ b/codegen/testserver/singlefile/embedded.go @@ -0,0 +1,43 @@ +package singlefile + +// 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/singlefile/embedded.graphql b/codegen/testserver/singlefile/embedded.graphql new file mode 100644 index 0000000..8445c05 --- /dev/null +++ b/codegen/testserver/singlefile/embedded.graphql @@ -0,0 +1,17 @@ +extend type Query { + embeddedCase1: EmbeddedCase1 + embeddedCase2: EmbeddedCase2 + embeddedCase3: EmbeddedCase3 +} + +type EmbeddedCase1 @goModel(model:"singlefile.EmbeddedCase1") { + exportedEmbeddedPointerExportedMethod: String! +} + +type EmbeddedCase2 @goModel(model:"singlefile.EmbeddedCase2") { + unexportedEmbeddedPointerExportedMethod: String! +} + +type EmbeddedCase3 @goModel(model:"singlefile.EmbeddedCase3") { + unexportedEmbeddedInterfaceExportedMethod: String! +} diff --git a/codegen/testserver/singlefile/embedded_test.go b/codegen/testserver/singlefile/embedded_test.go new file mode 100644 index 0000000..4e7003c --- /dev/null +++ b/codegen/testserver/singlefile/embedded_test.go @@ -0,0 +1,67 @@ +package singlefile + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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/singlefile/enum.graphql b/codegen/testserver/singlefile/enum.graphql new file mode 100644 index 0000000..08559b6 --- /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/singlefile/enums_test.go b/codegen/testserver/singlefile/enums_test.go new file mode 100644 index 0000000..9b37a3e --- /dev/null +++ b/codegen/testserver/singlefile/enums_test.go @@ -0,0 +1,53 @@ +package singlefile + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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":"Value \"INVALID\" does not exist in \"EnumTest!\" enum.","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/singlefile/fields_order.go b/codegen/testserver/singlefile/fields_order.go new file mode 100644 index 0000000..a43083b --- /dev/null +++ b/codegen/testserver/singlefile/fields_order.go @@ -0,0 +1,5 @@ +package singlefile + +type FieldsOrderInput struct { + FirstField *string `json:"firstField"` +} diff --git a/codegen/testserver/singlefile/fields_order.graphql b/codegen/testserver/singlefile/fields_order.graphql new file mode 100644 index 0000000..7be4328 --- /dev/null +++ b/codegen/testserver/singlefile/fields_order.graphql @@ -0,0 +1,12 @@ +type FieldsOrderPayload { + firstFieldValue: String +} + +input FieldsOrderInput { + firstField: String + overrideFirstField: String +} + +extend type Mutation { + overrideValueViaInput(input: FieldsOrderInput!): FieldsOrderPayload! +} diff --git a/codegen/testserver/singlefile/fields_order_test.go b/codegen/testserver/singlefile/fields_order_test.go new file mode 100644 index 0000000..2aa533c --- /dev/null +++ b/codegen/testserver/singlefile/fields_order_test.go @@ -0,0 +1,66 @@ +package singlefile + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +type FieldsOrderPayloadResults struct { + OverrideValueViaInput struct { + FirstFieldValue *string `json:"firstFieldValue"` + } `json:"overrideValueViaInput"` +} + +func TestFieldsOrder(t *testing.T) { + resolvers := &Stub{} + + c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))) + resolvers.FieldsOrderInputResolver.OverrideFirstField = func(ctx context.Context, in *FieldsOrderInput, data *string) error { + if data != nil { + in.FirstField = data + } + return nil + } + resolvers.MutationResolver.OverrideValueViaInput = func(ctx context.Context, in FieldsOrderInput) (ret *FieldsOrderPayload, err error) { + ret = &FieldsOrderPayload{ + FirstFieldValue: in.FirstField, + } + return + } + + t.Run("firstField", func(t *testing.T) { + var resp FieldsOrderPayloadResults + + err := c.Post(`mutation { + overrideValueViaInput(input: { firstField:"newName" }) { + firstFieldValue + } + }`, &resp) + require.NoError(t, err) + + require.NotNil(t, resp.OverrideValueViaInput.FirstFieldValue) + require.Equal(t, "newName", *resp.OverrideValueViaInput.FirstFieldValue) + }) + + t.Run("firstField/override", func(t *testing.T) { + var resp FieldsOrderPayloadResults + + err := c.Post(`mutation { overrideValueViaInput(input: { + firstField:"newName", + overrideFirstField: "override" + }) { + firstFieldValue + } + }`, &resp) + require.NoError(t, err) + + require.NotNil(t, resp.OverrideValueViaInput.FirstFieldValue) + require.NotEqual(t, "newName", *resp.OverrideValueViaInput.FirstFieldValue) + require.Equal(t, "override", *resp.OverrideValueViaInput.FirstFieldValue) + }) +} diff --git a/codegen/testserver/singlefile/generated.go b/codegen/testserver/singlefile/generated.go new file mode 100644 index 0000000..f7c68a9 --- /dev/null +++ b/codegen/testserver/singlefile/generated.go @@ -0,0 +1,23973 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package singlefile + +import ( + "bytes" + "context" + "embed" + "errors" + "fmt" + "io" + "strconv" + "sync" + "sync/atomic" + "time" + + introspection1 "github.com/niko0xdev/gqlgen/codegen/testserver/singlefile/introspection" + invalid_packagename "github.com/niko0xdev/gqlgen/codegen/testserver/singlefile/invalid-packagename" + "github.com/niko0xdev/gqlgen/codegen/testserver/singlefile/otherpkg" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + BackedByInterface() BackedByInterfaceResolver + DeferModel() DeferModelResolver + Errors() ErrorsResolver + ForcedResolver() ForcedResolverResolver + ModelMethods() ModelMethodsResolver + Mutation() MutationResolver + OverlappingFields() OverlappingFieldsResolver + Panics() PanicsResolver + Pet() PetResolver + Primitive() PrimitiveResolver + PrimitiveString() PrimitiveStringResolver + Query() QueryResolver + Subscription() SubscriptionResolver + User() UserResolver + WrappedMap() WrappedMapResolver + WrappedSlice() WrappedSliceResolver + FieldsOrderInput() FieldsOrderInputResolver +} + +type DirectiveRoot struct { + Custom func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + Defer func(ctx context.Context, obj interface{}, next graphql.Resolver, ifArg *bool, label *string) (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 + Size 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 + } + + DeferModel struct { + ID func(childComplexity int) int + Name func(childComplexity int) int + Values func(childComplexity int) int + } + + Dog struct { + DogBreed func(childComplexity int) int + Size 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 + } + + FieldsOrderPayload struct { + FirstFieldValue func(childComplexity int) int + } + + ForcedResolver struct { + Field func(childComplexity int) int + } + + Horse struct { + HorseBreed func(childComplexity int) int + Size func(childComplexity int) int + Species 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 + } + + MapNested struct { + Value func(childComplexity int) int + } + + MapStringInterfaceType struct { + A func(childComplexity int) int + B func(childComplexity int) int + C func(childComplexity int) int + Nested 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 + OverrideValueViaInput func(childComplexity int, input FieldsOrderInput) 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 + } + + Pet struct { + Friends func(childComplexity int, limit *int) int + ID 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 + } + + PtrToAnyContainer struct { + Binding func(childComplexity int) int + PtrToAny 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 + DeferCase1 func(childComplexity int) int + DeferCase2 func(childComplexity int) 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 + Dog 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 + InputOmittable func(childComplexity int, arg OmittableInput) int + InputSlice func(childComplexity int, arg []string) int + Invalid func(childComplexity int) 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 + PtrToAnyContainer 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 + VariadicModel 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 + } + + Size struct { + Height func(childComplexity int) int + Weight 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 + ErrorRequired 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 + Pets func(childComplexity int, limit *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 + } + + VariadicModel struct { + Value func(childComplexity int, rank int) 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 BackedByInterfaceResolver interface { + ID(ctx context.Context, obj BackedByInterface) (string, error) +} +type DeferModelResolver interface { + Values(ctx context.Context, obj *DeferModel) ([]string, error) +} +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) +} +type ForcedResolverResolver interface { + Field(ctx context.Context, obj *ForcedResolver) (*Circle, error) +} +type ModelMethodsResolver interface { + ResolverField(ctx context.Context, obj *ModelMethods) (bool, error) +} +type MutationResolver interface { + DefaultInput(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error) + OverrideValueViaInput(ctx context.Context, input FieldsOrderInput) (*FieldsOrderPayload, 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) +} +type PanicsResolver interface { + FieldScalarMarshal(ctx context.Context, obj *Panics) ([]MarshalPanic, error) + + ArgUnmarshal(ctx context.Context, obj *Panics, u []MarshalPanic) (bool, error) +} +type PetResolver interface { + Friends(ctx context.Context, obj *Pet, limit *int) ([]*Pet, error) +} +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) +} +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) + InputOmittable(ctx context.Context, arg OmittableInput) (string, 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) + DeferCase1(ctx context.Context) (*DeferModel, error) + DeferCase2(ctx context.Context) ([]*DeferModel, 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) + Dog(ctx context.Context) (*Dog, 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) + Invalid(ctx context.Context) (string, error) + Panics(ctx context.Context) (*Panics, error) + PrimitiveObject(ctx context.Context) ([]Primitive, error) + PrimitiveStringObject(ctx context.Context) ([]PrimitiveString, error) + PtrToAnyContainer(ctx context.Context) (*PtrToAnyContainer, 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) + VariadicModel(ctx context.Context) (*VariadicModel, 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) + ErrorRequired(ctx context.Context) (<-chan *Error, error) +} +type UserResolver interface { + Friends(ctx context.Context, obj *User) ([]*User, error) + + Pets(ctx context.Context, obj *User, limit *int) ([]*Pet, error) +} +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) +} + +type FieldsOrderInputResolver interface { + OverrideFirstField(ctx context.Context, obj *FieldsOrderInput, data *string) error +} + +type executableSchema struct { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = 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.size": + if e.complexity.Cat.Size == nil { + break + } + + return e.complexity.Cat.Size(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 "DeferModel.id": + if e.complexity.DeferModel.ID == nil { + break + } + + return e.complexity.DeferModel.ID(childComplexity), true + + case "DeferModel.name": + if e.complexity.DeferModel.Name == nil { + break + } + + return e.complexity.DeferModel.Name(childComplexity), true + + case "DeferModel.values": + if e.complexity.DeferModel.Values == nil { + break + } + + return e.complexity.DeferModel.Values(childComplexity), true + + case "Dog.dogBreed": + if e.complexity.Dog.DogBreed == nil { + break + } + + return e.complexity.Dog.DogBreed(childComplexity), true + + case "Dog.size": + if e.complexity.Dog.Size == nil { + break + } + + return e.complexity.Dog.Size(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 "FieldsOrderPayload.firstFieldValue": + if e.complexity.FieldsOrderPayload.FirstFieldValue == nil { + break + } + + return e.complexity.FieldsOrderPayload.FirstFieldValue(childComplexity), true + + case "ForcedResolver.field": + if e.complexity.ForcedResolver.Field == nil { + break + } + + return e.complexity.ForcedResolver.Field(childComplexity), true + + case "Horse.horseBreed": + if e.complexity.Horse.HorseBreed == nil { + break + } + + return e.complexity.Horse.HorseBreed(childComplexity), true + + case "Horse.size": + if e.complexity.Horse.Size == nil { + break + } + + return e.complexity.Horse.Size(childComplexity), true + + case "Horse.species": + if e.complexity.Horse.Species == nil { + break + } + + return e.complexity.Horse.Species(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 "MapNested.value": + if e.complexity.MapNested.Value == nil { + break + } + + return e.complexity.MapNested.Value(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 "MapStringInterfaceType.c": + if e.complexity.MapStringInterfaceType.C == nil { + break + } + + return e.complexity.MapStringInterfaceType.C(childComplexity), true + + case "MapStringInterfaceType.nested": + if e.complexity.MapStringInterfaceType.Nested == nil { + break + } + + return e.complexity.MapStringInterfaceType.Nested(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.overrideValueViaInput": + if e.complexity.Mutation.OverrideValueViaInput == nil { + break + } + + args, err := ec.field_Mutation_overrideValueViaInput_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.OverrideValueViaInput(childComplexity, args["input"].(FieldsOrderInput)), 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 "Pet.friends": + if e.complexity.Pet.Friends == nil { + break + } + + args, err := ec.field_Pet_friends_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Pet.Friends(childComplexity, args["limit"].(*int)), true + + case "Pet.id": + if e.complexity.Pet.ID == nil { + break + } + + return e.complexity.Pet.ID(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 "PtrToAnyContainer.binding": + if e.complexity.PtrToAnyContainer.Binding == nil { + break + } + + return e.complexity.PtrToAnyContainer.Binding(childComplexity), true + + case "PtrToAnyContainer.ptrToAny": + if e.complexity.PtrToAnyContainer.PtrToAny == nil { + break + } + + return e.complexity.PtrToAnyContainer.PtrToAny(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.deferCase1": + if e.complexity.Query.DeferCase1 == nil { + break + } + + return e.complexity.Query.DeferCase1(childComplexity), true + + case "Query.deferCase2": + if e.complexity.Query.DeferCase2 == nil { + break + } + + return e.complexity.Query.DeferCase2(childComplexity), 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.dog": + if e.complexity.Query.Dog == nil { + break + } + + return e.complexity.Query.Dog(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.inputOmittable": + if e.complexity.Query.InputOmittable == nil { + break + } + + args, err := ec.field_Query_inputOmittable_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.InputOmittable(childComplexity, args["arg"].(OmittableInput)), 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.invalid": + if e.complexity.Query.Invalid == nil { + break + } + + return e.complexity.Query.Invalid(childComplexity), 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.ptrToAnyContainer": + if e.complexity.Query.PtrToAnyContainer == nil { + break + } + + return e.complexity.Query.PtrToAnyContainer(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.variadicModel": + if e.complexity.Query.VariadicModel == nil { + break + } + + return e.complexity.Query.VariadicModel(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 "Size.height": + if e.complexity.Size.Height == nil { + break + } + + return e.complexity.Size.Height(childComplexity), true + + case "Size.weight": + if e.complexity.Size.Weight == nil { + break + } + + return e.complexity.Size.Weight(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.errorRequired": + if e.complexity.Subscription.ErrorRequired == nil { + break + } + + return e.complexity.Subscription.ErrorRequired(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.pets": + if e.complexity.User.Pets == nil { + break + } + + args, err := ec.field_User_pets_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.User.Pets(childComplexity, args["limit"].(*int)), 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 "VariadicModel.value": + if e.complexity.VariadicModel.Value == nil { + break + } + + args, err := ec.field_VariadicModel_value_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.VariadicModel.Value(childComplexity, args["rank"].(int)), 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, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap( + ec.unmarshalInputChanges, + ec.unmarshalInputDefaultInput, + ec.unmarshalInputFieldsOrderInput, + ec.unmarshalInputInnerDirectives, + ec.unmarshalInputInnerInput, + ec.unmarshalInputInputDirectives, + ec.unmarshalInputInputWithEnumValue, + ec.unmarshalInputMapNestedInput, + ec.unmarshalInputMapStringInterfaceInput, + ec.unmarshalInputNestedInput, + ec.unmarshalInputNestedMapInput, + ec.unmarshalInputOmittableInput, + ec.unmarshalInputOuterInput, + ec.unmarshalInputRecursiveInputSlice, + ec.unmarshalInputSpecialInput, + ec.unmarshalInputUpdatePtrToPtrInner, + ec.unmarshalInputUpdatePtrToPtrOuter, + ec.unmarshalInputValidInput, + ) + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + case ast.Mutation: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + 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(ctx) + + 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 + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + +//go:embed "builtinscalar.graphql" "complexity.graphql" "defaults.graphql" "defer.graphql" "directive.graphql" "embedded.graphql" "enum.graphql" "fields_order.graphql" "interfaces.graphql" "issue896.graphql" "loops.graphql" "maps.graphql" "mutation_with_custom_scalar.graphql" "nulls.graphql" "panics.graphql" "primitive_objects.graphql" "ptr_to_any.graphql" "ptr_to_ptr_input.graphql" "ptr_to_slice.graphql" "scalar_context.graphql" "scalar_default.graphql" "schema.graphql" "slices.graphql" "typefallback.graphql" "useptr.graphql" "v-ok.graphql" "validtypes.graphql" "variadic.graphql" "weird_type_cases.graphql" "wrapped_type.graphql" +var sourcesFS embed.FS + +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) +} + +var sources = []*ast.Source{ + {Name: "builtinscalar.graphql", Input: sourceData("builtinscalar.graphql"), BuiltIn: false}, + {Name: "complexity.graphql", Input: sourceData("complexity.graphql"), BuiltIn: false}, + {Name: "defaults.graphql", Input: sourceData("defaults.graphql"), BuiltIn: false}, + {Name: "defer.graphql", Input: sourceData("defer.graphql"), BuiltIn: false}, + {Name: "directive.graphql", Input: sourceData("directive.graphql"), BuiltIn: false}, + {Name: "embedded.graphql", Input: sourceData("embedded.graphql"), BuiltIn: false}, + {Name: "enum.graphql", Input: sourceData("enum.graphql"), BuiltIn: false}, + {Name: "fields_order.graphql", Input: sourceData("fields_order.graphql"), BuiltIn: false}, + {Name: "interfaces.graphql", Input: sourceData("interfaces.graphql"), BuiltIn: false}, + {Name: "issue896.graphql", Input: sourceData("issue896.graphql"), BuiltIn: false}, + {Name: "loops.graphql", Input: sourceData("loops.graphql"), BuiltIn: false}, + {Name: "maps.graphql", Input: sourceData("maps.graphql"), BuiltIn: false}, + {Name: "mutation_with_custom_scalar.graphql", Input: sourceData("mutation_with_custom_scalar.graphql"), BuiltIn: false}, + {Name: "nulls.graphql", Input: sourceData("nulls.graphql"), BuiltIn: false}, + {Name: "panics.graphql", Input: sourceData("panics.graphql"), BuiltIn: false}, + {Name: "primitive_objects.graphql", Input: sourceData("primitive_objects.graphql"), BuiltIn: false}, + {Name: "ptr_to_any.graphql", Input: sourceData("ptr_to_any.graphql"), BuiltIn: false}, + {Name: "ptr_to_ptr_input.graphql", Input: sourceData("ptr_to_ptr_input.graphql"), BuiltIn: false}, + {Name: "ptr_to_slice.graphql", Input: sourceData("ptr_to_slice.graphql"), BuiltIn: false}, + {Name: "scalar_context.graphql", Input: sourceData("scalar_context.graphql"), BuiltIn: false}, + {Name: "scalar_default.graphql", Input: sourceData("scalar_default.graphql"), BuiltIn: false}, + {Name: "schema.graphql", Input: sourceData("schema.graphql"), BuiltIn: false}, + {Name: "slices.graphql", Input: sourceData("slices.graphql"), BuiltIn: false}, + {Name: "typefallback.graphql", Input: sourceData("typefallback.graphql"), BuiltIn: false}, + {Name: "useptr.graphql", Input: sourceData("useptr.graphql"), BuiltIn: false}, + {Name: "v-ok.graphql", Input: sourceData("v-ok.graphql"), BuiltIn: false}, + {Name: "validtypes.graphql", Input: sourceData("validtypes.graphql"), BuiltIn: false}, + {Name: "variadic.graphql", Input: sourceData("variadic.graphql"), BuiltIn: false}, + {Name: "weird_type_cases.graphql", Input: sourceData("weird_type_cases.graphql"), BuiltIn: false}, + {Name: "wrapped_type.graphql", Input: sourceData("wrapped_type.graphql"), BuiltIn: false}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (ec *executionContext) dir_defer_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["if"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("if")) + arg0, err = ec.unmarshalOBoolean2ᚖbool(ctx, tmp) + if err != nil { + return nil, err + } + } + args["if"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["label"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("label")) + arg1, err = ec.unmarshalOString2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["label"] = arg1 + return args, nil +} + +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 +} + +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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDefaultInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["input"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_overrideValueViaInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 FieldsOrderInput + if tmp, ok := rawArgs["input"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) + arg0, err = ec.unmarshalNFieldsOrderInput2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐFieldsOrderInput(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐSpecialInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["input"] = arg0 + return args, nil +} + +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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanicᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["u"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Pet_friends_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["limit"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("limit")) + arg0, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["limit"] = arg0 + return args, nil +} + +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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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/niko0xdev/gqlgen/codegen/testserver/singlefile.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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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_inputOmittable_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 OmittableInput + if tmp, ok := rawArgs["arg"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("arg")) + arg0, err = ec.unmarshalNOmittableInput2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOmittableInput(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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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 +} + +func (ec *executionContext) field_User_pets_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["limit"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("limit")) + arg0, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["limit"] = arg0 + return args, nil +} + +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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐValidInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["input"] = arg0 + return args, nil +} + +func (ec *executionContext) field_VariadicModel_value_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["rank"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("rank")) + arg0, err = ec.unmarshalNInt2int(ctx, tmp) + if err != nil { + return nil, err + } + } + args["rank"] = arg0 + return args, nil +} + +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 +} + +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 ************************** + +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) _A_id(ctx context.Context, field graphql.CollectedField, obj *A) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_A_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_A_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "A", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _AIt_id(ctx context.Context, field graphql.CollectedField, obj *AIt) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_AIt_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_AIt_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "AIt", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _AbIt_id(ctx context.Context, field graphql.CollectedField, obj *AbIt) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_AbIt_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_AbIt_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "AbIt", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Autobind_int(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Autobind_int(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Autobind_int(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Autobind", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Autobind_int32(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Autobind_int32(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Autobind_int32(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Autobind", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Autobind_int64(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Autobind_int64(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Autobind_int64(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Autobind", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Autobind_idStr(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Autobind_idStr(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Autobind_idStr(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Autobind", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Autobind_idInt(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Autobind_idInt(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Autobind_idInt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Autobind", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _B_id(ctx context.Context, field graphql.CollectedField, obj *B) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_B_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_B_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "B", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _BackedByInterface_id(ctx context.Context, field graphql.CollectedField, obj BackedByInterface) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BackedByInterface_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_BackedByInterface_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "BackedByInterface", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _BackedByInterface_thisShouldBind(ctx context.Context, field graphql.CollectedField, obj BackedByInterface) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BackedByInterface_thisShouldBind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_BackedByInterface_thisShouldBind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "BackedByInterface", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _BackedByInterface_thisShouldBindWithError(ctx context.Context, field graphql.CollectedField, obj BackedByInterface) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BackedByInterface_thisShouldBindWithError(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_BackedByInterface_thisShouldBindWithError(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "BackedByInterface", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Cat_species(ctx context.Context, field graphql.CollectedField, obj *Cat) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Cat_species(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Cat_species(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Cat", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Cat_size(ctx context.Context, field graphql.CollectedField, obj *Cat) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Cat_size(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Size, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*Size) + fc.Result = res + return ec.marshalNSize2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐSize(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Cat_size(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Cat", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "height": + return ec.fieldContext_Size_height(ctx, field) + case "weight": + return ec.fieldContext_Size_weight(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Size", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Cat_catBreed(ctx context.Context, field graphql.CollectedField, obj *Cat) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Cat_catBreed(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Cat_catBreed(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Cat", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _CheckIssue896_id(ctx context.Context, field graphql.CollectedField, obj *CheckIssue896) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CheckIssue896_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) +} + +func (ec *executionContext) fieldContext_CheckIssue896_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CheckIssue896", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Circle_radius(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Circle_radius(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Circle", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Circle_area(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Circle_area(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Circle", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Circle_coordinates(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Circle_coordinates(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCoordinates(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Circle_coordinates(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Circle", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "x": + return ec.fieldContext_Coordinates_x(ctx, field) + case "y": + return ec.fieldContext_Coordinates_y(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Coordinates", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _ConcreteNodeA_id(ctx context.Context, field graphql.CollectedField, obj *ConcreteNodeA) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ConcreteNodeA_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ConcreteNodeA_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ConcreteNodeA", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ConcreteNodeA_child(ctx context.Context, field graphql.CollectedField, obj *ConcreteNodeA) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ConcreteNodeA_child(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐNode(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ConcreteNodeA_child(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ConcreteNodeA", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + }, + } + return fc, nil +} + +func (ec *executionContext) _ConcreteNodeA_name(ctx context.Context, field graphql.CollectedField, obj *ConcreteNodeA) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ConcreteNodeA_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ConcreteNodeA_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ConcreteNodeA", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ConcreteNodeInterface_id(ctx context.Context, field graphql.CollectedField, obj ConcreteNodeInterface) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ConcreteNodeInterface_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ConcreteNodeInterface_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ConcreteNodeInterface", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ConcreteNodeInterface_child(ctx context.Context, field graphql.CollectedField, obj ConcreteNodeInterface) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ConcreteNodeInterface_child(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐNode(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ConcreteNodeInterface_child(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ConcreteNodeInterface", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + }, + } + return fc, nil +} + +func (ec *executionContext) _Content_Post_foo(ctx context.Context, field graphql.CollectedField, obj *ContentPost) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Content_Post_foo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Content_Post_foo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Content_Post", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Content_User_foo(ctx context.Context, field graphql.CollectedField, obj *ContentUser) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Content_User_foo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Content_User_foo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Content_User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Coordinates_x(ctx context.Context, field graphql.CollectedField, obj *Coordinates) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Coordinates_x(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Coordinates_x(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Coordinates", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Coordinates_y(ctx context.Context, field graphql.CollectedField, obj *Coordinates) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Coordinates_y(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Coordinates_y(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Coordinates", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _DefaultParametersMirror_falsyBoolean(ctx context.Context, field graphql.CollectedField, obj *DefaultParametersMirror) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_DefaultParametersMirror_falsyBoolean(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_DefaultParametersMirror_falsyBoolean(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "DefaultParametersMirror", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _DefaultParametersMirror_truthyBoolean(ctx context.Context, field graphql.CollectedField, obj *DefaultParametersMirror) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_DefaultParametersMirror_truthyBoolean(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_DefaultParametersMirror_truthyBoolean(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "DefaultParametersMirror", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _DeferModel_id(ctx context.Context, field graphql.CollectedField, obj *DeferModel) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_DeferModel_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_DeferModel_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "DeferModel", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _DeferModel_name(ctx context.Context, field graphql.CollectedField, obj *DeferModel) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_DeferModel_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_DeferModel_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "DeferModel", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _DeferModel_values(ctx context.Context, field graphql.CollectedField, obj *DeferModel) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_DeferModel_values(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.DeferModel().Values(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.marshalNString2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_DeferModel_values(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "DeferModel", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Dog_species(ctx context.Context, field graphql.CollectedField, obj *Dog) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Dog_species(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Dog_species(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Dog", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Dog_size(ctx context.Context, field graphql.CollectedField, obj *Dog) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Dog_size(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Size, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*Size) + fc.Result = res + return ec.marshalNSize2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐSize(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Dog_size(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Dog", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "height": + return ec.fieldContext_Size_height(ctx, field) + case "weight": + return ec.fieldContext_Size_weight(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Size", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Dog_dogBreed(ctx context.Context, field graphql.CollectedField, obj *Dog) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Dog_dogBreed(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Dog_dogBreed(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Dog", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _EmbeddedCase1_exportedEmbeddedPointerExportedMethod(ctx context.Context, field graphql.CollectedField, obj *EmbeddedCase1) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_EmbeddedCase1_exportedEmbeddedPointerExportedMethod(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_EmbeddedCase1_exportedEmbeddedPointerExportedMethod(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "EmbeddedCase1", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(ctx context.Context, field graphql.CollectedField, obj *EmbeddedCase2) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "EmbeddedCase2", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod(ctx context.Context, field graphql.CollectedField, obj *EmbeddedCase3) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) +} + +func (ec *executionContext) fieldContext_EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "EmbeddedCase3", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _EmbeddedDefaultScalar_value(ctx context.Context, field graphql.CollectedField, obj *EmbeddedDefaultScalar) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_EmbeddedDefaultScalar_value(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) +} + +func (ec *executionContext) fieldContext_EmbeddedDefaultScalar_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "EmbeddedDefaultScalar", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type DefaultScalarImplementation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _EmbeddedPointer_ID(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_EmbeddedPointer_ID(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_EmbeddedPointer_ID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "EmbeddedPointer", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _EmbeddedPointer_Title(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_EmbeddedPointer_Title(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_EmbeddedPointer_Title(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "EmbeddedPointer", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Error_id(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Error_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Error_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Error", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Error_errorOnNonRequiredField(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Error", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Error_errorOnRequiredField(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Error_errorOnRequiredField(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Error", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Error_nilOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Error_nilOnRequiredField(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Error_nilOnRequiredField(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Error", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Errors_a(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Errors_a(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Errors_a(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Errors", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Error_id(ctx, field) + case "errorOnNonRequiredField": + return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) + case "errorOnRequiredField": + return ec.fieldContext_Error_errorOnRequiredField(ctx, field) + case "nilOnRequiredField": + return ec.fieldContext_Error_nilOnRequiredField(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Errors_b(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Errors_b(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Errors_b(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Errors", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Error_id(ctx, field) + case "errorOnNonRequiredField": + return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) + case "errorOnRequiredField": + return ec.fieldContext_Error_errorOnRequiredField(ctx, field) + case "nilOnRequiredField": + return ec.fieldContext_Error_nilOnRequiredField(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Errors_c(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Errors_c(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Errors_c(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Errors", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Error_id(ctx, field) + case "errorOnNonRequiredField": + return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) + case "errorOnRequiredField": + return ec.fieldContext_Error_errorOnRequiredField(ctx, field) + case "nilOnRequiredField": + return ec.fieldContext_Error_nilOnRequiredField(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Errors_d(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Errors_d(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Errors_d(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Errors", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Error_id(ctx, field) + case "errorOnNonRequiredField": + return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) + case "errorOnRequiredField": + return ec.fieldContext_Error_errorOnRequiredField(ctx, field) + case "nilOnRequiredField": + return ec.fieldContext_Error_nilOnRequiredField(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Errors_e(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Errors_e(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Errors_e(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Errors", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Error_id(ctx, field) + case "errorOnNonRequiredField": + return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) + case "errorOnRequiredField": + return ec.fieldContext_Error_errorOnRequiredField(ctx, field) + case "nilOnRequiredField": + return ec.fieldContext_Error_nilOnRequiredField(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _FieldsOrderPayload_firstFieldValue(ctx context.Context, field graphql.CollectedField, obj *FieldsOrderPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_FieldsOrderPayload_firstFieldValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.FirstFieldValue, nil + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_FieldsOrderPayload_firstFieldValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "FieldsOrderPayload", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field graphql.CollectedField, obj *ForcedResolver) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ForcedResolver_field(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCircle(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ForcedResolver_field(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ForcedResolver", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "radius": + return ec.fieldContext_Circle_radius(ctx, field) + case "area": + return ec.fieldContext_Circle_area(ctx, field) + case "coordinates": + return ec.fieldContext_Circle_coordinates(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Circle", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Horse_species(ctx context.Context, field graphql.CollectedField, obj *Horse) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Horse_species(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Horse_species(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Horse", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Horse_size(ctx context.Context, field graphql.CollectedField, obj *Horse) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Horse_size(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Size, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*Size) + fc.Result = res + return ec.marshalNSize2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐSize(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Horse_size(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Horse", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "height": + return ec.fieldContext_Size_height(ctx, field) + case "weight": + return ec.fieldContext_Size_weight(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Size", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Horse_horseBreed(ctx context.Context, field graphql.CollectedField, obj *Horse) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Horse_horseBreed(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.HorseBreed, 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) fieldContext_Horse_horseBreed(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Horse", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.CollectedField, obj *InnerObject) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_InnerObject_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_InnerObject_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "InnerObject", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field graphql.CollectedField, obj *invalid_packagename.InvalidIdentifier) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_InvalidIdentifier_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_InvalidIdentifier_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "InvalidIdentifier", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedField, obj *introspection1.It) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_It_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_It_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "It", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _LoopA_b(ctx context.Context, field graphql.CollectedField, obj *LoopA) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_LoopA_b(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐLoopB(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_LoopA_b(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "LoopA", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "a": + return ec.fieldContext_LoopB_a(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type LoopB", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _LoopB_a(ctx context.Context, field graphql.CollectedField, obj *LoopB) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_LoopB_a(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐLoopA(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_LoopB_a(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "LoopB", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "b": + return ec.fieldContext_LoopA_b(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type LoopA", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Map_id(ctx context.Context, field graphql.CollectedField, obj *Map) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Map_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Map_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Map", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MapNested_value(ctx context.Context, field graphql.CollectedField, obj *MapNested) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MapNested_value(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.(CustomScalar) + fc.Result = res + return ec.marshalNCustomScalar2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCustomScalar(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MapNested_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MapNested", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type CustomScalar does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MapStringInterfaceType_a(ctx context.Context, field graphql.CollectedField, obj map[string]interface{}) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MapStringInterfaceType_a(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_MapStringInterfaceType_a(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MapStringInterfaceType", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MapStringInterfaceType_b(ctx context.Context, field graphql.CollectedField, obj map[string]interface{}) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MapStringInterfaceType_b(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) +} + +func (ec *executionContext) fieldContext_MapStringInterfaceType_b(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MapStringInterfaceType", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MapStringInterfaceType_c(ctx context.Context, field graphql.CollectedField, obj map[string]interface{}) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MapStringInterfaceType_c(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + switch v := obj["c"].(type) { + case *CustomScalar: + return v, nil + case CustomScalar: + return &v, nil + case nil: + return (*CustomScalar)(nil), nil + default: + return nil, fmt.Errorf("unexpected type %T for field %s", v, "c") + } + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*CustomScalar) + fc.Result = res + return ec.marshalOCustomScalar2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCustomScalar(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MapStringInterfaceType_c(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MapStringInterfaceType", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type CustomScalar does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MapStringInterfaceType_nested(ctx context.Context, field graphql.CollectedField, obj map[string]interface{}) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MapStringInterfaceType_nested(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + switch v := obj["nested"].(type) { + case *MapNested: + return v, nil + case MapNested: + return &v, nil + case nil: + return (*MapNested)(nil), nil + default: + return nil, fmt.Errorf("unexpected type %T for field %s", v, "nested") + } + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*MapNested) + fc.Result = res + return ec.marshalOMapNested2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMapNested(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MapStringInterfaceType_nested(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MapStringInterfaceType", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "value": + return ec.fieldContext_MapNested_value(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type MapNested", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _ModelMethods_resolverField(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ModelMethods_resolverField(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ModelMethods_resolverField(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ModelMethods", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ModelMethods_noContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ModelMethods_noContext(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ModelMethods_noContext(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ModelMethods", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ModelMethods_withContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ModelMethods_withContext(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ModelMethods_withContext(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ModelMethods", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Mutation_defaultInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_defaultInput(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDefaultParametersMirror(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_defaultInput(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "falsyBoolean": + return ec.fieldContext_DefaultParametersMirror_falsyBoolean(ctx, field) + case "truthyBoolean": + return ec.fieldContext_DefaultParametersMirror_truthyBoolean(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type DefaultParametersMirror", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_defaultInput_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_overrideValueViaInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_overrideValueViaInput(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().OverrideValueViaInput(rctx, fc.Args["input"].(FieldsOrderInput)) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*FieldsOrderPayload) + fc.Result = res + return ec.marshalNFieldsOrderPayload2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐFieldsOrderPayload(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_overrideValueViaInput(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "firstFieldValue": + return ec.fieldContext_FieldsOrderPayload_firstFieldValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type FieldsOrderPayload", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_overrideValueViaInput_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_updateSomething(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateSomething(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Mutation_updateSomething(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_updateSomething_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_updatePtrToPtr(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updatePtrToPtr(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrOuter(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_updatePtrToPtr(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_PtrToPtrOuter_name(ctx, field) + case "inner": + return ec.fieldContext_PtrToPtrOuter_inner(ctx, field) + case "stupidInner": + return ec.fieldContext_PtrToPtrOuter_stupidInner(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PtrToPtrOuter", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_updatePtrToPtr_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _ObjectDirectives_text(ctx context.Context, field graphql.CollectedField, obj *ObjectDirectives) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ObjectDirectives_text(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ObjectDirectives_text(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ObjectDirectives", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ObjectDirectives_nullableText(ctx context.Context, field graphql.CollectedField, obj *ObjectDirectives) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ObjectDirectives_nullableText(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ObjectDirectives_nullableText(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ObjectDirectives", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ObjectDirectives_order(ctx context.Context, field graphql.CollectedField, obj *ObjectDirectives) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ObjectDirectives_order(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ObjectDirectives_order(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ObjectDirectives", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ObjectDirectivesWithCustomGoModel_nullableText(ctx context.Context, field graphql.CollectedField, obj *ObjectDirectivesWithCustomGoModel) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ObjectDirectivesWithCustomGoModel_nullableText(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) +} + +func (ec *executionContext) fieldContext_ObjectDirectivesWithCustomGoModel_nullableText(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ObjectDirectivesWithCustomGoModel", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphql.CollectedField, obj *OuterObject) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_OuterObject_inner(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInnerObject(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_OuterObject_inner(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "OuterObject", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_InnerObject_id(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type InnerObject", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _OverlappingFields_oneFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_OverlappingFields_oneFoo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_OverlappingFields_oneFoo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "OverlappingFields", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _OverlappingFields_twoFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_OverlappingFields_twoFoo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_OverlappingFields_twoFoo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "OverlappingFields", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _OverlappingFields_oldFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_OverlappingFields_oldFoo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_OverlappingFields_oldFoo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "OverlappingFields", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _OverlappingFields_newFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_OverlappingFields_newFoo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_OverlappingFields_newFoo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "OverlappingFields", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _OverlappingFields_new_foo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_OverlappingFields_new_foo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_OverlappingFields_new_foo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "OverlappingFields", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Panics_fieldScalarMarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Panics_fieldScalarMarshal(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanicᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Panics_fieldScalarMarshal(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Panics", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type MarshalPanic does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Panics_fieldFuncMarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Panics_fieldFuncMarshal(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.FieldFuncMarshal(ctx, fc.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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanicᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Panics_fieldFuncMarshal(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Panics", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type MarshalPanic does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Panics_fieldFuncMarshal_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Panics_argUnmarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Panics_argUnmarshal(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) +} + +func (ec *executionContext) fieldContext_Panics_argUnmarshal(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Panics", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Panics_argUnmarshal_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Pet_id(ctx context.Context, field graphql.CollectedField, obj *Pet) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Pet_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Pet_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Pet", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Pet_friends(ctx context.Context, field graphql.CollectedField, obj *Pet) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Pet_friends(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Pet().Friends(rctx, obj, fc.Args["limit"].(*int)) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*Pet) + fc.Result = res + return ec.marshalOPet2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPetᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Pet_friends(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Pet", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Pet_id(ctx, field) + case "friends": + return ec.fieldContext_Pet_friends(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Pet", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Pet_friends_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Primitive_value(ctx context.Context, field graphql.CollectedField, obj *Primitive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Primitive_value(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Primitive_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Primitive", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Primitive_squared(ctx context.Context, field graphql.CollectedField, obj *Primitive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Primitive_squared(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Primitive_squared(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Primitive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PrimitiveString_value(ctx context.Context, field graphql.CollectedField, obj *PrimitiveString) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PrimitiveString_value(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_PrimitiveString_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PrimitiveString", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PrimitiveString_doubled(ctx context.Context, field graphql.CollectedField, obj *PrimitiveString) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PrimitiveString_doubled(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_PrimitiveString_doubled(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PrimitiveString", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PrimitiveString_len(ctx context.Context, field graphql.CollectedField, obj *PrimitiveString) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PrimitiveString_len(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) +} + +func (ec *executionContext) fieldContext_PrimitiveString_len(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PrimitiveString", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PtrToAnyContainer_ptrToAny(ctx context.Context, field graphql.CollectedField, obj *PtrToAnyContainer) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PtrToAnyContainer_ptrToAny(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PtrToAny, nil + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*any) + fc.Result = res + return ec.marshalOAny2ᚖinterface(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PtrToAnyContainer_ptrToAny(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PtrToAnyContainer", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Any does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PtrToAnyContainer_binding(ctx context.Context, field graphql.CollectedField, obj *PtrToAnyContainer) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PtrToAnyContainer_binding(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Binding(), nil + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*any) + fc.Result = res + return ec.marshalOAny2ᚖinterface(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PtrToAnyContainer_binding(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PtrToAnyContainer", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Any does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PtrToPtrInner_key(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrInner) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PtrToPtrInner_key(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_PtrToPtrInner_key(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PtrToPtrInner", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PtrToPtrInner_value(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrInner) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PtrToPtrInner_value(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_PtrToPtrInner_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PtrToPtrInner", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PtrToPtrOuter_name(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrOuter) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PtrToPtrOuter_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_PtrToPtrOuter_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PtrToPtrOuter", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PtrToPtrOuter_inner(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrOuter) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PtrToPtrOuter_inner(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PtrToPtrOuter_inner(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PtrToPtrOuter", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "key": + return ec.fieldContext_PtrToPtrInner_key(ctx, field) + case "value": + return ec.fieldContext_PtrToPtrInner_value(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PtrToPtrInner", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _PtrToPtrOuter_stupidInner(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrOuter) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PtrToPtrOuter_stupidInner(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PtrToPtrOuter_stupidInner(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PtrToPtrOuter", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "key": + return ec.fieldContext_PtrToPtrInner_key(ctx, field) + case "value": + return ec.fieldContext_PtrToPtrInner_value(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PtrToPtrInner", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _PtrToSliceContainer_ptrToSlice(ctx context.Context, field graphql.CollectedField, obj *PtrToSliceContainer) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PtrToSliceContainer_ptrToSlice(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_PtrToSliceContainer_ptrToSlice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PtrToSliceContainer", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_invalidIdentifier(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_invalidIdentifier(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_InvalidIdentifier_id(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type InvalidIdentifier", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_collision(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_collision(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋintrospectionᚐIt(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_collision(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_It_id(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type It", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_mapInput(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_mapInput(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_mapInput_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_recursive(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_recursive(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_recursive_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_nestedInputs(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_nestedInputs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_nestedInputs_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_nestedOutputs(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterObject(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_nestedOutputs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "inner": + return ec.fieldContext_OuterObject_inner(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type OuterObject", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_modelMethods(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_modelMethods(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐModelMethods(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_modelMethods(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "resolverField": + return ec.fieldContext_ModelMethods_resolverField(ctx, field) + case "noContext": + return ec.fieldContext_ModelMethods_noContext(ctx, field) + case "withContext": + return ec.fieldContext_ModelMethods_withContext(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ModelMethods", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_user(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "friends": + return ec.fieldContext_User_friends(ctx, field) + case "created": + return ec.fieldContext_User_created(ctx, field) + case "updated": + return ec.fieldContext_User_updated(ctx, field) + case "pets": + return ec.fieldContext_User_pets(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_user_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_nullableArg(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_nullableArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_nullableArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_inputSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_inputSlice(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_inputSlice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_inputSlice_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_inputNullableSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_inputNullableSlice(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_inputNullableSlice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_inputNullableSlice_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_inputOmittable(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_inputOmittable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().InputOmittable(rctx, fc.Args["arg"].(OmittableInput)) + }) + + 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) fieldContext_Query_inputOmittable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_inputOmittable_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_shapeUnion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_shapeUnion(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐShapeUnion(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_shapeUnion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ShapeUnion does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_autobind(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_autobind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐAutobind(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_autobind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "int": + return ec.fieldContext_Autobind_int(ctx, field) + case "int32": + return ec.fieldContext_Autobind_int32(ctx, field) + case "int64": + return ec.fieldContext_Autobind_int64(ctx, field) + case "idStr": + return ec.fieldContext_Autobind_idStr(ctx, field) + case "idInt": + return ec.fieldContext_Autobind_idInt(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Autobind", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_deprecatedField(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_deprecatedField(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Query_deprecatedField(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_overlapping(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_overlapping(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOverlappingFields(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_overlapping(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "oneFoo": + return ec.fieldContext_OverlappingFields_oneFoo(ctx, field) + case "twoFoo": + return ec.fieldContext_OverlappingFields_twoFoo(ctx, field) + case "oldFoo": + return ec.fieldContext_OverlappingFields_oldFoo(ctx, field) + case "newFoo": + return ec.fieldContext_OverlappingFields_newFoo(ctx, field) + case "new_foo": + return ec.fieldContext_OverlappingFields_new_foo(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type OverlappingFields", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_defaultParameters(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_defaultParameters(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.Args["falsyBoolean"].(*bool), fc.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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDefaultParametersMirror(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_defaultParameters(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "falsyBoolean": + return ec.fieldContext_DefaultParametersMirror_falsyBoolean(ctx, field) + case "truthyBoolean": + return ec.fieldContext_DefaultParametersMirror_truthyBoolean(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type DefaultParametersMirror", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_defaultParameters_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_deferCase1(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_deferCase1(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().DeferCase1(rctx) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*DeferModel) + fc.Result = res + return ec.marshalODeferModel2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDeferModel(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_deferCase1(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_DeferModel_id(ctx, field) + case "name": + return ec.fieldContext_DeferModel_name(ctx, field) + case "values": + return ec.fieldContext_DeferModel_values(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type DeferModel", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_deferCase2(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_deferCase2(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().DeferCase2(rctx) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*DeferModel) + fc.Result = res + return ec.marshalODeferModel2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDeferModelᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_deferCase2(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_DeferModel_id(ctx, field) + case "name": + return ec.fieldContext_DeferModel_name(ctx, field) + case "values": + return ec.fieldContext_DeferModel_values(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type DeferModel", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_directiveArg(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_directiveArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_directiveArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_directiveNullableArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_directiveNullableArg(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.Args["arg"].(*int), fc.Args["arg2"].(*int), fc.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) fieldContext_Query_directiveNullableArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_directiveNullableArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_directiveInputNullable(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_directiveInputNullable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_directiveInputNullable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_directiveInputNullable_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_directiveInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_directiveInput(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_directiveInput(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_directiveInput_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_directiveInputType(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_directiveInputType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_directiveInputType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_directiveInputType_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_directiveObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_directiveObject(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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/niko0xdev/gqlgen/codegen/testserver/singlefile.ObjectDirectives`, tmp) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*ObjectDirectives) + fc.Result = res + return ec.marshalOObjectDirectives2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐObjectDirectives(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_directiveObject(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "text": + return ec.fieldContext_ObjectDirectives_text(ctx, field) + case "nullableText": + return ec.fieldContext_ObjectDirectives_nullableText(ctx, field) + case "order": + return ec.fieldContext_ObjectDirectives_order(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ObjectDirectives", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_directiveObjectWithCustomGoModel(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_directiveObjectWithCustomGoModel(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐObjectDirectivesWithCustomGoModel(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_directiveObjectWithCustomGoModel(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "nullableText": + return ec.fieldContext_ObjectDirectivesWithCustomGoModel_nullableText(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ObjectDirectivesWithCustomGoModel", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_directiveFieldDef(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_directiveFieldDef(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_directiveFieldDef(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_directiveFieldDef_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_directiveField(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_directiveField(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Query_directiveField(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_directiveDouble(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_directiveDouble(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Query_directiveDouble(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_directiveUnimplemented(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_directiveUnimplemented(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Query_directiveUnimplemented(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_embeddedCase1(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_embeddedCase1(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEmbeddedCase1(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_embeddedCase1(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "exportedEmbeddedPointerExportedMethod": + return ec.fieldContext_EmbeddedCase1_exportedEmbeddedPointerExportedMethod(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type EmbeddedCase1", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_embeddedCase2(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_embeddedCase2(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEmbeddedCase2(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_embeddedCase2(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "unexportedEmbeddedPointerExportedMethod": + return ec.fieldContext_EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type EmbeddedCase2", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_embeddedCase3(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_embeddedCase3(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEmbeddedCase3(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_embeddedCase3(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "unexportedEmbeddedInterfaceExportedMethod": + return ec.fieldContext_EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type EmbeddedCase3", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_enumInInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_enumInInput(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEnumTest(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_enumInInput(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type EnumTest does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_enumInInput_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_shapes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐShape(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_shapes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_noShape(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_noShape(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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/niko0xdev/gqlgen/codegen/testserver/singlefile.Shape`, tmp) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(Shape) + fc.Result = res + return ec.marshalOShape2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐShape(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_noShape(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐNode(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_noShapeTypedNil(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_noShapeTypedNil(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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/niko0xdev/gqlgen/codegen/testserver/singlefile.Shape`, tmp) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(Shape) + fc.Result = res + return ec.marshalOShape2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐShape(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_noShapeTypedNil(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_animal(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_animal(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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/niko0xdev/gqlgen/codegen/testserver/singlefile.Animal`, tmp) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(Animal) + fc.Result = res + return ec.marshalOAnimal2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐAnimal(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_animal(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_notAnInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_notAnInterface(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐBackedByInterface(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_notAnInterface(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_BackedByInterface_id(ctx, field) + case "thisShouldBind": + return ec.fieldContext_BackedByInterface_thisShouldBind(ctx, field) + case "thisShouldBindWithError": + return ec.fieldContext_BackedByInterface_thisShouldBindWithError(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type BackedByInterface", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_dog(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_dog(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Dog(rctx) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Dog) + fc.Result = res + return ec.marshalODog2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDog(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_dog(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "species": + return ec.fieldContext_Dog_species(ctx, field) + case "size": + return ec.fieldContext_Dog_size(ctx, field) + case "dogBreed": + return ec.fieldContext_Dog_dogBreed(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Dog", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_issue896a(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_issue896a(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCheckIssue896ᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_issue896a(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_CheckIssue896_id(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CheckIssue896", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_mapStringInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_mapStringInterface(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_mapStringInterface(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "a": + return ec.fieldContext_MapStringInterfaceType_a(ctx, field) + case "b": + return ec.fieldContext_MapStringInterfaceType_b(ctx, field) + case "c": + return ec.fieldContext_MapStringInterfaceType_c(ctx, field) + case "nested": + return ec.fieldContext_MapStringInterfaceType_nested(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type MapStringInterfaceType", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_mapStringInterface_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_mapNestedStringInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_mapNestedStringInterface(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_mapNestedStringInterface(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "a": + return ec.fieldContext_MapStringInterfaceType_a(ctx, field) + case "b": + return ec.fieldContext_MapStringInterfaceType_b(ctx, field) + case "c": + return ec.fieldContext_MapStringInterfaceType_c(ctx, field) + case "nested": + return ec.fieldContext_MapStringInterfaceType_nested(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type MapStringInterfaceType", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_mapNestedStringInterface_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_errorBubble(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_errorBubble(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Error_id(ctx, field) + case "errorOnNonRequiredField": + return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) + case "errorOnRequiredField": + return ec.fieldContext_Error_errorOnRequiredField(ctx, field) + case "nilOnRequiredField": + return ec.fieldContext_Error_nilOnRequiredField(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_errorBubbleList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_errorBubbleList(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐErrorᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_errorBubbleList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Error_id(ctx, field) + case "errorOnNonRequiredField": + return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) + case "errorOnRequiredField": + return ec.fieldContext_Error_errorOnRequiredField(ctx, field) + case "nilOnRequiredField": + return ec.fieldContext_Error_nilOnRequiredField(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_errorList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_errorList(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_errorList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Error_id(ctx, field) + case "errorOnNonRequiredField": + return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) + case "errorOnRequiredField": + return ec.fieldContext_Error_errorOnRequiredField(ctx, field) + case "nilOnRequiredField": + return ec.fieldContext_Error_nilOnRequiredField(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_errors(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_errors(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐErrors(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_errors(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "a": + return ec.fieldContext_Errors_a(ctx, field) + case "b": + return ec.fieldContext_Errors_b(ctx, field) + case "c": + return ec.fieldContext_Errors_c(ctx, field) + case "d": + return ec.fieldContext_Errors_d(ctx, field) + case "e": + return ec.fieldContext_Errors_e(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Errors", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_valid(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Query_valid(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_invalid(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_invalid(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Invalid(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) fieldContext_Query_invalid(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_panics(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_panics(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPanics(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_panics(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "fieldScalarMarshal": + return ec.fieldContext_Panics_fieldScalarMarshal(ctx, field) + case "fieldFuncMarshal": + return ec.fieldContext_Panics_fieldFuncMarshal(ctx, field) + case "argUnmarshal": + return ec.fieldContext_Panics_argUnmarshal(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Panics", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_primitiveObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_primitiveObject(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPrimitiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_primitiveObject(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "value": + return ec.fieldContext_Primitive_value(ctx, field) + case "squared": + return ec.fieldContext_Primitive_squared(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Primitive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_primitiveStringObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_primitiveStringObject(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPrimitiveStringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_primitiveStringObject(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "value": + return ec.fieldContext_PrimitiveString_value(ctx, field) + case "doubled": + return ec.fieldContext_PrimitiveString_doubled(ctx, field) + case "len": + return ec.fieldContext_PrimitiveString_len(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PrimitiveString", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_ptrToAnyContainer(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_ptrToAnyContainer(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().PtrToAnyContainer(rctx) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*PtrToAnyContainer) + fc.Result = res + return ec.marshalNPtrToAnyContainer2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToAnyContainer(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_ptrToAnyContainer(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "ptrToAny": + return ec.fieldContext_PtrToAnyContainer_ptrToAny(ctx, field) + case "binding": + return ec.fieldContext_PtrToAnyContainer_binding(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PtrToAnyContainer", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_ptrToSliceContainer(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_ptrToSliceContainer(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToSliceContainer(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_ptrToSliceContainer(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "ptrToSlice": + return ec.fieldContext_PtrToSliceContainer_ptrToSlice(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PtrToSliceContainer", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_infinity(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_infinity(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Query_infinity(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_stringFromContextInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_stringFromContextInterface(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐStringFromContextInterface(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_stringFromContextInterface(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type StringFromContextInterface does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_stringFromContextFunction(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_stringFromContextFunction(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Query_stringFromContextFunction(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type StringFromContextFunction does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_defaultScalar(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_defaultScalar(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_Query_defaultScalar(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type DefaultScalarImplementation does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_defaultScalar_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_slices(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_slices(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐSlices(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_slices(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "test1": + return ec.fieldContext_Slices_test1(ctx, field) + case "test2": + return ec.fieldContext_Slices_test2(ctx, field) + case "test3": + return ec.fieldContext_Slices_test3(ctx, field) + case "test4": + return ec.fieldContext_Slices_test4(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Slices", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_scalarSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_scalarSlice(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Query_scalarSlice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Bytes does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_fallback(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_fallback(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐFallbackToStringEncoding(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_fallback(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type FallbackToStringEncoding does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_fallback_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_optionalUnion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_optionalUnion(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐTestUnion(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_optionalUnion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type TestUnion does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_vOkCaseValue(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_vOkCaseValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐVOkCaseValue(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_vOkCaseValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "value": + return ec.fieldContext_VOkCaseValue_value(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type VOkCaseValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_vOkCaseNil(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_vOkCaseNil(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐVOkCaseNil(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_vOkCaseNil(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "value": + return ec.fieldContext_VOkCaseNil_value(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type VOkCaseNil", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_validType(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_validType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐValidType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_validType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "differentCase": + return ec.fieldContext_ValidType_differentCase(ctx, field) + case "different_case": + return ec.fieldContext_ValidType_different_case(ctx, field) + case "validInputKeywords": + return ec.fieldContext_ValidType_validInputKeywords(ctx, field) + case "validArgs": + return ec.fieldContext_ValidType_validArgs(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ValidType", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_variadicModel(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_variadicModel(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().VariadicModel(rctx) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*VariadicModel) + fc.Result = res + return ec.marshalOVariadicModel2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐVariadicModel(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_variadicModel(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "value": + return ec.fieldContext_VariadicModel_value(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type VariadicModel", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_wrappedStruct(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_wrappedStruct(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐWrappedStruct(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_wrappedStruct(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_WrappedStruct_name(ctx, field) + case "desc": + return ec.fieldContext_WrappedStruct_desc(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type WrappedStruct", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_wrappedScalar(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_wrappedScalar(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋotherpkgᚐScalar(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_wrappedScalar(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type WrappedScalar does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_wrappedMap(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_wrappedMap(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐWrappedMap(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_wrappedMap(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "get": + return ec.fieldContext_WrappedMap_get(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type WrappedMap", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_wrappedSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_wrappedSlice(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐWrappedSlice(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_wrappedSlice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "get": + return ec.fieldContext_WrappedSlice_get(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type WrappedSlice", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Rectangle_length(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Rectangle_length(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Rectangle", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Rectangle_width(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Rectangle_width(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Rectangle", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Rectangle_area(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Rectangle_area(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Rectangle", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Float does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Rectangle_coordinates(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Rectangle_coordinates(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCoordinates(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Rectangle_coordinates(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Rectangle", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "x": + return ec.fieldContext_Coordinates_x(ctx, field) + case "y": + return ec.fieldContext_Coordinates_y(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Coordinates", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Size_height(ctx context.Context, field graphql.CollectedField, obj *Size) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Size_height(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Height, 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) fieldContext_Size_height(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Size", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Size_weight(ctx context.Context, field graphql.CollectedField, obj *Size) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Size_weight(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Weight, 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) fieldContext_Size_weight(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Size", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Slices_test1(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Slices_test1(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Slices_test1(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Slices", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Slices_test2(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Slices_test2(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Slices_test2(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Slices", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Slices_test3(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Slices_test3(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Slices_test3(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Slices", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Slices_test4(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Slices_test4(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) +} + +func (ec *executionContext) fieldContext_Slices_test4(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Slices", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Subscription_updated(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { + fc, err := ec.fieldContext_Subscription_updated(ctx, field) + if err != nil { + return nil + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + 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(ctx context.Context) graphql.Marshaler { + select { + case 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{'}'}) + }) + case <-ctx.Done(): + return nil + } + } +} + +func (ec *executionContext) fieldContext_Subscription_updated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Subscription", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Subscription_initPayload(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { + fc, err := ec.fieldContext_Subscription_initPayload(ctx, field) + if err != nil { + return nil + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + 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(ctx context.Context) graphql.Marshaler { + select { + case 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{'}'}) + }) + case <-ctx.Done(): + return nil + } + } +} + +func (ec *executionContext) fieldContext_Subscription_initPayload(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Subscription", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Subscription_directiveArg(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { + fc, err := ec.fieldContext_Subscription_directiveArg(ctx, field) + if err != nil { + return nil + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + 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, fc.Args["arg"].(string)) + }) + + if resTmp == nil { + return nil + } + return func(ctx context.Context) graphql.Marshaler { + select { + case 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{'}'}) + }) + case <-ctx.Done(): + return nil + } + } +} + +func (ec *executionContext) fieldContext_Subscription_directiveArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Subscription", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Subscription_directiveArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Subscription_directiveNullableArg(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { + fc, err := ec.fieldContext_Subscription_directiveNullableArg(ctx, field) + if err != nil { + return nil + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + 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, fc.Args["arg"].(*int), fc.Args["arg2"].(*int), fc.Args["arg3"].(*string)) + }) + + if resTmp == nil { + return nil + } + return func(ctx context.Context) graphql.Marshaler { + select { + case 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{'}'}) + }) + case <-ctx.Done(): + return nil + } + } +} + +func (ec *executionContext) fieldContext_Subscription_directiveNullableArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Subscription", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Subscription_directiveNullableArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Subscription_directiveDouble(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { + fc, err := ec.fieldContext_Subscription_directiveDouble(ctx, field) + if err != nil { + return nil + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + 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(ctx context.Context) graphql.Marshaler { + select { + case 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{'}'}) + }) + case <-ctx.Done(): + return nil + } + } +} + +func (ec *executionContext) fieldContext_Subscription_directiveDouble(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Subscription", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Subscription_directiveUnimplemented(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { + fc, err := ec.fieldContext_Subscription_directiveUnimplemented(ctx, field) + if err != nil { + return nil + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + 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(ctx context.Context) graphql.Marshaler { + select { + case 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{'}'}) + }) + case <-ctx.Done(): + return nil + } + } +} + +func (ec *executionContext) fieldContext_Subscription_directiveUnimplemented(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Subscription", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Subscription_issue896b(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { + fc, err := ec.fieldContext_Subscription_issue896b(ctx, field) + if err != nil { + return nil + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + 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(ctx context.Context) graphql.Marshaler { + select { + case 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCheckIssue896(ctx, field.Selections, res).MarshalGQL(w) + w.Write([]byte{'}'}) + }) + case <-ctx.Done(): + return nil + } + } +} + +func (ec *executionContext) fieldContext_Subscription_issue896b(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Subscription", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_CheckIssue896_id(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CheckIssue896", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Subscription_errorRequired(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { + fc, err := ec.fieldContext_Subscription_errorRequired(ctx, field) + if err != nil { + return nil + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Subscription().ErrorRequired(rctx) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return nil + } + return func(ctx context.Context) graphql.Marshaler { + select { + case res, ok := <-resTmp.(<-chan *Error): + if !ok { + return nil + } + return graphql.WriterFunc(func(w io.Writer) { + w.Write([]byte{'{'}) + graphql.MarshalString(field.Alias).MarshalGQL(w) + w.Write([]byte{':'}) + ec.marshalNError2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx, field.Selections, res).MarshalGQL(w) + w.Write([]byte{'}'}) + }) + case <-ctx.Done(): + return nil + } + } +} + +func (ec *executionContext) fieldContext_Subscription_errorRequired(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Subscription", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Error_id(ctx, field) + case "errorOnNonRequiredField": + return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) + case "errorOnRequiredField": + return ec.fieldContext_Error_errorOnRequiredField(ctx, field) + case "nilOnRequiredField": + return ec.fieldContext_Error_nilOnRequiredField(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_User_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_friends(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_friends(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUserᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_friends(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "friends": + return ec.fieldContext_User_friends(ctx, field) + case "created": + return ec.fieldContext_User_created(ctx, field) + case "updated": + return ec.fieldContext_User_updated(ctx, field) + case "pets": + return ec.fieldContext_User_pets(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _User_created(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_created(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_User_created(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_updated(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_updated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) +} + +func (ec *executionContext) fieldContext_User_updated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_pets(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_pets(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.User().Pets(rctx, obj, fc.Args["limit"].(*int)) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*Pet) + fc.Result = res + return ec.marshalOPet2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPetᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_pets(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Pet_id(ctx, field) + case "friends": + return ec.fieldContext_Pet_friends(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Pet", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_User_pets_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _VOkCaseNil_value(ctx context.Context, field graphql.CollectedField, obj *VOkCaseNil) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VOkCaseNil_value(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_VOkCaseNil_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VOkCaseNil", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _VOkCaseValue_value(ctx context.Context, field graphql.CollectedField, obj *VOkCaseValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VOkCaseValue_value(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_VOkCaseValue_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VOkCaseValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ValidType_differentCase(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ValidType_differentCase(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ValidType_differentCase(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ValidType", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ValidType_different_case(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ValidType_different_case(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ValidType_different_case(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ValidType", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ValidType_validInputKeywords(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ValidType_validInputKeywords(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_ValidType_validInputKeywords(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ValidType", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_ValidType_validInputKeywords_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _ValidType_validArgs(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ValidType_validArgs(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) +} + +func (ec *executionContext) fieldContext_ValidType_validArgs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ValidType", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_ValidType_validArgs_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _VariadicModel_value(ctx context.Context, field graphql.CollectedField, obj *VariadicModel) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VariadicModel_value(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Value(ctx, fc.Args["rank"].(int)) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalOString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VariadicModel_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VariadicModel", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_VariadicModel_value_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _WrappedMap_get(ctx context.Context, field graphql.CollectedField, obj WrappedMap) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_WrappedMap_get(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_WrappedMap_get(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "WrappedMap", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_WrappedMap_get_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _WrappedSlice_get(ctx context.Context, field graphql.CollectedField, obj WrappedSlice) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_WrappedSlice_get(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.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) fieldContext_WrappedSlice_get(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "WrappedSlice", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_WrappedSlice_get_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _WrappedStruct_name(ctx context.Context, field graphql.CollectedField, obj *WrappedStruct) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_WrappedStruct_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋotherpkgᚐScalar(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_WrappedStruct_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "WrappedStruct", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type WrappedScalar does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _WrappedStruct_desc(ctx context.Context, field graphql.CollectedField, obj *WrappedStruct) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_WrappedStruct_desc(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋotherpkgᚐScalar(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_WrappedStruct_desc(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "WrappedStruct", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type WrappedScalar does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _XXIt_id(ctx context.Context, field graphql.CollectedField, obj *XXIt) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_XXIt_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_XXIt_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "XXIt", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _XxIt_id(ctx context.Context, field graphql.CollectedField, obj *XxIt) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_XxIt_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_XxIt_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "XxIt", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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ᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _asdfIt_id(ctx context.Context, field graphql.CollectedField, obj *AsdfIt) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_asdfIt_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_asdfIt_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "asdfIt", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _iIt_id(ctx context.Context, field graphql.CollectedField, obj *IIt) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_iIt_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_iIt_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "iIt", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputChanges(ctx context.Context, obj interface{}) (map[string]interface{}, error) { + it := make(map[string]interface{}, len(obj.(map[string]interface{}))) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"a", "b"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "a": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("a")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it["a"] = data + case "b": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("b")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it["b"] = data + } + } + + return it, nil +} + +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 + } + + fieldsInOrder := [...]string{"falsyBoolean", "truthyBoolean"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "falsyBoolean": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("falsyBoolean")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.FalsyBoolean = data + case "truthyBoolean": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("truthyBoolean")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.TruthyBoolean = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputFieldsOrderInput(ctx context.Context, obj interface{}) (FieldsOrderInput, error) { + var it FieldsOrderInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"firstField", "overrideFirstField"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "firstField": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("firstField")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.FirstField = data + case "overrideFirstField": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("overrideFirstField")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + if err = ec.resolvers.FieldsOrderInput().OverrideFirstField(ctx, &it, data); err != nil { + return it, err + } + } + } + + return it, nil +} + +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 + } + + fieldsInOrder := [...]string{"message"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "message": + 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) 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 + } + + fieldsInOrder := [...]string{"id"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalNInt2int(ctx, v) + if err != nil { + return it, err + } + it.ID = data + } + } + + 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 + } + + fieldsInOrder := [...]string{"text", "nullableText", "inner", "innerNullable", "thirdParty"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "text": + 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": + 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": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inner")) + directive0 := func(ctx context.Context) (interface{}, error) { + return ec.unmarshalNInnerDirectives2ᚖgithubᚗcomᚋniko0xdevᚋ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, 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/niko0xdev/gqlgen/codegen/testserver/singlefile.InnerDirectives`, tmp) + return it, graphql.ErrorOnPath(ctx, err) + } + case "innerNullable": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("innerNullable")) + directive0 := func(ctx context.Context) (interface{}, error) { + return ec.unmarshalOInnerDirectives2ᚖgithubᚗcomᚋniko0xdevᚋ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, 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/niko0xdev/gqlgen/codegen/testserver/singlefile.InnerDirectives`, tmp) + return it, graphql.ErrorOnPath(ctx, err) + } + case "thirdParty": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("thirdParty")) + directive0 := func(ctx context.Context) (interface{}, error) { + return ec.unmarshalOThirdParty2ᚖgithubᚗcomᚋniko0xdevᚋ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 + } + 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/niko0xdev/gqlgen/codegen/testserver/singlefile.ThirdParty`, tmp) + return it, graphql.ErrorOnPath(ctx, err) + } + } + } + + return it, nil +} + +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 + } + + fieldsInOrder := [...]string{"enum"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "enum": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("enum")) + data, err := ec.unmarshalNEnumTest2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEnumTest(ctx, v) + if err != nil { + return it, err + } + it.Enum = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputMapNestedInput(ctx context.Context, obj interface{}) (MapNested, error) { + var it MapNested + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"value"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "value": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("value")) + data, err := ec.unmarshalNCustomScalar2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCustomScalar(ctx, v) + if err != nil { + return it, err + } + it.Value = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputMapStringInterfaceInput(ctx context.Context, obj interface{}) (map[string]interface{}, error) { + it := make(map[string]interface{}, len(obj.(map[string]interface{}))) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"a", "b", "c", "nested"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "a": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("a")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it["a"] = data + case "b": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("b")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it["b"] = data + case "c": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("c")) + data, err := ec.unmarshalOCustomScalar2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCustomScalar(ctx, v) + if err != nil { + return it, err + } + it["c"] = data + case "nested": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nested")) + data, err := ec.unmarshalOMapNestedInput2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMapNested(ctx, v) + if err != nil { + return it, err + } + it["nested"] = data + } + } + + return it, nil +} + +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 + } + + fieldsInOrder := [...]string{"field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "field": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + data, err := ec.unmarshalNEmail2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEmail(ctx, v) + if err != nil { + return it, err + } + it.Field = data + } + } + + return it, nil +} + +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 + } + + fieldsInOrder := [...]string{"map"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "map": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("map")) + data, err := ec.unmarshalOMapStringInterfaceInput2map(ctx, v) + if err != nil { + return it, err + } + it.Map = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputOmittableInput(ctx context.Context, obj interface{}) (OmittableInput, error) { + var it OmittableInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"id", "bool", "str", "int", "time", "enum", "scalar", "object"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ID = graphql.OmittableOf(data) + case "bool": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("bool")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.Bool = graphql.OmittableOf(data) + case "str": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("str")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Str = graphql.OmittableOf(data) + case "int": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("int")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.Int = graphql.OmittableOf(data) + case "time": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("time")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.Time = graphql.OmittableOf(data) + case "enum": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("enum")) + data, err := ec.unmarshalOStatus2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐStatus(ctx, v) + if err != nil { + return it, err + } + it.Enum = graphql.OmittableOf(data) + case "scalar": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("scalar")) + data, err := ec.unmarshalOThirdParty2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐThirdParty(ctx, v) + if err != nil { + return it, err + } + it.Scalar = graphql.OmittableOf(data) + case "object": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("object")) + data, err := ec.unmarshalOOuterInput2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterInput(ctx, v) + if err != nil { + return it, err + } + it.Object = graphql.OmittableOf(data) + } + } + + 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 + } + + fieldsInOrder := [...]string{"inner"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "inner": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inner")) + data, err := ec.unmarshalNInnerInput2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInnerInput(ctx, v) + if err != nil { + return it, err + } + it.Inner = data + } + } + + 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 + } + + fieldsInOrder := [...]string{"self"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "self": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("self")) + data, err := ec.unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐRecursiveInputSliceᚄ(ctx, v) + if err != nil { + return it, err + } + it.Self = data + } + } + + 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 + } + + fieldsInOrder := [...]string{"nesting"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "nesting": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nesting")) + data, err := ec.unmarshalNNestedInput2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐNestedInput(ctx, v) + if err != nil { + return it, err + } + it.Nesting = data + } + } + + 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 + } + + fieldsInOrder := [...]string{"key", "value"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "key": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("key")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Key = data + case "value": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("value")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Value = data + } + } + + 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 + } + + fieldsInOrder := [...]string{"name", "inner", "stupidInner"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Name = data + case "inner": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inner")) + data, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx, v) + if err != nil { + return it, err + } + it.Inner = data + case "stupidInner": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("stupidInner")) + data, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx, v) + if err != nil { + return it, err + } + it.StupidInner = data + } + } + + return it, nil +} + +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 + } + + fieldsInOrder := [...]string{"break", "default", "func", "interface", "select", "case", "defer", "go", "map", "struct", "chan", "else", "goto", "package", "switch", "const", "fallthrough", "if", "range", "type", "continue", "for", "import", "return", "var", "_"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "break": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("break")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Break = data + case "default": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("default")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Default = data + case "func": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("func")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Func = data + case "interface": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("interface")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Interface = data + case "select": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("select")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Select = data + case "case": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("case")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Case = data + case "defer": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("defer")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Defer = data + case "go": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("go")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Go = data + case "map": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("map")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Map = data + case "struct": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("struct")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Struct = data + case "chan": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chan")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Chan = data + case "else": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("else")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Else = data + case "goto": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("goto")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Goto = data + case "package": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("package")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Package = data + case "switch": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("switch")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Switch = data + case "const": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("const")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Const = data + case "fallthrough": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fallthrough")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Fallthrough = data + case "if": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("if")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.If = data + case "range": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("range")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Range = data + case "type": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("type")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Type = data + case "continue": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("continue")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Continue = data + case "for": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("for")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.For = data + case "import": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("import")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Import = data + case "return": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("return")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Return = data + case "var": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("var")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Var = data + case "_": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("_")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Underscore = data + } + } + + return it, nil +} + +// 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 Horse: + return ec._Horse(ctx, sel, &obj) + case *Horse: + if obj == nil { + return graphql.Null + } + return ec._Horse(ctx, sel, obj) + 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) + case Mammalian: + if obj == nil { + return graphql.Null + } + return ec._Mammalian(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +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)) + } +} + +func (ec *executionContext) _Mammalian(ctx context.Context, sel ast.SelectionSet, obj Mammalian) graphql.Marshaler { + switch obj := (obj).(type) { + case nil: + return graphql.Null + case Horse: + return ec._Horse(ctx, sel, &obj) + case *Horse: + if obj == nil { + return graphql.Null + } + return ec._Horse(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)) + } +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("A") + case "id": + out.Values[i] = ec._A_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("AIt") + case "id": + out.Values[i] = ec._AIt_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("AbIt") + case "id": + out.Values[i] = ec._AbIt_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Autobind") + case "int": + out.Values[i] = ec._Autobind_int(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "int32": + out.Values[i] = ec._Autobind_int32(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "int64": + out.Values[i] = ec._Autobind_int64(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "idStr": + out.Values[i] = ec._Autobind_idStr(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "idInt": + out.Values[i] = ec._Autobind_idInt(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("B") + case "id": + out.Values[i] = ec._B_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + 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, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "thisShouldBind": + out.Values[i] = ec._BackedByInterface_thisShouldBind(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "thisShouldBindWithError": + out.Values[i] = ec._BackedByInterface_thisShouldBindWithError(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Cat") + case "species": + out.Values[i] = ec._Cat_species(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "size": + out.Values[i] = ec._Cat_size(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "catBreed": + out.Values[i] = ec._Cat_catBreed(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("CheckIssue896") + case "id": + out.Values[i] = ec._CheckIssue896_id(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Circle") + case "radius": + out.Values[i] = ec._Circle_radius(ctx, field, obj) + case "area": + out.Values[i] = ec._Circle_area(ctx, field, obj) + case "coordinates": + out.Values[i] = ec._Circle_coordinates(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ConcreteNodeA") + case "id": + out.Values[i] = ec._ConcreteNodeA_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "child": + out.Values[i] = ec._ConcreteNodeA_child(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec._ConcreteNodeA_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ConcreteNodeInterface") + case "id": + out.Values[i] = ec._ConcreteNodeInterface_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "child": + out.Values[i] = ec._ConcreteNodeInterface_child(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Content_Post") + case "foo": + out.Values[i] = ec._Content_Post_foo(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Content_User") + case "foo": + out.Values[i] = ec._Content_User_foo(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Coordinates") + case "x": + out.Values[i] = ec._Coordinates_x(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "y": + out.Values[i] = ec._Coordinates_y(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("DefaultParametersMirror") + case "falsyBoolean": + out.Values[i] = ec._DefaultParametersMirror_falsyBoolean(ctx, field, obj) + case "truthyBoolean": + out.Values[i] = ec._DefaultParametersMirror_truthyBoolean(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var deferModelImplementors = []string{"DeferModel"} + +func (ec *executionContext) _DeferModel(ctx context.Context, sel ast.SelectionSet, obj *DeferModel) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, deferModelImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("DeferModel") + case "id": + out.Values[i] = ec._DeferModel_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "name": + out.Values[i] = ec._DeferModel_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "values": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._DeferModel_values(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Dog") + case "species": + out.Values[i] = ec._Dog_species(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "size": + out.Values[i] = ec._Dog_size(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "dogBreed": + out.Values[i] = ec._Dog_dogBreed(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("EmbeddedCase1") + case "exportedEmbeddedPointerExportedMethod": + out.Values[i] = ec._EmbeddedCase1_exportedEmbeddedPointerExportedMethod(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("EmbeddedCase2") + case "unexportedEmbeddedPointerExportedMethod": + out.Values[i] = ec._EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("EmbeddedCase3") + case "unexportedEmbeddedInterfaceExportedMethod": + out.Values[i] = ec._EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("EmbeddedDefaultScalar") + case "value": + out.Values[i] = ec._EmbeddedDefaultScalar_value(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("EmbeddedPointer") + case "ID": + out.Values[i] = ec._EmbeddedPointer_ID(ctx, field, obj) + case "Title": + out.Values[i] = ec._EmbeddedPointer_Title(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Error") + case "id": + out.Values[i] = ec._Error_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "errorOnNonRequiredField": + out.Values[i] = ec._Error_errorOnNonRequiredField(ctx, field, obj) + case "errorOnRequiredField": + out.Values[i] = ec._Error_errorOnRequiredField(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "nilOnRequiredField": + out.Values[i] = ec._Error_nilOnRequiredField(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "b": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "c": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "d": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "e": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var fieldsOrderPayloadImplementors = []string{"FieldsOrderPayload"} + +func (ec *executionContext) _FieldsOrderPayload(ctx context.Context, sel ast.SelectionSet, obj *FieldsOrderPayload) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, fieldsOrderPayloadImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("FieldsOrderPayload") + case "firstFieldValue": + out.Values[i] = ec._FieldsOrderPayload_firstFieldValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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, fs *graphql.FieldSet) (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 + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var horseImplementors = []string{"Horse", "Mammalian", "Animal"} + +func (ec *executionContext) _Horse(ctx context.Context, sel ast.SelectionSet, obj *Horse) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, horseImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Horse") + case "species": + out.Values[i] = ec._Horse_species(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "size": + out.Values[i] = ec._Horse_size(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "horseBreed": + out.Values[i] = ec._Horse_horseBreed(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("InnerObject") + case "id": + out.Values[i] = ec._InnerObject_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("InvalidIdentifier") + case "id": + out.Values[i] = ec._InvalidIdentifier_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("It") + case "id": + out.Values[i] = ec._It_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("LoopA") + case "b": + out.Values[i] = ec._LoopA_b(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("LoopB") + case "a": + out.Values[i] = ec._LoopB_a(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Map") + case "id": + out.Values[i] = ec._Map_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var mapNestedImplementors = []string{"MapNested"} + +func (ec *executionContext) _MapNested(ctx context.Context, sel ast.SelectionSet, obj *MapNested) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, mapNestedImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("MapNested") + case "value": + out.Values[i] = ec._MapNested_value(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("MapStringInterfaceType") + case "a": + out.Values[i] = ec._MapStringInterfaceType_a(ctx, field, obj) + case "b": + out.Values[i] = ec._MapStringInterfaceType_b(ctx, field, obj) + case "c": + out.Values[i] = ec._MapStringInterfaceType_c(ctx, field, obj) + case "nested": + out.Values[i] = ec._MapStringInterfaceType_nested(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "noContext": + out.Values[i] = ec._ModelMethods_noContext(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "withContext": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_defaultInput(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "overrideValueViaInput": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_overrideValueViaInput(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "updateSomething": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_updateSomething(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "updatePtrToPtr": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_updatePtrToPtr(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ObjectDirectives") + case "text": + out.Values[i] = ec._ObjectDirectives_text(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "nullableText": + out.Values[i] = ec._ObjectDirectives_nullableText(ctx, field, obj) + case "order": + out.Values[i] = ec._ObjectDirectives_order(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ObjectDirectivesWithCustomGoModel") + case "nullableText": + out.Values[i] = ec._ObjectDirectivesWithCustomGoModel_nullableText(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("OuterObject") + case "inner": + out.Values[i] = ec._OuterObject_inner(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("OverlappingFields") + case "oneFoo": + out.Values[i] = ec._OverlappingFields_oneFoo(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "twoFoo": + out.Values[i] = ec._OverlappingFields_twoFoo(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "oldFoo": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "newFoo": + out.Values[i] = ec._OverlappingFields_newFoo(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "new_foo": + out.Values[i] = ec._OverlappingFields_new_foo(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + 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, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "fieldFuncMarshal": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "argUnmarshal": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var petImplementors = []string{"Pet"} + +func (ec *executionContext) _Pet(ctx context.Context, sel ast.SelectionSet, obj *Pet) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, petImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Pet") + case "id": + out.Values[i] = ec._Pet_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "friends": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Pet_friends(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + 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, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "squared": + out.Values[i] = ec._Primitive_squared(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "doubled": + out.Values[i] = ec._PrimitiveString_doubled(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "len": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var ptrToAnyContainerImplementors = []string{"PtrToAnyContainer"} + +func (ec *executionContext) _PtrToAnyContainer(ctx context.Context, sel ast.SelectionSet, obj *PtrToAnyContainer) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, ptrToAnyContainerImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("PtrToAnyContainer") + case "ptrToAny": + out.Values[i] = ec._PtrToAnyContainer_ptrToAny(ctx, field, obj) + case "binding": + out.Values[i] = ec._PtrToAnyContainer_binding(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("PtrToPtrInner") + case "key": + out.Values[i] = ec._PtrToPtrInner_key(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "value": + out.Values[i] = ec._PtrToPtrInner_value(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("PtrToPtrOuter") + case "name": + out.Values[i] = ec._PtrToPtrOuter_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "inner": + out.Values[i] = ec._PtrToPtrOuter_inner(ctx, field, obj) + case "stupidInner": + out.Values[i] = ec._PtrToPtrOuter_stupidInner(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("PtrToSliceContainer") + case "ptrToSlice": + out.Values[i] = ec._PtrToSliceContainer_ptrToSlice(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "collision": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "mapInput": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "recursive": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "nestedInputs": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "nestedOutputs": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "modelMethods": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "user": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "nullableArg": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "inputSlice": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "inputNullableSlice": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "inputOmittable": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_inputOmittable(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "shapeUnion": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "autobind": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "deprecatedField": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "overlapping": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "defaultParameters": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "deferCase1": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_deferCase1(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "deferCase2": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_deferCase2(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "directiveArg": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "directiveNullableArg": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "directiveInputNullable": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "directiveInput": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "directiveInputType": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "directiveObject": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "directiveObjectWithCustomGoModel": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "directiveFieldDef": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "directiveField": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "directiveDouble": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "directiveUnimplemented": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "embeddedCase1": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "embeddedCase2": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "embeddedCase3": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "enumInInput": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "shapes": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "noShape": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "node": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "noShapeTypedNil": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "animal": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "notAnInterface": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "dog": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_dog(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "issue896a": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "mapStringInterface": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "mapNestedStringInterface": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "errorBubble": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "errorBubbleList": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "errorList": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "errors": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "valid": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "invalid": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_invalid(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "panics": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "primitiveObject": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "primitiveStringObject": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "ptrToAnyContainer": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_ptrToAnyContainer(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "ptrToSliceContainer": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "infinity": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "stringFromContextInterface": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "stringFromContextFunction": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "defaultScalar": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "slices": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "scalarSlice": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "fallback": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "optionalUnion": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "vOkCaseValue": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "vOkCaseNil": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "validType": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "variadicModel": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_variadicModel(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "wrappedStruct": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "wrappedScalar": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "wrappedMap": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "wrappedSlice": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Rectangle") + case "length": + out.Values[i] = ec._Rectangle_length(ctx, field, obj) + case "width": + out.Values[i] = ec._Rectangle_width(ctx, field, obj) + case "area": + out.Values[i] = ec._Rectangle_area(ctx, field, obj) + case "coordinates": + out.Values[i] = ec._Rectangle_coordinates(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var sizeImplementors = []string{"Size"} + +func (ec *executionContext) _Size(ctx context.Context, sel ast.SelectionSet, obj *Size) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, sizeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Size") + case "height": + out.Values[i] = ec._Size_height(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "weight": + out.Values[i] = ec._Size_weight(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Slices") + case "test1": + out.Values[i] = ec._Slices_test1(ctx, field, obj) + case "test2": + out.Values[i] = ec._Slices_test2(ctx, field, obj) + case "test3": + out.Values[i] = ec._Slices_test3(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "test4": + out.Values[i] = ec._Slices_test4(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var subscriptionImplementors = []string{"Subscription"} + +func (ec *executionContext) _Subscription(ctx context.Context, sel ast.SelectionSet) func(ctx context.Context) 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]) + case "errorRequired": + return ec._Subscription_errorRequired(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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("User") + case "id": + out.Values[i] = ec._User_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "friends": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "created": + out.Values[i] = ec._User_created(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "updated": + out.Values[i] = ec._User_updated(ctx, field, obj) + case "pets": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._User_pets(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("VOkCaseNil") + case "value": + out.Values[i] = ec._VOkCaseNil_value(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("VOkCaseValue") + case "value": + out.Values[i] = ec._VOkCaseValue_value(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ValidType") + case "differentCase": + out.Values[i] = ec._ValidType_differentCase(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "different_case": + out.Values[i] = ec._ValidType_different_case(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "validInputKeywords": + out.Values[i] = ec._ValidType_validInputKeywords(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "validArgs": + out.Values[i] = ec._ValidType_validArgs(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var variadicModelImplementors = []string{"VariadicModel"} + +func (ec *executionContext) _VariadicModel(ctx context.Context, sel ast.SelectionSet, obj *VariadicModel) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, variadicModelImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("VariadicModel") + case "value": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._VariadicModel_value(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + 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, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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, fs *graphql.FieldSet) (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(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("WrappedStruct") + case "name": + out.Values[i] = ec._WrappedStruct_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "desc": + out.Values[i] = ec._WrappedStruct_desc(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("XXIt") + case "id": + out.Values[i] = ec._XXIt_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("XxIt") + case "id": + out.Values[i] = ec._XxIt_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("asdfIt") + case "id": + out.Values[i] = ec._asdfIt_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("iIt") + case "id": + out.Values[i] = ec._iIt_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + res := MarshalBytes(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNCheckIssue8962ᚖgithubᚗcomᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._CheckIssue896(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNCustomScalar2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCustomScalar(ctx context.Context, v interface{}) (CustomScalar, error) { + var res CustomScalar + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNCustomScalar2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCustomScalar(ctx context.Context, sel ast.SelectionSet, v CustomScalar) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalNDefaultInput2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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) +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNDeferModel2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDeferModel(ctx context.Context, sel ast.SelectionSet, v *DeferModel) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._DeferModel(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNEmail2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEmail(ctx context.Context, sel ast.SelectionSet, v Email) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalNEnumTest2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEnumTest(ctx context.Context, sel ast.SelectionSet, v EnumTest) graphql.Marshaler { + return v +} + +func (ec *executionContext) marshalNError2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Error(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNFallbackToStringEncoding2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNFieldsOrderInput2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐFieldsOrderInput(ctx context.Context, v interface{}) (FieldsOrderInput, error) { + res, err := ec.unmarshalInputFieldsOrderInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNFieldsOrderPayload2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐFieldsOrderPayload(ctx context.Context, sel ast.SelectionSet, v FieldsOrderPayload) graphql.Marshaler { + return ec._FieldsOrderPayload(ctx, sel, &v) +} + +func (ec *executionContext) marshalNFieldsOrderPayload2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐFieldsOrderPayload(ctx context.Context, sel ast.SelectionSet, v *FieldsOrderPayload) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._FieldsOrderPayload(ctx, sel, v) +} + +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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNInnerDirectives2ᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._InnerObject(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNInputDirectives2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInputDirectives(ctx context.Context, v interface{}) (InputDirectives, error) { + res, err := ec.unmarshalInputInputDirectives(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNLoopA2ᚖgithubᚗcomᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._LoopA(ctx, sel, v) +} + +func (ec *executionContext) marshalNLoopB2ᚖgithubᚗcomᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._LoopB(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNMarshalPanic2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanic(ctx context.Context, sel ast.SelectionSet, v MarshalPanic) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalNMarshalPanic2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanicᚄ(ctx context.Context, v interface{}) ([]MarshalPanic, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanic(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalNMarshalPanic2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Node(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNOmittableInput2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOmittableInput(ctx context.Context, v interface{}) (OmittableInput, error) { + res, err := ec.unmarshalInputOmittableInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNPet2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPet(ctx context.Context, sel ast.SelectionSet, v *Pet) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Pet(ctx, sel, v) +} + +func (ec *executionContext) marshalNPrimitive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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 + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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 + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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 +} + +func (ec *executionContext) marshalNPtrToAnyContainer2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToAnyContainer(ctx context.Context, sel ast.SelectionSet, v PtrToAnyContainer) graphql.Marshaler { + return ec._PtrToAnyContainer(ctx, sel, &v) +} + +func (ec *executionContext) marshalNPtrToAnyContainer2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToAnyContainer(ctx context.Context, sel ast.SelectionSet, v *PtrToAnyContainer) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._PtrToAnyContainer(ctx, sel, v) +} + +func (ec *executionContext) marshalNPtrToPtrOuter2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._PtrToPtrOuter(ctx, sel, v) +} + +func (ec *executionContext) marshalNPtrToSliceContainer2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._PtrToSliceContainer(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNRecursiveInputSlice2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._ShapeUnion(ctx, sel, v) +} + +func (ec *executionContext) marshalNSize2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐSize(ctx context.Context, sel ast.SelectionSet, v *Size) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Size(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNSpecialInput2githubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐSpecialInput(ctx context.Context, v interface{}) (SpecialInput, error) { + res, err := ec.unmarshalInputSpecialInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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 { + vSlice = graphql.CoerceList(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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + res := graphql.MarshalString(*v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + return graphql.WrapContextMarshaler(ctx, res) +} + +func (ec *executionContext) unmarshalNStringFromContextInterface2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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) +} + +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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNUpdatePtrToPtrOuter2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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 + 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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._User(ctx, sel, v) +} + +func (ec *executionContext) marshalNWrappedMap2githubᚗcomᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._WrappedMap(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNWrappedScalar2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNWrappedSlice2githubᚗcomᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._WrappedSlice(ctx, sel, v) +} + +func (ec *executionContext) marshalNWrappedStruct2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._WrappedStruct(ctx, sel, v) +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalOAnimal2githubᚗcomᚋniko0xdevᚋ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) unmarshalOAny2interface(ctx context.Context, v interface{}) (any, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalAny(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOAny2interface(ctx context.Context, sel ast.SelectionSet, v any) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := graphql.MarshalAny(v) + return res +} + +func (ec *executionContext) unmarshalOAny2ᚖinterface(ctx context.Context, v interface{}) (*any, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOAny2interface(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOAny2ᚖinterface(ctx context.Context, sel ast.SelectionSet, v *any) graphql.Marshaler { + return ec.marshalOAny2interface(ctx, sel, *v) +} + +func (ec *executionContext) marshalOAutobind2ᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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) 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) unmarshalOChanges2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputChanges(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCheckIssue896(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCoordinates(ctx context.Context, sel ast.SelectionSet, v Coordinates) graphql.Marshaler { + return ec._Coordinates(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalOCustomScalar2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCustomScalar(ctx context.Context, v interface{}) (*CustomScalar, error) { + if v == nil { + return nil, nil + } + var res = new(CustomScalar) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOCustomScalar2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCustomScalar(ctx context.Context, sel ast.SelectionSet, v *CustomScalar) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +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 +} + +func (ec *executionContext) marshalODeferModel2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDeferModelᚄ(ctx context.Context, sel ast.SelectionSet, v []*DeferModel) 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.marshalNDeferModel2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDeferModel(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) marshalODeferModel2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDeferModel(ctx context.Context, sel ast.SelectionSet, v *DeferModel) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._DeferModel(ctx, sel, v) +} + +func (ec *executionContext) marshalODog2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDog(ctx context.Context, sel ast.SelectionSet, v *Dog) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Dog(ctx, sel, v) +} + +func (ec *executionContext) marshalOEmbeddedCase12ᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐErrors(ctx context.Context, sel ast.SelectionSet, v *Errors) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Errors(ctx, sel, v) +} + +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) unmarshalOID2ᚖstring(ctx context.Context, v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalID(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOID2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := graphql.MarshalID(*v) + return res +} + +func (ec *executionContext) unmarshalOInnerDirectives2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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) unmarshalOInputWithEnumValue2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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) +} + +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) marshalOInvalidIdentifier2ᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋ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) marshalOMapNested2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMapNested(ctx context.Context, sel ast.SelectionSet, v *MapNested) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._MapNested(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOMapNestedInput2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMapNested(ctx context.Context, v interface{}) (*MapNested, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMapNestedInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalOMapStringInterfaceInput2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMapStringInterfaceInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +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) marshalOModelMethods2ᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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) +} + +func (ec *executionContext) marshalOObjectDirectives2ᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterInput(ctx context.Context, v interface{}) ([][]*OuterInput, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOOuterInput2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterInput(ctx context.Context, v interface{}) ([]*OuterInput, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOOuterInput2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterObject(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) marshalOOuterObject2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterObject(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) marshalOOuterObject2ᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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) marshalOPet2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPetᚄ(ctx context.Context, sel ast.SelectionSet, v []*Pet) 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.marshalNPet2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPet(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) marshalOPtrToPtrInner2ᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx, sel, *v) +} + +func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx, sel, *v) +} + +func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx, sel, *v) +} + +func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx, sel, *v) +} + +func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx, sel, *v) +} + +func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx, sel, *v) +} + +func (ec *executionContext) unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐRecursiveInputSliceᚄ(ctx context.Context, v interface{}) ([]RecursiveInputSlice, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐRecursiveInputSlice(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalORecursiveInputSlice2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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) marshalOShape2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐShape(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) marshalOSlices2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐSlices(ctx context.Context, sel ast.SelectionSet, v *Slices) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Slices(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOStatus2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐStatus(ctx context.Context, v interface{}) (*Status, error) { + if v == nil { + return nil, nil + } + var res = new(Status) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOStatus2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐStatus(ctx context.Context, sel ast.SelectionSet, v *Status) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +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 { + vSlice = graphql.CoerceList(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 { + vSlice = graphql.CoerceList(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) marshalOTestUnion2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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 +} + +func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (**UpdatePtrToPtrInner, error) { + var pres *UpdatePtrToPtrInner + if v != nil { + res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (***UpdatePtrToPtrInner, error) { + var pres **UpdatePtrToPtrInner + if v != nil { + res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (****UpdatePtrToPtrInner, error) { + var pres ***UpdatePtrToPtrInner + if v != nil { + res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (*****UpdatePtrToPtrInner, error) { + var pres ****UpdatePtrToPtrInner + if v != nil { + res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (******UpdatePtrToPtrInner, error) { + var pres *****UpdatePtrToPtrInner + if v != nil { + res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (*******UpdatePtrToPtrInner, error) { + var pres ******UpdatePtrToPtrInner + if v != nil { + res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx context.Context, v interface{}) (********UpdatePtrToPtrInner, error) { + var pres *******UpdatePtrToPtrInner + if v != nil { + res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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ᚋniko0xdevᚋ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) marshalOVariadicModel2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐVariadicModel(ctx context.Context, sel ast.SelectionSet, v *VariadicModel) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._VariadicModel(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOWrappedScalar2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋ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ᚋniko0xdevᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋ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 +} + +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/singlefile/generated_test.go b/codegen/testserver/singlefile/generated_test.go new file mode 100644 index 0000000..91509f1 --- /dev/null +++ b/codegen/testserver/singlefile/generated_test.go @@ -0,0 +1,81 @@ +//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/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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 0000000..e9f5caa --- /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/niko0xdev/gqlgen/codegen/testserver" + - "github.com/niko0xdev/gqlgen/codegen/testserver/singlefile" + - "github.com/niko0xdev/gqlgen/codegen/testserver/singlefile/introspection" + - "github.com/niko0xdev/gqlgen/codegen/testserver/singlefile/invalid-packagename" + +models: + Email: + model: "github.com/niko0xdev/gqlgen/codegen/testserver/singlefile.Email" + StringFromContextFunction: + model: "github.com/niko0xdev/gqlgen/codegen/testserver/singlefile.StringFromContextFunction" diff --git a/codegen/testserver/singlefile/input_test.go b/codegen/testserver/singlefile/input_test.go new file mode 100644 index 0000000..f75b5ba --- /dev/null +++ b/codegen/testserver/singlefile/input_test.go @@ -0,0 +1,342 @@ +package singlefile + +import ( + "context" + "strconv" + "testing" + "time" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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":"String cannot represent a non string value: 1","locations":[{"line":1,"column":32}],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}},{"message":"String cannot represent a non string value: 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) + }) +} + +func TestInputOmittable(t *testing.T) { + resolvers := &Stub{} + srv := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})) + c := client.New(srv) + + t.Run("id field", func(t *testing.T) { + resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { + value, isSet := arg.ID.ValueOK() + if !isSet { + return "", nil + } + + if value == nil { + return "", nil + } + + return *value, nil + } + + var resp struct { + InputOmittable string + } + var err error + + err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { id: null }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { id: "foo" }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "foo", resp.InputOmittable) + }) + + t.Run("bool field", func(t *testing.T) { + resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { + value, isSet := arg.Bool.ValueOK() + if !isSet { + return "", nil + } + + if value == nil { + return "", nil + } + + return strconv.FormatBool(*value), nil + } + + var resp struct { + InputOmittable string + } + var err error + + err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { bool: null }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { bool: false }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "false", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { bool: true }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "true", resp.InputOmittable) + }) + + t.Run("str field", func(t *testing.T) { + resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { + value, isSet := arg.Str.ValueOK() + if !isSet { + return "", nil + } + + if value == nil { + return "", nil + } + + return *value, nil + } + + var resp struct { + InputOmittable string + } + var err error + + err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { str: null }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { str: "bar" }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "bar", resp.InputOmittable) + }) + + t.Run("int field", func(t *testing.T) { + resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { + value, isSet := arg.Int.ValueOK() + if !isSet { + return "", nil + } + + if value == nil { + return "", nil + } + + return strconv.Itoa(*value), nil + } + + var resp struct { + InputOmittable string + } + var err error + + err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { int: null }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { int: 42 }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "42", resp.InputOmittable) + }) + + t.Run("time field", func(t *testing.T) { + resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { + value, isSet := arg.Time.ValueOK() + if !isSet { + return "", nil + } + + if value == nil { + return "", nil + } + + return value.UTC().Format(time.RFC3339), nil + } + + var resp struct { + InputOmittable string + } + var err error + + err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { time: null }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { time: "2011-04-05T16:01:33Z" }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "2011-04-05T16:01:33Z", resp.InputOmittable) + }) + + t.Run("enum field", func(t *testing.T) { + resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { + value, isSet := arg.Enum.ValueOK() + if !isSet { + return "", nil + } + + if value == nil { + return "", nil + } + + return value.String(), nil + } + + var resp struct { + InputOmittable string + } + var err error + + err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { enum: null }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { enum: OK }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "OK", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { enum: ERROR }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "ERROR", resp.InputOmittable) + }) + + t.Run("scalar field", func(t *testing.T) { + resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { + value, isSet := arg.Scalar.ValueOK() + if !isSet { + return "", nil + } + + if value == nil { + return "", nil + } + + return value.str, nil + } + + var resp struct { + InputOmittable string + } + var err error + + err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { scalar: null }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { scalar: "baz" }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "baz", resp.InputOmittable) + }) + + t.Run("object field", func(t *testing.T) { + resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { + value, isSet := arg.Object.ValueOK() + if !isSet { + return "", nil + } + + if value == nil { + return "", nil + } + + return strconv.Itoa(value.Inner.ID), nil + } + + var resp struct { + InputOmittable string + } + var err error + + err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { object: null }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "", resp.InputOmittable) + + err = c.Post(`query { inputOmittable(arg: { object: { inner: { id: 21 } } }) }`, &resp) + require.NoError(t, err) + require.Equal(t, "21", resp.InputOmittable) + }) +} diff --git a/codegen/testserver/singlefile/interfaces.go b/codegen/testserver/singlefile/interfaces.go new file mode 100644 index 0000000..afb1084 --- /dev/null +++ b/codegen/testserver/singlefile/interfaces.go @@ -0,0 +1,87 @@ +package singlefile + +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/singlefile/interfaces.graphql b/codegen/testserver/singlefile/interfaces.graphql new file mode 100644 index 0000000..ae9be8c --- /dev/null +++ b/codegen/testserver/singlefile/interfaces.graphql @@ -0,0 +1,91 @@ +extend type Query { + shapes: [Shape] + noShape: Shape @makeNil + node: Node! + noShapeTypedNil: Shape @makeTypedNil + animal: Animal @makeTypedNil + notAnInterface: BackedByInterface + dog: Dog +} + +interface Animal { + species: String! + size: Size! +} + +type Size { + height: Int! + weight: Int! +} + +type BackedByInterface { + id: String! + thisShouldBind: String! + thisShouldBindWithError: String! +} + +type Dog implements Animal { + species: String! + size: Size! + dogBreed: String! +} + +type Cat implements Animal { + species: String! + size: Size! + 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: "singlefile.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! +} + +interface Mammalian implements Animal { + species: String! + size: Size! +} + +# Types with multiple interfaces are evaluated first in the case statement +type Horse implements Mammalian & Animal { + species: String! + size: Size! + horseBreed: String! +} diff --git a/codegen/testserver/singlefile/interfaces_test.go b/codegen/testserver/singlefile/interfaces_test.go new file mode 100644 index 0000000..2c82d76 --- /dev/null +++ b/codegen/testserver/singlefile/interfaces_test.go @@ -0,0 +1,298 @@ +package singlefile + +import ( + "context" + "fmt" + "reflect" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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, "[]singlefile.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) + }) + + t.Run("fragment on interface must return merged fields", func(t *testing.T) { + resolvers := &Stub{} + resolvers.QueryResolver.Dog = func(ctx context.Context) (dog *Dog, err error) { + return &Dog{ + Size: &Size{ + Height: 100, + Weight: 35, + }, + }, nil + } + + c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))) + var resp struct { + Dog struct { + Size struct { + Height int + Weight int + } + } + } + + c.MustPost(` + { + dog { + size { + height + } + ...AnimalWeight + } + } + fragment AnimalWeight on Animal { + size { + weight + } + } + `, &resp) + + require.Equal(t, 100, resp.Dog.Size.Height) + require.Equal(t, 35, resp.Dog.Size.Weight) + }) +} diff --git a/codegen/testserver/singlefile/introspection/it.go b/codegen/testserver/singlefile/introspection/it.go new file mode 100644 index 0000000..e184968 --- /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/singlefile/introspection_test.go b/codegen/testserver/singlefile/introspection_test.go new file mode 100644 index 0000000..f4f4f97 --- /dev/null +++ b/codegen/testserver/singlefile/introspection_test.go @@ -0,0 +1,80 @@ +package singlefile + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" + "github.com/niko0xdev/gqlgen/graphql/introspection" +) + +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/singlefile/invalid-packagename/invalid-identifier.go b/codegen/testserver/singlefile/invalid-packagename/invalid-identifier.go new file mode 100644 index 0000000..fe0feb7 --- /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 0000000..4cfe79e --- /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/niko0xdev/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 0000000..0254ef4 --- /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.go b/codegen/testserver/singlefile/maps.go new file mode 100644 index 0000000..5836627 --- /dev/null +++ b/codegen/testserver/singlefile/maps.go @@ -0,0 +1,28 @@ +package singlefile + +import ( + "io" + "strconv" +) + +type MapNested struct { + Value CustomScalar +} + +type CustomScalar struct { + value int64 +} + +func (s *CustomScalar) UnmarshalGQL(v interface{}) (err error) { + switch v := v.(type) { + case string: + s.value, err = strconv.ParseInt(v, 10, 64) + case int64: + s.value = v + } + return +} + +func (s CustomScalar) MarshalGQL(w io.Writer) { + _, _ = w.Write([]byte(strconv.Quote(strconv.FormatInt(s.value, 10)))) +} diff --git a/codegen/testserver/singlefile/maps.graphql b/codegen/testserver/singlefile/maps.graphql new file mode 100644 index 0000000..38205ad --- /dev/null +++ b/codegen/testserver/singlefile/maps.graphql @@ -0,0 +1,32 @@ +extend type Query { + mapStringInterface(in: MapStringInterfaceInput): MapStringInterfaceType + mapNestedStringInterface(in: NestedMapInput): MapStringInterfaceType +} + +type MapStringInterfaceType @goModel(model: "map[string]interface{}") { + a: String + b: Int + c: CustomScalar + nested: MapNested +} + +type MapNested @goModel(model: "singlefile.MapNested") { + value: CustomScalar! +} + +input MapStringInterfaceInput @goModel(model: "map[string]interface{}") { + a: String! + b: Int + c: CustomScalar + nested: MapNestedInput +} + +input MapNestedInput @goModel(model: "singlefile.MapNested") { + value: CustomScalar! +} + +scalar CustomScalar @goModel(model: "singlefile.CustomScalar") + +input NestedMapInput { + map: MapStringInterfaceInput +} diff --git a/codegen/testserver/singlefile/maps_test.go b/codegen/testserver/singlefile/maps_test.go new file mode 100644 index 0000000..893c538 --- /dev/null +++ b/codegen/testserver/singlefile/maps_test.go @@ -0,0 +1,101 @@ +package singlefile + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +func TestMaps(t *testing.T) { + resolver := &Stub{} + resolver.QueryResolver.MapStringInterface = func(ctx context.Context, in map[string]interface{}) (i map[string]interface{}, e error) { + validateMapItemsType(t, in) + return in, nil + } + resolver.QueryResolver.MapNestedStringInterface = func(ctx context.Context, in *NestedMapInput) (i map[string]interface{}, e error) { + if in == nil { + return nil, nil + } + validateMapItemsType(t, in.Map) + 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, c, nested { value } } }`, &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, c, nested { value } } }`, &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($value: CustomScalar!) { mapStringInterface(in: { a: "a", b: null, c: 42, nested: { value: $value } }) { a, b, c, nested { value } } }`, &resp, client.Var("value", "17")) + require.NoError(t, err) + require.Equal(t, "a", resp.MapStringInterface["a"]) + require.Nil(t, resp.MapStringInterface["b"]) + require.Equal(t, "42", resp.MapStringInterface["c"]) + require.NotNil(t, resp.MapStringInterface["nested"]) + require.IsType(t, map[string]interface{}{}, resp.MapStringInterface["nested"]) + require.Equal(t, "17", (resp.MapStringInterface["nested"].(map[string]interface{}))["value"]) + }) + + t.Run("nested", func(t *testing.T) { + var resp struct { + MapNestedStringInterface map[string]interface{} + } + err := c.Post(`query { mapNestedStringInterface(in: { map: { a: "a", c: "42", nested: { value: 31 } } }) { a, b, c, nested { value } } }`, &resp) + require.NoError(t, err) + require.Equal(t, "a", resp.MapNestedStringInterface["a"]) + require.Nil(t, resp.MapNestedStringInterface["b"]) + require.Equal(t, "42", resp.MapNestedStringInterface["c"]) + require.NotNil(t, resp.MapNestedStringInterface["nested"]) + require.IsType(t, map[string]interface{}{}, resp.MapNestedStringInterface["nested"]) + require.Equal(t, "31", (resp.MapNestedStringInterface["nested"].(map[string]interface{}))["value"]) + }) + + 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, c, nested { value } } }`, &resp) + require.NoError(t, err) + require.Nil(t, resp.MapNestedStringInterface) + }) +} + +func validateMapItemsType(t *testing.T, in map[string]interface{}) { + for k, v := range in { + switch k { + case "a": + require.IsType(t, "", v) + case "b": + require.IsType(t, new(int), v) + case "c": + require.IsType(t, new(CustomScalar), v) + case "nested": + require.IsType(t, new(MapNested), v) + default: + require.Failf(t, "unexpected key in map", "key %q was not expected in map", k) + } + } +} diff --git a/codegen/testserver/singlefile/middleware_test.go b/codegen/testserver/singlefile/middleware_test.go new file mode 100644 index 0000000..2ec7266 --- /dev/null +++ b/codegen/testserver/singlefile/middleware_test.go @@ -0,0 +1,152 @@ +package singlefile + +import ( + "context" + "sync" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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.UserResolver.Pets = func(ctx context.Context, obj *User, limit *int) ([]*Pet, error) { + return []*Pet{{ID: 10}}, nil + } + + resolvers.PetResolver.Friends = func(ctx context.Context, obj *Pet, limit *int) ([]*Pet, error) { + return []*Pet{}, 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) + }) + + srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + fc := graphql.GetFieldContext(ctx) + if fc.Field.Name != "user" { + return next(ctx) + } + opCtx := graphql.GetOperationContext(ctx) + collected := graphql.CollectFields(opCtx, fc.Field.Selections, []string{"User"}) + require.Len(t, collected, 3) + require.Equal(t, "pets", collected[2].Name) + child, err := fc.Child(ctx, collected[2]) + require.NoError(t, err) + require.Equal(t, 2, *child.Args["limit"].(*int)) + collected = graphql.CollectFields(opCtx, child.Field.Selections, []string{"Pet"}) + require.Len(t, collected, 2) + require.Equal(t, "friends", collected[1].Name) + child, err = child.Child(ctx, collected[1]) + require.NoError(t, err) + require.Equal(t, 10, *child.Args["limit"].(*int)) + return next(ctx) + }) + + c := client.New(srv) + + var resp struct { + User struct { + ID int + Friends []struct { + ID int + } + Pets []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 + } + pets (limit: 2) { + id + friends(limit: 10) { + id + } + } + } + modelMethods { + noContext + } + }`, &resp) + + assert.Equal(t, map[string]bool{ + "user": true, + "pets": true, + "id": false, + "friends": true, + "modelMethods": true, + "noContext": true, + }, areMethods) + assert.Equal(t, map[string]bool{ + "user": true, + "pets": true, + "id": false, + "friends": true, + "modelMethods": true, + "noContext": false, + }, areResolvers) + + require.NoError(t, err) + require.True(t, called) +} diff --git a/codegen/testserver/singlefile/modelmethod_test.go b/codegen/testserver/singlefile/modelmethod_test.go new file mode 100644 index 0000000..f823a26 --- /dev/null +++ b/codegen/testserver/singlefile/modelmethod_test.go @@ -0,0 +1,45 @@ +package singlefile + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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/singlefile/models-gen.go b/codegen/testserver/singlefile/models-gen.go new file mode 100644 index 0000000..02b96ef --- /dev/null +++ b/codegen/testserver/singlefile/models-gen.go @@ -0,0 +1,374 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package singlefile + +import ( + "fmt" + "io" + "strconv" + "time" + + "github.com/niko0xdev/gqlgen/graphql" +) + +type Animal interface { + IsAnimal() + GetSpecies() string + GetSize() *Size +} + +type ContentChild interface { + IsContentChild() +} + +type Mammalian interface { + IsAnimal() + IsMammalian() + GetSpecies() string + GetSize() *Size +} + +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"` + Size *Size `json:"size"` + CatBreed string `json:"catBreed"` +} + +func (Cat) IsAnimal() {} +func (this Cat) GetSpecies() string { return this.Species } +func (this Cat) GetSize() *Size { return this.Size } + +type CheckIssue896 struct { + ID *int `json:"id,omitempty"` +} + +type ContentPost struct { + Foo *string `json:"foo,omitempty"` +} + +func (ContentPost) IsContentChild() {} + +type ContentUser struct { + Foo *string `json:"foo,omitempty"` +} + +func (ContentUser) IsContentChild() {} + +type Coordinates struct { + X float64 `json:"x"` + Y float64 `json:"y"` +} + +type DefaultInput struct { + FalsyBoolean *bool `json:"falsyBoolean,omitempty"` + TruthyBoolean *bool `json:"truthyBoolean,omitempty"` +} + +type DefaultParametersMirror struct { + FalsyBoolean *bool `json:"falsyBoolean,omitempty"` + TruthyBoolean *bool `json:"truthyBoolean,omitempty"` +} + +type DeferModel struct { + ID string `json:"id"` + Name string `json:"name"` + Values []string `json:"values"` +} + +type Dog struct { + Species string `json:"species"` + Size *Size `json:"size"` + DogBreed string `json:"dogBreed"` +} + +func (Dog) IsAnimal() {} +func (this Dog) GetSpecies() string { return this.Species } +func (this Dog) GetSize() *Size { return this.Size } + +type EmbeddedDefaultScalar struct { + Value *string `json:"value,omitempty"` +} + +type FieldsOrderPayload struct { + FirstFieldValue *string `json:"firstFieldValue,omitempty"` +} + +type Horse struct { + Species string `json:"species"` + Size *Size `json:"size"` + HorseBreed string `json:"horseBreed"` +} + +func (Horse) IsMammalian() {} +func (this Horse) GetSpecies() string { return this.Species } +func (this Horse) GetSize() *Size { return this.Size } + +func (Horse) IsAnimal() {} + +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,omitempty"` + Inner *InnerDirectives `json:"inner"` + InnerNullable *InnerDirectives `json:"innerNullable,omitempty"` + ThirdParty *ThirdParty `json:"thirdParty,omitempty"` +} + +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 Mutation struct { +} + +type NestedInput struct { + Field Email `json:"field"` +} + +type NestedMapInput struct { + Map map[string]interface{} `json:"map,omitempty"` +} + +type ObjectDirectives struct { + Text string `json:"text"` + NullableText *string `json:"nullableText,omitempty"` + Order []string `json:"order"` +} + +type OmittableInput struct { + ID graphql.Omittable[*string] `json:"id,omitempty"` + Bool graphql.Omittable[*bool] `json:"bool,omitempty"` + Str graphql.Omittable[*string] `json:"str,omitempty"` + Int graphql.Omittable[*int] `json:"int,omitempty"` + Time graphql.Omittable[*time.Time] `json:"time,omitempty"` + Enum graphql.Omittable[*Status] `json:"enum,omitempty"` + Scalar graphql.Omittable[*ThirdParty] `json:"scalar,omitempty"` + Object graphql.Omittable[*OuterInput] `json:"object,omitempty"` +} + +type OuterInput struct { + Inner *InnerInput `json:"inner"` +} + +type OuterObject struct { + Inner *InnerObject `json:"inner"` +} + +type Pet struct { + ID int `json:"id"` + Friends []*Pet `json:"friends,omitempty"` +} + +type Query struct { +} + +type Size struct { + Height int `json:"height"` + Weight int `json:"weight"` +} + +type Slices struct { + Test1 []*string `json:"test1,omitempty"` + Test2 []string `json:"test2,omitempty"` + Test3 []*string `json:"test3"` + Test4 []string `json:"test4"` +} + +type SpecialInput struct { + Nesting *NestedInput `json:"nesting"` +} + +type Subscription struct { +} + +type User struct { + ID int `json:"id"` + Friends []*User `json:"friends"` + Created time.Time `json:"created"` + Updated *time.Time `json:"updated,omitempty"` + Pets []*Pet `json:"pets,omitempty"` +} + +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/singlefile/models.go b/codegen/testserver/singlefile/models.go new file mode 100644 index 0000000..e9203cd --- /dev/null +++ b/codegen/testserver/singlefile/models.go @@ -0,0 +1,104 @@ +package singlefile + +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/singlefile/mutation_with_custom_scalar.go b/codegen/testserver/singlefile/mutation_with_custom_scalar.go new file mode 100644 index 0000000..22c4586 --- /dev/null +++ b/codegen/testserver/singlefile/mutation_with_custom_scalar.go @@ -0,0 +1,29 @@ +package singlefile + +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/singlefile/mutation_with_custom_scalar.graphql b/codegen/testserver/singlefile/mutation_with_custom_scalar.graphql new file mode 100644 index 0000000..e9896dd --- /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/singlefile/mutation_with_custom_scalar_test.go b/codegen/testserver/singlefile/mutation_with_custom_scalar_test.go new file mode 100644 index 0000000..ebadbeb --- /dev/null +++ b/codegen/testserver/singlefile/mutation_with_custom_scalar_test.go @@ -0,0 +1,51 @@ +package singlefile + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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/singlefile/nulls.graphql b/codegen/testserver/singlefile/nulls.graphql new file mode 100644 index 0000000..23dd965 --- /dev/null +++ b/codegen/testserver/singlefile/nulls.graphql @@ -0,0 +1,27 @@ +extend type Query { + errorBubble: Error + errorBubbleList: [Error!] + errorList: [Error] + errors: Errors + valid: String! + invalid: String! +} + +extend type Subscription { + errorRequired: Error! +} + +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/singlefile/nulls_test.go b/codegen/testserver/singlefile/nulls_test.go new file mode 100644 index 0000000..189e530 --- /dev/null +++ b/codegen/testserver/singlefile/nulls_test.go @@ -0,0 +1,148 @@ +package singlefile + +import ( + "context" + "errors" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +func TestNullBubbling(t *testing.T) { + resolvers := &Stub{} + resolvers.QueryResolver.Valid = func(ctx context.Context) (s string, e error) { + return "Ok", nil + } + resolvers.QueryResolver.Invalid = func(ctx context.Context) (s string, e error) { + return "Ok", errors.New("ERROR") + } + 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{{ID: "1"}, nil, 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":"the requested element is null which the schema does not allow","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.Contains(t, err.Error(), `{"message":"the requested element is null which the schema does not allow","path":["errorBubbleList",2]}`) + require.Contains(t, err.Error(), `{"message":"the requested element is null which the schema does not allow","path":["errorBubbleList",1]}`) + 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(), "the requested element is null which the schema does not allow") + }) + + t.Run("when non-nullable field returns content while error occurred", func(t *testing.T) { + var resp any + err := c.Post(`query { invalid }`, &resp) + require.Nil(t, resp) + require.NotNil(t, err) + require.Contains(t, err.Error(), `{"message":"ERROR","path":["invalid"]}`) + }) +} diff --git a/codegen/testserver/singlefile/otherpkg/model.go b/codegen/testserver/singlefile/otherpkg/model.go new file mode 100644 index 0000000..f2cc202 --- /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 0000000..8895fca --- /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/singlefile/panics_test.go b/codegen/testserver/singlefile/panics_test.go new file mode 100644 index 0000000..827ab4c --- /dev/null +++ b/codegen/testserver/singlefile/panics_test.go @@ -0,0 +1,69 @@ +package singlefile + +import ( + "context" + "fmt" + "testing" + + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/v2/gqlerror" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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/singlefile/primitive_objects.graphql b/codegen/testserver/singlefile/primitive_objects.graphql new file mode 100644 index 0000000..c53702c --- /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/singlefile/primitive_objects_test.go b/codegen/testserver/singlefile/primitive_objects_test.go new file mode 100644 index 0000000..760862c --- /dev/null +++ b/codegen/testserver/singlefile/primitive_objects_test.go @@ -0,0 +1,74 @@ +package singlefile + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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/singlefile/ptr_to_any.go b/codegen/testserver/singlefile/ptr_to_any.go new file mode 100644 index 0000000..37a1c3d --- /dev/null +++ b/codegen/testserver/singlefile/ptr_to_any.go @@ -0,0 +1,9 @@ +package singlefile + +type PtrToAnyContainer struct { + PtrToAny *any +} + +func (c *PtrToAnyContainer) Binding() *any { + return c.PtrToAny +} diff --git a/codegen/testserver/singlefile/ptr_to_any.graphql b/codegen/testserver/singlefile/ptr_to_any.graphql new file mode 100644 index 0000000..c86bf38 --- /dev/null +++ b/codegen/testserver/singlefile/ptr_to_any.graphql @@ -0,0 +1,10 @@ +scalar Any + +type PtrToAnyContainer { + ptrToAny: Any + binding: Any +} + +extend type Query { + ptrToAnyContainer: PtrToAnyContainer! +} diff --git a/codegen/testserver/singlefile/ptr_to_any_test.go b/codegen/testserver/singlefile/ptr_to_any_test.go new file mode 100644 index 0000000..840b10e --- /dev/null +++ b/codegen/testserver/singlefile/ptr_to_any_test.go @@ -0,0 +1,38 @@ +package singlefile + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +func TestPtrToAny(t *testing.T) { + resolvers := &Stub{} + + c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))) + + var a any = `{"some":"thing"}` + resolvers.QueryResolver.PtrToAnyContainer = func(ctx context.Context) (wrappedStruct *PtrToAnyContainer, e error) { + ptrToAnyContainer := PtrToAnyContainer{ + PtrToAny: &a, + } + return &ptrToAnyContainer, nil + } + + t.Run("binding to pointer to any", func(t *testing.T) { + var resp struct { + PtrToAnyContainer struct { + Binding *any + } + } + + err := c.Post(`query { ptrToAnyContainer { binding }}`, &resp) + require.NoError(t, err) + + require.Equal(t, &a, resp.PtrToAnyContainer.Binding) + }) +} 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 0000000..9fd1032 --- /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 0000000..c34b5c5 --- /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 0000000..6aea573 --- /dev/null +++ b/codegen/testserver/singlefile/ptr_to_ptr_input_test.go @@ -0,0 +1,175 @@ +package singlefile + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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 ret, err + } + + 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 0000000..b4e46d0 --- /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 0000000..b773d83 --- /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 0000000..69cd078 --- /dev/null +++ b/codegen/testserver/singlefile/ptr_to_slice_test.go @@ -0,0 +1,37 @@ +package singlefile + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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/singlefile/recursive.go b/codegen/testserver/singlefile/recursive.go new file mode 100644 index 0000000..728fbd9 --- /dev/null +++ b/codegen/testserver/singlefile/recursive.go @@ -0,0 +1,5 @@ +package singlefile + +type RecursiveInputSlice struct { + Self []RecursiveInputSlice +} diff --git a/codegen/testserver/singlefile/resolver.go b/codegen/testserver/singlefile/resolver.go new file mode 100644 index 0000000..a526dd9 --- /dev/null +++ b/codegen/testserver/singlefile/resolver.go @@ -0,0 +1,597 @@ +package singlefile + +// THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES. + +import ( + "context" + + introspection1 "github.com/niko0xdev/gqlgen/codegen/testserver/singlefile/introspection" + invalid_packagename "github.com/niko0xdev/gqlgen/codegen/testserver/singlefile/invalid-packagename" + "github.com/niko0xdev/gqlgen/codegen/testserver/singlefile/otherpkg" +) + +type Resolver struct{} + +// ID is the resolver for the id field. +func (r *backedByInterfaceResolver) ID(ctx context.Context, obj BackedByInterface) (string, error) { + panic("not implemented") +} + +// Values is the resolver for the values field. +func (r *deferModelResolver) Values(ctx context.Context, obj *DeferModel) ([]string, error) { + panic("not implemented") +} + +// A is the resolver for the a field. +func (r *errorsResolver) A(ctx context.Context, obj *Errors) (*Error, error) { + panic("not implemented") +} + +// B is the resolver for the b field. +func (r *errorsResolver) B(ctx context.Context, obj *Errors) (*Error, error) { + panic("not implemented") +} + +// C is the resolver for the c field. +func (r *errorsResolver) C(ctx context.Context, obj *Errors) (*Error, error) { + panic("not implemented") +} + +// D is the resolver for the d field. +func (r *errorsResolver) D(ctx context.Context, obj *Errors) (*Error, error) { + panic("not implemented") +} + +// E is the resolver for the e field. +func (r *errorsResolver) E(ctx context.Context, obj *Errors) (*Error, error) { + panic("not implemented") +} + +// Field is the resolver for the field field. +func (r *forcedResolverResolver) Field(ctx context.Context, obj *ForcedResolver) (*Circle, error) { + panic("not implemented") +} + +// ResolverField is the resolver for the resolverField field. +func (r *modelMethodsResolver) ResolverField(ctx context.Context, obj *ModelMethods) (bool, error) { + panic("not implemented") +} + +// DefaultInput is the resolver for the defaultInput field. +func (r *mutationResolver) DefaultInput(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error) { + panic("not implemented") +} + +// OverrideValueViaInput is the resolver for the overrideValueViaInput field. +func (r *mutationResolver) OverrideValueViaInput(ctx context.Context, input FieldsOrderInput) (*FieldsOrderPayload, error) { + panic("not implemented") +} + +// UpdateSomething is the resolver for the updateSomething field. +func (r *mutationResolver) UpdateSomething(ctx context.Context, input SpecialInput) (string, error) { + panic("not implemented") +} + +// UpdatePtrToPtr is the resolver for the updatePtrToPtr field. +func (r *mutationResolver) UpdatePtrToPtr(ctx context.Context, input UpdatePtrToPtrOuter) (*PtrToPtrOuter, error) { + panic("not implemented") +} + +// OldFoo is the resolver for the oldFoo field. +func (r *overlappingFieldsResolver) OldFoo(ctx context.Context, obj *OverlappingFields) (int, error) { + panic("not implemented") +} + +// FieldScalarMarshal is the resolver for the fieldScalarMarshal field. +func (r *panicsResolver) FieldScalarMarshal(ctx context.Context, obj *Panics) ([]MarshalPanic, error) { + panic("not implemented") +} + +// ArgUnmarshal is the resolver for the argUnmarshal field. +func (r *panicsResolver) ArgUnmarshal(ctx context.Context, obj *Panics, u []MarshalPanic) (bool, error) { + panic("not implemented") +} + +// Friends is the resolver for the friends field. +func (r *petResolver) Friends(ctx context.Context, obj *Pet, limit *int) ([]*Pet, error) { + panic("not implemented") +} + +// Value is the resolver for the value field. +func (r *primitiveResolver) Value(ctx context.Context, obj *Primitive) (int, error) { + panic("not implemented") +} + +// Value is the resolver for the value field. +func (r *primitiveStringResolver) Value(ctx context.Context, obj *PrimitiveString) (string, error) { + panic("not implemented") +} + +// Len is the resolver for the len field. +func (r *primitiveStringResolver) Len(ctx context.Context, obj *PrimitiveString) (int, error) { + panic("not implemented") +} + +// InvalidIdentifier is the resolver for the invalidIdentifier field. +func (r *queryResolver) InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) { + panic("not implemented") +} + +// Collision is the resolver for the collision field. +func (r *queryResolver) Collision(ctx context.Context) (*introspection1.It, error) { + panic("not implemented") +} + +// MapInput is the resolver for the mapInput field. +func (r *queryResolver) MapInput(ctx context.Context, input map[string]interface{}) (*bool, error) { + panic("not implemented") +} + +// Recursive is the resolver for the recursive field. +func (r *queryResolver) Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error) { + panic("not implemented") +} + +// NestedInputs is the resolver for the nestedInputs field. +func (r *queryResolver) NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error) { + panic("not implemented") +} + +// NestedOutputs is the resolver for the nestedOutputs field. +func (r *queryResolver) NestedOutputs(ctx context.Context) ([][]*OuterObject, error) { + panic("not implemented") +} + +// ModelMethods is the resolver for the modelMethods field. +func (r *queryResolver) ModelMethods(ctx context.Context) (*ModelMethods, error) { + panic("not implemented") +} + +// User is the resolver for the user field. +func (r *queryResolver) User(ctx context.Context, id int) (*User, error) { + panic("not implemented") +} + +// NullableArg is the resolver for the nullableArg field. +func (r *queryResolver) NullableArg(ctx context.Context, arg *int) (*string, error) { + panic("not implemented") +} + +// InputSlice is the resolver for the inputSlice field. +func (r *queryResolver) InputSlice(ctx context.Context, arg []string) (bool, error) { + panic("not implemented") +} + +// InputNullableSlice is the resolver for the inputNullableSlice field. +func (r *queryResolver) InputNullableSlice(ctx context.Context, arg []string) (bool, error) { + panic("not implemented") +} + +// InputOmittable is the resolver for the inputOmittable field. +func (r *queryResolver) InputOmittable(ctx context.Context, arg OmittableInput) (string, error) { + panic("not implemented") +} + +// ShapeUnion is the resolver for the shapeUnion field. +func (r *queryResolver) ShapeUnion(ctx context.Context) (ShapeUnion, error) { + panic("not implemented") +} + +// Autobind is the resolver for the autobind field. +func (r *queryResolver) Autobind(ctx context.Context) (*Autobind, error) { + panic("not implemented") +} + +// DeprecatedField is the resolver for the deprecatedField field. +func (r *queryResolver) DeprecatedField(ctx context.Context) (string, error) { + panic("not implemented") +} + +// Overlapping is the resolver for the overlapping field. +func (r *queryResolver) Overlapping(ctx context.Context) (*OverlappingFields, error) { + panic("not implemented") +} + +// DefaultParameters is the resolver for the defaultParameters field. +func (r *queryResolver) DefaultParameters(ctx context.Context, falsyBoolean *bool, truthyBoolean *bool) (*DefaultParametersMirror, error) { + panic("not implemented") +} + +// DeferCase1 is the resolver for the deferCase1 field. +func (r *queryResolver) DeferCase1(ctx context.Context) (*DeferModel, error) { + panic("not implemented") +} + +// DeferCase2 is the resolver for the deferCase2 field. +func (r *queryResolver) DeferCase2(ctx context.Context) ([]*DeferModel, error) { + panic("not implemented") +} + +// DirectiveArg is the resolver for the directiveArg field. +func (r *queryResolver) DirectiveArg(ctx context.Context, arg string) (*string, error) { + panic("not implemented") +} + +// DirectiveNullableArg is the resolver for the directiveNullableArg field. +func (r *queryResolver) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (*string, error) { + panic("not implemented") +} + +// DirectiveInputNullable is the resolver for the directiveInputNullable field. +func (r *queryResolver) DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) { + panic("not implemented") +} + +// DirectiveInput is the resolver for the directiveInput field. +func (r *queryResolver) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) { + panic("not implemented") +} + +// DirectiveInputType is the resolver for the directiveInputType field. +func (r *queryResolver) DirectiveInputType(ctx context.Context, arg InnerInput) (*string, error) { + panic("not implemented") +} + +// DirectiveObject is the resolver for the directiveObject field. +func (r *queryResolver) DirectiveObject(ctx context.Context) (*ObjectDirectives, error) { + panic("not implemented") +} + +// DirectiveObjectWithCustomGoModel is the resolver for the directiveObjectWithCustomGoModel field. +func (r *queryResolver) DirectiveObjectWithCustomGoModel(ctx context.Context) (*ObjectDirectivesWithCustomGoModel, error) { + panic("not implemented") +} + +// DirectiveFieldDef is the resolver for the directiveFieldDef field. +func (r *queryResolver) DirectiveFieldDef(ctx context.Context, ret string) (string, error) { + panic("not implemented") +} + +// DirectiveField is the resolver for the directiveField field. +func (r *queryResolver) DirectiveField(ctx context.Context) (*string, error) { + panic("not implemented") +} + +// DirectiveDouble is the resolver for the directiveDouble field. +func (r *queryResolver) DirectiveDouble(ctx context.Context) (*string, error) { + panic("not implemented") +} + +// DirectiveUnimplemented is the resolver for the directiveUnimplemented field. +func (r *queryResolver) DirectiveUnimplemented(ctx context.Context) (*string, error) { + panic("not implemented") +} + +// EmbeddedCase1 is the resolver for the embeddedCase1 field. +func (r *queryResolver) EmbeddedCase1(ctx context.Context) (*EmbeddedCase1, error) { + panic("not implemented") +} + +// EmbeddedCase2 is the resolver for the embeddedCase2 field. +func (r *queryResolver) EmbeddedCase2(ctx context.Context) (*EmbeddedCase2, error) { + panic("not implemented") +} + +// EmbeddedCase3 is the resolver for the embeddedCase3 field. +func (r *queryResolver) EmbeddedCase3(ctx context.Context) (*EmbeddedCase3, error) { + panic("not implemented") +} + +// EnumInInput is the resolver for the enumInInput field. +func (r *queryResolver) EnumInInput(ctx context.Context, input *InputWithEnumValue) (EnumTest, error) { + panic("not implemented") +} + +// Shapes is the resolver for the shapes field. +func (r *queryResolver) Shapes(ctx context.Context) ([]Shape, error) { + panic("not implemented") +} + +// NoShape is the resolver for the noShape field. +func (r *queryResolver) NoShape(ctx context.Context) (Shape, error) { + panic("not implemented") +} + +// Node is the resolver for the node field. +func (r *queryResolver) Node(ctx context.Context) (Node, error) { + panic("not implemented") +} + +// NoShapeTypedNil is the resolver for the noShapeTypedNil field. +func (r *queryResolver) NoShapeTypedNil(ctx context.Context) (Shape, error) { + panic("not implemented") +} + +// Animal is the resolver for the animal field. +func (r *queryResolver) Animal(ctx context.Context) (Animal, error) { + panic("not implemented") +} + +// NotAnInterface is the resolver for the notAnInterface field. +func (r *queryResolver) NotAnInterface(ctx context.Context) (BackedByInterface, error) { + panic("not implemented") +} + +// Dog is the resolver for the dog field. +func (r *queryResolver) Dog(ctx context.Context) (*Dog, error) { + panic("not implemented") +} + +// Issue896a is the resolver for the issue896a field. +func (r *queryResolver) Issue896a(ctx context.Context) ([]*CheckIssue896, error) { + panic("not implemented") +} + +// MapStringInterface is the resolver for the mapStringInterface field. +func (r *queryResolver) MapStringInterface(ctx context.Context, in map[string]interface{}) (map[string]interface{}, error) { + panic("not implemented") +} + +// MapNestedStringInterface is the resolver for the mapNestedStringInterface field. +func (r *queryResolver) MapNestedStringInterface(ctx context.Context, in *NestedMapInput) (map[string]interface{}, error) { + panic("not implemented") +} + +// ErrorBubble is the resolver for the errorBubble field. +func (r *queryResolver) ErrorBubble(ctx context.Context) (*Error, error) { + panic("not implemented") +} + +// ErrorBubbleList is the resolver for the errorBubbleList field. +func (r *queryResolver) ErrorBubbleList(ctx context.Context) ([]*Error, error) { + panic("not implemented") +} + +// ErrorList is the resolver for the errorList field. +func (r *queryResolver) ErrorList(ctx context.Context) ([]*Error, error) { + panic("not implemented") +} + +// Errors is the resolver for the errors field. +func (r *queryResolver) Errors(ctx context.Context) (*Errors, error) { + panic("not implemented") +} + +// Valid is the resolver for the valid field. +func (r *queryResolver) Valid(ctx context.Context) (string, error) { + panic("not implemented") +} + +// Invalid is the resolver for the invalid field. +func (r *queryResolver) Invalid(ctx context.Context) (string, error) { + panic("not implemented") +} + +// Panics is the resolver for the panics field. +func (r *queryResolver) Panics(ctx context.Context) (*Panics, error) { + panic("not implemented") +} + +// PrimitiveObject is the resolver for the primitiveObject field. +func (r *queryResolver) PrimitiveObject(ctx context.Context) ([]Primitive, error) { + panic("not implemented") +} + +// PrimitiveStringObject is the resolver for the primitiveStringObject field. +func (r *queryResolver) PrimitiveStringObject(ctx context.Context) ([]PrimitiveString, error) { + panic("not implemented") +} + +// PtrToAnyContainer is the resolver for the ptrToAnyContainer field. +func (r *queryResolver) PtrToAnyContainer(ctx context.Context) (*PtrToAnyContainer, error) { + panic("not implemented") +} + +// PtrToSliceContainer is the resolver for the ptrToSliceContainer field. +func (r *queryResolver) PtrToSliceContainer(ctx context.Context) (*PtrToSliceContainer, error) { + panic("not implemented") +} + +// Infinity is the resolver for the infinity field. +func (r *queryResolver) Infinity(ctx context.Context) (float64, error) { + panic("not implemented") +} + +// StringFromContextInterface is the resolver for the stringFromContextInterface field. +func (r *queryResolver) StringFromContextInterface(ctx context.Context) (*StringFromContextInterface, error) { + panic("not implemented") +} + +// StringFromContextFunction is the resolver for the stringFromContextFunction field. +func (r *queryResolver) StringFromContextFunction(ctx context.Context) (string, error) { + panic("not implemented") +} + +// DefaultScalar is the resolver for the defaultScalar field. +func (r *queryResolver) DefaultScalar(ctx context.Context, arg string) (string, error) { + panic("not implemented") +} + +// Slices is the resolver for the slices field. +func (r *queryResolver) Slices(ctx context.Context) (*Slices, error) { + panic("not implemented") +} + +// ScalarSlice is the resolver for the scalarSlice field. +func (r *queryResolver) ScalarSlice(ctx context.Context) ([]byte, error) { + panic("not implemented") +} + +// Fallback is the resolver for the fallback field. +func (r *queryResolver) Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) { + panic("not implemented") +} + +// OptionalUnion is the resolver for the optionalUnion field. +func (r *queryResolver) OptionalUnion(ctx context.Context) (TestUnion, error) { + panic("not implemented") +} + +// VOkCaseValue is the resolver for the vOkCaseValue field. +func (r *queryResolver) VOkCaseValue(ctx context.Context) (*VOkCaseValue, error) { + panic("not implemented") +} + +// VOkCaseNil is the resolver for the vOkCaseNil field. +func (r *queryResolver) VOkCaseNil(ctx context.Context) (*VOkCaseNil, error) { + panic("not implemented") +} + +// ValidType is the resolver for the validType field. +func (r *queryResolver) ValidType(ctx context.Context) (*ValidType, error) { + panic("not implemented") +} + +// VariadicModel is the resolver for the variadicModel field. +func (r *queryResolver) VariadicModel(ctx context.Context) (*VariadicModel, error) { + panic("not implemented") +} + +// WrappedStruct is the resolver for the wrappedStruct field. +func (r *queryResolver) WrappedStruct(ctx context.Context) (*WrappedStruct, error) { + panic("not implemented") +} + +// WrappedScalar is the resolver for the wrappedScalar field. +func (r *queryResolver) WrappedScalar(ctx context.Context) (otherpkg.Scalar, error) { + panic("not implemented") +} + +// WrappedMap is the resolver for the wrappedMap field. +func (r *queryResolver) WrappedMap(ctx context.Context) (WrappedMap, error) { + panic("not implemented") +} + +// WrappedSlice is the resolver for the wrappedSlice field. +func (r *queryResolver) WrappedSlice(ctx context.Context) (WrappedSlice, error) { + panic("not implemented") +} + +// Updated is the resolver for the updated field. +func (r *subscriptionResolver) Updated(ctx context.Context) (<-chan string, error) { + panic("not implemented") +} + +// InitPayload is the resolver for the initPayload field. +func (r *subscriptionResolver) InitPayload(ctx context.Context) (<-chan string, error) { + panic("not implemented") +} + +// DirectiveArg is the resolver for the directiveArg field. +func (r *subscriptionResolver) DirectiveArg(ctx context.Context, arg string) (<-chan *string, error) { + panic("not implemented") +} + +// DirectiveNullableArg is the resolver for the directiveNullableArg field. +func (r *subscriptionResolver) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (<-chan *string, error) { + panic("not implemented") +} + +// DirectiveDouble is the resolver for the directiveDouble field. +func (r *subscriptionResolver) DirectiveDouble(ctx context.Context) (<-chan *string, error) { + panic("not implemented") +} + +// DirectiveUnimplemented is the resolver for the directiveUnimplemented field. +func (r *subscriptionResolver) DirectiveUnimplemented(ctx context.Context) (<-chan *string, error) { + panic("not implemented") +} + +// Issue896b is the resolver for the issue896b field. +func (r *subscriptionResolver) Issue896b(ctx context.Context) (<-chan []*CheckIssue896, error) { + panic("not implemented") +} + +// ErrorRequired is the resolver for the errorRequired field. +func (r *subscriptionResolver) ErrorRequired(ctx context.Context) (<-chan *Error, error) { + panic("not implemented") +} + +// Friends is the resolver for the friends field. +func (r *userResolver) Friends(ctx context.Context, obj *User) ([]*User, error) { + panic("not implemented") +} + +// Pets is the resolver for the pets field. +func (r *userResolver) Pets(ctx context.Context, obj *User, limit *int) ([]*Pet, error) { + panic("not implemented") +} + +// Get is the resolver for the get field. +func (r *wrappedMapResolver) Get(ctx context.Context, obj WrappedMap, key string) (string, error) { + panic("not implemented") +} + +// Get is the resolver for the get field. +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} +} + +// DeferModel returns DeferModelResolver implementation. +func (r *Resolver) DeferModel() DeferModelResolver { return &deferModelResolver{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} } + +// Pet returns PetResolver implementation. +func (r *Resolver) Pet() PetResolver { return &petResolver{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 deferModelResolver 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 petResolver 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/singlefile/response_extension_test.go b/codegen/testserver/singlefile/response_extension_test.go new file mode 100644 index 0000000..208f213 --- /dev/null +++ b/codegen/testserver/singlefile/response_extension_test.go @@ -0,0 +1,34 @@ +package singlefile + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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/singlefile/scalar_context.go b/codegen/testserver/singlefile/scalar_context.go new file mode 100644 index 0000000..e632df1 --- /dev/null +++ b/codegen/testserver/singlefile/scalar_context.go @@ -0,0 +1,39 @@ +package singlefile + +import ( + "context" + "io" + "strconv" + + "github.com/niko0xdev/gqlgen/graphql" +) + +type StringFromContextInterface struct { + OperationName string +} + +var ( + _ graphql.ContextMarshaler = StringFromContextInterface{} + _ 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 0000000..f49fa55 --- /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 0000000..ce56dc2 --- /dev/null +++ b/codegen/testserver/singlefile/scalar_context_test.go @@ -0,0 +1,52 @@ +package singlefile + +import ( + "context" + "math" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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 0000000..5e3a9c0 --- /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/singlefile/scalar_default_test.go b/codegen/testserver/singlefile/scalar_default_test.go new file mode 100644 index 0000000..8ffdc16 --- /dev/null +++ b/codegen/testserver/singlefile/scalar_default_test.go @@ -0,0 +1,33 @@ +package singlefile + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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/singlefile/schema.graphql b/codegen/testserver/singlefile/schema.graphql new file mode 100644 index 0000000..4db9a47 --- /dev/null +++ b/codegen/testserver/singlefile/schema.graphql @@ -0,0 +1,128 @@ +directive @goModel( + model: String + models: [String!] +) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION +directive @goField( + forceResolver: Boolean + name: String + omittable: Boolean +) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION +directive @defer( + if: Boolean = true + label: String +) on FRAGMENT_SPREAD | INLINE_FRAGMENT + +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! + inputOmittable(arg: OmittableInput!): String! + shapeUnion: ShapeUnion! + autobind: Autobind + deprecatedField: String! @deprecated(reason: "test deprecated directive") +} + +type Subscription { + updated: String! + initPayload: String! +} + +type Pet { + id: Int! + friends(limit: Int): [Pet!] @goField(forceResolver: true) +} + +type User { + id: Int! + friends: [User!]! @goField(forceResolver: true) + created: Time! + updated: Time + pets(limit: Int): [Pet!] @goField(forceResolver: true) +} + +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! +} + +input OmittableInput { + id: ID @goField(omittable: true) + bool: Boolean @goField(omittable: true) + str: String @goField(omittable: true) + int: Int @goField(omittable: true) + time: Time @goField(omittable: true) + enum: Status @goField(omittable: true) + scalar: ThirdParty @goField(omittable: true) + object: OuterInput @goField(omittable: true) +} + +scalar ThirdParty @goModel(model:"singlefile.ThirdParty") + +type OuterObject { + inner: InnerObject! +} + +type InnerObject { + id: Int! +} + +type ForcedResolver { + field: Circle @goField(forceResolver: true) +} + +type EmbeddedPointer @goModel(model:"singlefile.EmbeddedPointerModel") { + ID: String + Title: String +} + +scalar UUID + +enum Status { + OK + ERROR +} + +scalar Time diff --git a/codegen/testserver/singlefile/slices.graphql b/codegen/testserver/singlefile/slices.graphql new file mode 100644 index 0000000..b1265c5 --- /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/singlefile/slices_test.go b/codegen/testserver/singlefile/slices_test.go new file mode 100644 index 0000000..2c7d877 --- /dev/null +++ b/codegen/testserver/singlefile/slices_test.go @@ -0,0 +1,44 @@ +package singlefile + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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/singlefile/stub.go b/codegen/testserver/singlefile/stub.go new file mode 100644 index 0000000..28f73c4 --- /dev/null +++ b/codegen/testserver/singlefile/stub.go @@ -0,0 +1,569 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package singlefile + +import ( + "context" + + introspection1 "github.com/niko0xdev/gqlgen/codegen/testserver/singlefile/introspection" + invalid_packagename "github.com/niko0xdev/gqlgen/codegen/testserver/singlefile/invalid-packagename" + "github.com/niko0xdev/gqlgen/codegen/testserver/singlefile/otherpkg" +) + +type Stub struct { + BackedByInterfaceResolver struct { + ID func(ctx context.Context, obj BackedByInterface) (string, error) + } + DeferModelResolver struct { + Values func(ctx context.Context, obj *DeferModel) ([]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) + OverrideValueViaInput func(ctx context.Context, input FieldsOrderInput) (*FieldsOrderPayload, 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) + } + PetResolver struct { + Friends func(ctx context.Context, obj *Pet, limit *int) ([]*Pet, 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) + InputOmittable func(ctx context.Context, arg OmittableInput) (string, 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) + DeferCase1 func(ctx context.Context) (*DeferModel, error) + DeferCase2 func(ctx context.Context) ([]*DeferModel, 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) + Dog func(ctx context.Context) (*Dog, 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) + Invalid 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) + PtrToAnyContainer func(ctx context.Context) (*PtrToAnyContainer, 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) + VariadicModel func(ctx context.Context) (*VariadicModel, 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) + ErrorRequired func(ctx context.Context) (<-chan *Error, error) + } + UserResolver struct { + Friends func(ctx context.Context, obj *User) ([]*User, error) + Pets func(ctx context.Context, obj *User, limit *int) ([]*Pet, 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) + } + + FieldsOrderInputResolver struct { + OverrideFirstField func(ctx context.Context, obj *FieldsOrderInput, data *string) error + } +} + +func (r *Stub) BackedByInterface() BackedByInterfaceResolver { + return &stubBackedByInterface{r} +} +func (r *Stub) DeferModel() DeferModelResolver { + return &stubDeferModel{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) Pet() PetResolver { + return &stubPet{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} +} + +func (r *Stub) FieldsOrderInput() FieldsOrderInputResolver { + return &stubFieldsOrderInput{r} +} + +type stubBackedByInterface struct{ *Stub } + +func (r *stubBackedByInterface) ID(ctx context.Context, obj BackedByInterface) (string, error) { + return r.BackedByInterfaceResolver.ID(ctx, obj) +} + +type stubDeferModel struct{ *Stub } + +func (r *stubDeferModel) Values(ctx context.Context, obj *DeferModel) ([]string, error) { + return r.DeferModelResolver.Values(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) OverrideValueViaInput(ctx context.Context, input FieldsOrderInput) (*FieldsOrderPayload, error) { + return r.MutationResolver.OverrideValueViaInput(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 stubPet struct{ *Stub } + +func (r *stubPet) Friends(ctx context.Context, obj *Pet, limit *int) ([]*Pet, error) { + return r.PetResolver.Friends(ctx, obj, limit) +} + +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) InputOmittable(ctx context.Context, arg OmittableInput) (string, error) { + return r.QueryResolver.InputOmittable(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) DeferCase1(ctx context.Context) (*DeferModel, error) { + return r.QueryResolver.DeferCase1(ctx) +} +func (r *stubQuery) DeferCase2(ctx context.Context) ([]*DeferModel, error) { + return r.QueryResolver.DeferCase2(ctx) +} +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) Dog(ctx context.Context) (*Dog, error) { + return r.QueryResolver.Dog(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) Invalid(ctx context.Context) (string, error) { + return r.QueryResolver.Invalid(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) PtrToAnyContainer(ctx context.Context) (*PtrToAnyContainer, error) { + return r.QueryResolver.PtrToAnyContainer(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) VariadicModel(ctx context.Context) (*VariadicModel, error) { + return r.QueryResolver.VariadicModel(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) +} +func (r *stubSubscription) ErrorRequired(ctx context.Context) (<-chan *Error, error) { + return r.SubscriptionResolver.ErrorRequired(ctx) +} + +type stubUser struct{ *Stub } + +func (r *stubUser) Friends(ctx context.Context, obj *User) ([]*User, error) { + return r.UserResolver.Friends(ctx, obj) +} +func (r *stubUser) Pets(ctx context.Context, obj *User, limit *int) ([]*Pet, error) { + return r.UserResolver.Pets(ctx, obj, limit) +} + +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) +} + +type stubFieldsOrderInput struct{ *Stub } + +func (r *stubFieldsOrderInput) OverrideFirstField(ctx context.Context, obj *FieldsOrderInput, data *string) error { + return r.FieldsOrderInputResolver.OverrideFirstField(ctx, obj, data) +} diff --git a/codegen/testserver/singlefile/subscription_test.go b/codegen/testserver/singlefile/subscription_test.go new file mode 100644 index 0000000..5e4684d --- /dev/null +++ b/codegen/testserver/singlefile/subscription_test.go @@ -0,0 +1,205 @@ +package singlefile + +import ( + "context" + "fmt" + "runtime" + "sort" + "testing" + "time" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" +) + +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 + } + + errorTick := make(chan *Error, 1) + resolvers.SubscriptionResolver.ErrorRequired = func(ctx context.Context) (<-chan *Error, error) { + res := make(chan *Error, 1) + + go func() { + for { + select { + case t := <-errorTick: + res <- t + case <-ctx.Done(): + close(res) + return + } + } + }() + return res, 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) { + runtime.GC() // ensure no go-routines left from preceding tests + initialGoroutineCount := runtime.NumGoroutine() + + 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() + + // 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("websocket gets errors", func(t *testing.T) { + runtime.GC() // ensure no go-routines left from preceding tests + initialGoroutineCount := runtime.NumGoroutine() + + sub := c.Websocket(`subscription { errorRequired { id } }`) + + errorTick <- &Error{ID: "ID1234"} + + var msg struct { + resp struct { + ErrorRequired *struct { + Id string + } + } + } + + err := sub.Next(&msg.resp) + require.NoError(t, err) + require.Equal(t, "ID1234", msg.resp.ErrorRequired.Id) + + errorTick <- nil + err = sub.Next(&msg.resp) + require.Error(t, err) + + 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()) + }) +} diff --git a/codegen/testserver/singlefile/thirdparty.go b/codegen/testserver/singlefile/thirdparty.go new file mode 100644 index 0000000..7a9f17f --- /dev/null +++ b/codegen/testserver/singlefile/thirdparty.go @@ -0,0 +1,31 @@ +package singlefile + +import ( + "fmt" + "io" + "strconv" + + "github.com/niko0xdev/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/singlefile/time_test.go b/codegen/testserver/singlefile/time_test.go new file mode 100644 index 0000000..c78fdde --- /dev/null +++ b/codegen/testserver/singlefile/time_test.go @@ -0,0 +1,69 @@ +package singlefile + +import ( + "context" + "testing" + "time" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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":"the requested element is null which the schema does not allow","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/singlefile/typefallback.graphql b/codegen/testserver/singlefile/typefallback.graphql new file mode 100644 index 0000000..e1ff1a5 --- /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/singlefile/typefallback_test.go b/codegen/testserver/singlefile/typefallback_test.go new file mode 100644 index 0000000..1a024e5 --- /dev/null +++ b/codegen/testserver/singlefile/typefallback_test.go @@ -0,0 +1,29 @@ +package singlefile + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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/singlefile/useptr.graphql b/codegen/testserver/singlefile/useptr.graphql new file mode 100644 index 0000000..23c1af0 --- /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/singlefile/useptr_test.go b/codegen/testserver/singlefile/useptr_test.go new file mode 100644 index 0000000..e4f2039 --- /dev/null +++ b/codegen/testserver/singlefile/useptr_test.go @@ -0,0 +1,14 @@ +package singlefile + +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/singlefile/v-ok.go b/codegen/testserver/singlefile/v-ok.go new file mode 100644 index 0000000..511fd5e --- /dev/null +++ b/codegen/testserver/singlefile/v-ok.go @@ -0,0 +1,15 @@ +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 0000000..f0c1ae8 --- /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 0000000..af51e7a --- /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/niko0xdev/gqlgen/client" + "github.com/niko0xdev/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 0000000..f66a426 --- /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/niko0xdev/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/singlefile/validtypes_test.go b/codegen/testserver/singlefile/validtypes_test.go new file mode 100644 index 0000000..07a81db --- /dev/null +++ b/codegen/testserver/singlefile/validtypes_test.go @@ -0,0 +1,37 @@ +package singlefile + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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/singlefile/variadic.go b/codegen/testserver/singlefile/variadic.go new file mode 100644 index 0000000..9313606 --- /dev/null +++ b/codegen/testserver/singlefile/variadic.go @@ -0,0 +1,14 @@ +package singlefile + +import ( + "context" + "strconv" +) + +type VariadicModel struct{} + +type VariadicModelOption func(*VariadicModel) + +func (v VariadicModel) Value(ctx context.Context, rank int, opts ...VariadicModelOption) (string, error) { + return strconv.Itoa(rank), nil +} diff --git a/codegen/testserver/singlefile/variadic.graphql b/codegen/testserver/singlefile/variadic.graphql new file mode 100644 index 0000000..e58845d --- /dev/null +++ b/codegen/testserver/singlefile/variadic.graphql @@ -0,0 +1,7 @@ +extend type Query { + variadicModel: VariadicModel +} + +type VariadicModel { + value(rank: Int!): String +} diff --git a/codegen/testserver/singlefile/variadic_test.go b/codegen/testserver/singlefile/variadic_test.go new file mode 100644 index 0000000..2d37492 --- /dev/null +++ b/codegen/testserver/singlefile/variadic_test.go @@ -0,0 +1,34 @@ +package singlefile + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +func TestVariadic(t *testing.T) { + resolver := &Stub{} + resolver.QueryResolver.VariadicModel = func(ctx context.Context) (*VariadicModel, error) { + return &VariadicModel{}, nil + } + c := client.New(handler.NewDefaultServer( + NewExecutableSchema(Config{Resolvers: resolver}), + )) + + var resp struct { + VariadicModel struct { + Value string + } + } + err := c.Post(`query { variadicModel { value(rank: 1) } }`, &resp) + require.NoError(t, err) + require.Equal(t, resp.VariadicModel.Value, "1") + + err = c.Post(`query { variadicModel { value(rank: 2) } }`, &resp) + require.NoError(t, err) + require.Equal(t, resp.VariadicModel.Value, "2") +} diff --git a/codegen/testserver/singlefile/weird_type_cases.graphql b/codegen/testserver/singlefile/weird_type_cases.graphql new file mode 100644 index 0000000..1e7eac1 --- /dev/null +++ b/codegen/testserver/singlefile/weird_type_cases.graphql @@ -0,0 +1,8 @@ +# regression test for https://github.com/niko0xdev/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/singlefile/wrapped_type.go b/codegen/testserver/singlefile/wrapped_type.go new file mode 100644 index 0000000..beca5c5 --- /dev/null +++ b/codegen/testserver/singlefile/wrapped_type.go @@ -0,0 +1,10 @@ +package singlefile + +import "github.com/niko0xdev/gqlgen/codegen/testserver/singlefile/otherpkg" + +type ( + WrappedScalar = otherpkg.Scalar + WrappedStruct otherpkg.Struct + WrappedMap otherpkg.Map + WrappedSlice otherpkg.Slice +) diff --git a/codegen/testserver/singlefile/wrapped_type.graphql b/codegen/testserver/singlefile/wrapped_type.graphql new file mode 100644 index 0000000..90b0c2e --- /dev/null +++ b/codegen/testserver/singlefile/wrapped_type.graphql @@ -0,0 +1,13 @@ +# regression test for https://github.com/niko0xdev/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/singlefile/wrapped_type_test.go b/codegen/testserver/singlefile/wrapped_type_test.go new file mode 100644 index 0000000..55ba88c --- /dev/null +++ b/codegen/testserver/singlefile/wrapped_type_test.go @@ -0,0 +1,99 @@ +package singlefile + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/codegen/testserver/singlefile/otherpkg" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +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/type.go b/codegen/type.go new file mode 100644 index 0000000..6ae420d --- /dev/null +++ b/codegen/type.go @@ -0,0 +1,32 @@ +package codegen + +import ( + "fmt" + + "github.com/niko0xdev/gqlgen/codegen/config" +) + +func (b *builder) buildTypes() map[string]*config.TypeReference { + ret := map[string]*config.TypeReference{} + for _, ref := range b.Binder.References { + processType(ret, ref) + } + return ret +} + +func processType(ret map[string]*config.TypeReference, ref *config.TypeReference) { + key := ref.UniquenessKey() + if existing, found := ret[key]; found { + // Simplistic check of content which is obviously different. + existingGQL := fmt.Sprintf("%v", existing.GQL) + newGQL := fmt.Sprintf("%v", ref.GQL) + if existingGQL != newGQL { + panic(fmt.Sprintf("non-unique key \"%s\", trying to replace %s with %s", key, existingGQL, newGQL)) + } + } + ret[key] = ref + + if ref.IsSlice() || ref.IsPtrToSlice() || ref.IsPtrToPtr() || ref.IsPtrToIntf() { + processType(ret, ref.Elem()) + } +} diff --git a/codegen/type.gotpl b/codegen/type.gotpl new file mode 100644 index 0000000..272f3db --- /dev/null +++ b/codegen/type.gotpl @@ -0,0 +1,199 @@ +{{- 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) (not $type.IsPtrToPtr) }} + if v == nil { return nil, nil } + {{- end }} + {{- if or $type.IsPtrToSlice $type.IsPtrToIntf }} + res, err := ec.{{ $type.Elem.UnmarshalFunc }}(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) + {{- else if $type.IsSlice }} + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]{{$type.GO.Elem | ref}}, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.{{ $type.Elem.UnmarshalFunc }}(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + 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 }} + {{- 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}} + {{- 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) + {{- else if and (not $type.IsTargetNilable) $type.IsNilable }} + return &res, graphql.ErrorOnPath(ctx, err) + {{- else}} + return res, graphql.ErrorOnPath(ctx, err) + {{- end }} + {{- else if $type.IsMarshaler }} + {{- if and $type.IsNilable $type.Elem }} + var res = new({{ $type.Elem.GO | ref }}) + {{- else}} + var res {{ $type.GO | ref }} + {{- end }} + {{- 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) + {{- if and $type.IsNilable (not $type.IsMap) (not $type.PointersInUmarshalInput) }} + return &res, graphql.ErrorOnPath(ctx, err) + {{- else if and (not $type.IsNilable) $type.PointersInUmarshalInput }} + return *res, graphql.ErrorOnPath(ctx, err) + {{- else }} + return res, graphql.ErrorOnPath(ctx, err) + {{- end }} + {{- end }} + {{- end }} + } + {{- end }} + + {{ with $type.MarshalFunc }} + func (ec *executionContext) {{ . }}(ctx context.Context, sel ast.SelectionSet, v {{ $type.GO | ref }}) graphql.Marshaler { + {{- if or $type.IsPtrToSlice $type.IsPtrToIntf }} + return ec.{{ $type.Elem.MarshalFunc }}(ctx, sel, *v) + {{- else if $type.IsSlice }} + {{- if not $type.GQL.NonNull }} + if v == nil { + return graphql.Null + } + {{- end }} + ret := make(graphql.Array, len(v)) + {{- if not $type.IsScalar }} + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + {{- end }} + for i := range v { + {{- if not $type.IsScalar }} + 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.{{ $type.Elem.MarshalFunc }}(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + {{ else }} + ret[i] = ec.{{ $type.Elem.MarshalFunc }}(ctx, sel, v[i]) + {{- 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 { + {{- if $type.GQL.NonNull }} + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + {{- end }} + return graphql.Null + } + {{- end }} + {{- if $type.IsMarshaler }} + {{- 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) }} + {{- $v = "&v" }} + {{- 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 }} + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + {{- end }} + {{- if $type.IsContext }} + return graphql.WrapContextMarshaler(ctx, res) + {{- else }} + return res + {{- end }} + {{- else if $type.IsRoot }} + {{- if eq $type.Definition.Name "Subscription" }} + res := ec._{{$type.Definition.Name}}(ctx, sel) + return res(ctx) + {{- else }} + return ec._{{$type.Definition.Name}}(ctx, sel) + {{- end }} + {{- else }} + return ec._{{$type.Definition.Name}}(ctx, sel, {{ if not $type.IsNilable}}&{{end}} v) + {{- end }} + {{- end }} + } + {{- end }} +{{- end }} diff --git a/codegen/util.go b/codegen/util.go new file mode 100644 index 0000000..8a60cd1 --- /dev/null +++ b/codegen/util.go @@ -0,0 +1,47 @@ +package codegen + +import ( + "fmt" + "go/types" + "strings" +) + +func findGoNamedType(def types.Type) (*types.Named, error) { + if def == nil { + return nil, nil + } + + namedType, ok := def.(*types.Named) + if !ok { + return nil, fmt.Errorf("expected %s to be a named type, instead found %T\n", def.String(), def) + } + + return namedType, nil +} + +func findGoInterface(def types.Type) (*types.Interface, error) { + if def == nil { + return nil, nil + } + namedType, err := findGoNamedType(def) + if err != nil { + return nil, err + } + if namedType == nil { + return nil, nil + } + + underlying, ok := namedType.Underlying().(*types.Interface) + if !ok { + 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.ReplaceAll(source, "_", "") + source = strings.ReplaceAll(source, ",omitempty", "") + target = strings.ReplaceAll(target, "_", "") + return strings.EqualFold(source, target) +} diff --git a/complexity/complexity.go b/complexity/complexity.go new file mode 100644 index 0000000..4fcd735 --- /dev/null +++ b/complexity/complexity.go @@ -0,0 +1,110 @@ +package complexity + +import ( + "github.com/vektah/gqlparser/v2/ast" + + "github.com/niko0xdev/gqlgen/graphql" +) + +func Calculate(es graphql.ExecutableSchema, op *ast.OperationDefinition, vars map[string]interface{}) int { + walker := complexityWalker{ + es: es, + schema: es.Schema(), + vars: vars, + } + return walker.selectionSetComplexity(op.SelectionSet) +} + +type complexityWalker struct { + es graphql.ExecutableSchema + schema *ast.Schema + vars map[string]interface{} +} + +func (cw complexityWalker) selectionSetComplexity(selectionSet ast.SelectionSet) int { + var complexity int + for _, selection := range 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: + childComplexity = cw.selectionSetComplexity(s.SelectionSet) + } + + args := s.ArgumentMap(cw.vars) + var fieldComplexity int + if s.ObjectDefinition.Kind == ast.Interface { + fieldComplexity = cw.interfaceFieldComplexity(s.ObjectDefinition, s.Name, childComplexity, args) + } else { + fieldComplexity = cw.fieldComplexity(s.ObjectDefinition.Name, s.Name, childComplexity, args) + } + complexity = safeAdd(complexity, fieldComplexity) + + case *ast.FragmentSpread: + complexity = safeAdd(complexity, cw.selectionSetComplexity(s.Definition.SelectionSet)) + + case *ast.InlineFragment: + complexity = safeAdd(complexity, cw.selectionSetComplexity(s.SelectionSet)) + } + } + return complexity +} + +func (cw complexityWalker) interfaceFieldComplexity(def *ast.Definition, field string, childComplexity int, args map[string]interface{}) int { + // Interfaces don't have their own separate field costs, so they have to assume the worst case. + // We iterate over all implementors and choose the most expensive one. + maxComplexity := 0 + implementors := cw.schema.GetPossibleTypes(def) + for _, t := range implementors { + fieldComplexity := cw.fieldComplexity(t.Name, field, childComplexity, args) + if fieldComplexity > maxComplexity { + maxComplexity = fieldComplexity + } + } + return maxComplexity +} + +func (cw complexityWalker) fieldComplexity(object, field string, childComplexity int, args map[string]interface{}) int { + if customComplexity, ok := cw.es.Complexity(object, field, childComplexity, args); ok && customComplexity >= childComplexity { + return customComplexity + } + // default complexity calculation + return safeAdd(1, childComplexity) +} + +const maxInt = int(^uint(0) >> 1) + +// safeAdd is a saturating add of a and b that ignores negative operands. +// If a + b would overflow through normal Go addition, +// it returns the maximum integer value instead. +// +// Adding complexities with this function prevents attackers from intentionally +// overflowing the complexity calculation to allow overly-complex queries. +// +// It also helps mitigate the impact of custom complexities that accidentally +// return negative values. +func safeAdd(a, b int) int { + // Ignore negative operands. + if a < 0 { + if b < 0 { + return 1 + } + return b + } else if b < 0 { + return a + } + + c := a + b + if c < a { + // Set c to maximum integer instead of overflowing. + c = maxInt + } + return c +} diff --git a/complexity/complexity_test.go b/complexity/complexity_test.go new file mode 100644 index 0000000..c145c0e --- /dev/null +++ b/complexity/complexity_test.go @@ -0,0 +1,216 @@ +package complexity + +import ( + "math" + "testing" + + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" + + "github.com/niko0xdev/gqlgen/graphql" +) + +var schema = gqlparser.MustLoadSchema( + &ast.Source{ + Name: "test.graphql", + Input: ` + interface NameInterface { + name: String + } + + type Item implements NameInterface { + scalar: String + name: String + list(size: Int = 10): [Item] + } + + type ExpensiveItem implements NameInterface { + name: String + } + + type Named { + name: String + } + + union NameUnion = Item | Named + + type Query { + scalar: String + object: Item + interface: NameInterface + union: NameUnion + customObject: Item + list(size: Int = 10): [Item] + } + `, + }, +) + +func requireComplexity(t *testing.T, source string, complexity int) { + t.Helper() + query := gqlparser.MustLoadQuery(schema, source) + + es := &graphql.ExecutableSchemaMock{ + ComplexityFunc: func(typeName, field string, childComplexity int, args map[string]interface{}) (int, bool) { + switch typeName + "." + field { + case "ExpensiveItem.name": + return 5, true + case "Query.list", "Item.list": + return int(args["size"].(int64)) * childComplexity, true + case "Query.customObject": + return 1, true + } + return 0, false + }, + SchemaFunc: func() *ast.Schema { + return schema + }, + } + + actualComplexity := Calculate(es, query.Operations[0], nil) + require.Equal(t, complexity, actualComplexity) +} + +func TestCalculate(t *testing.T) { + t.Run("uses default cost", func(t *testing.T) { + const query = ` + { + scalar + } + ` + requireComplexity(t, query, 1) + }) + + t.Run("adds together fields", func(t *testing.T) { + const query = ` + { + scalar1: scalar + scalar2: scalar + } + ` + requireComplexity(t, query, 2) + }) + + t.Run("a level of nesting adds complexity", func(t *testing.T) { + const query = ` + { + object { + scalar + } + } + ` + requireComplexity(t, query, 2) + }) + + t.Run("adds together children", func(t *testing.T) { + const query = ` + { + scalar + object { + scalar + } + } + ` + requireComplexity(t, query, 3) + }) + + t.Run("adds inline fragments", func(t *testing.T) { + const query = ` + { + ... { + scalar + } + } + ` + requireComplexity(t, query, 1) + }) + + t.Run("adds fragments", func(t *testing.T) { + const query = ` + { + ... Fragment + } + + fragment Fragment on Query { + scalar + } + ` + requireComplexity(t, query, 1) + }) + + t.Run("uses custom complexity", func(t *testing.T) { + const query = ` + { + list { + scalar + } + } + ` + requireComplexity(t, query, 10) + }) + + t.Run("ignores negative custom complexity values", func(t *testing.T) { + const query = ` + { + list(size: -100) { + scalar + } + } + ` + requireComplexity(t, query, 2) + }) + + t.Run("custom complexity must be >= child complexity", func(t *testing.T) { + const query = ` + { + customObject { + list(size: 100) { + scalar + } + } + } + ` + requireComplexity(t, query, 101) + }) + + t.Run("interfaces take max concrete cost", func(t *testing.T) { + const query = ` + { + interface { + name + } + } + ` + requireComplexity(t, query, 6) + }) + + t.Run("guards against integer overflow", func(t *testing.T) { + if maxInt == math.MaxInt32 { + // this test is written assuming 64-bit ints + t.Skip() + } + const query = ` + { + list1: list(size: 2147483647) { + list(size: 2147483647) { + list(size: 2) { + scalar + } + } + } + # total cost so far: 2*0x7fffffff*0x7fffffff + # = 0x7ffffffe00000002 + # Adding the same again should cause overflow + list2: list(size: 2147483647) { + list(size: 2147483647) { + list(size: 2) { + scalar + } + } + } + } + ` + requireComplexity(t, query, math.MaxInt64) + }) +} diff --git a/docs/build.sh b/docs/build.sh new file mode 100755 index 0000000..341f122 --- /dev/null +++ b/docs/build.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# +# This was adapted from https://github.com/dgraph-io/dgraph/blob/master/wiki/scripts/build.sh +# + +set -e + +GREEN='\033[32;1m' +RESET='\033[0m' +HOST=https://gqlgen.com + +IFS=$'\n' read -r -d '' -a VERSIONS_ARRAY < <(curl -s -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/niko0xdev/gqlgen/releases?per_page=20" | jq -r '.[].tag_name' ) || true + +VERSIONS_ARRAY+=( "origin/master" ) + +joinVersions() { + versions=$(printf ",%s" "${VERSIONS_ARRAY[@]}" | sed 's/origin\/master/master/') + echo "${versions:1}" +} + +function version { echo "$@" | gawk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }'; } + +rebuild() { + VERSION_STRING=$(joinVersions) + export CURRENT_VERSION=${1} + if [[ $CURRENT_VERSION == 'origin/master' ]] ; then + CURRENT_VERSION="master" + fi + + export VERSIONS=${VERSION_STRING} + + hugo --quiet --destination="public/$CURRENT_VERSION" --baseURL="$HOST/$CURRENT_VERSION/" + + if [[ $1 == "${VERSIONS_ARRAY[0]}" ]]; then + hugo --quiet --destination=public/ --baseURL="$HOST/" + fi +} + + +currentBranch=$(git rev-parse --abbrev-ref HEAD) + +if ! git remote | grep -q origin ; then + git remote add origin https://github.com/niko0xdev/gqlgen +fi +git fetch origin --tags + +for version in "${VERSIONS_ARRAY[@]}" ; do + echo -e "$(date) $GREEN Updating docs for $version.$RESET" + rm -rf content + git checkout $version -- content + rebuild "$version" +done + +rm -rf content +git checkout "$currentBranch" -- content + diff --git a/docs/config.yml b/docs/config.yml new file mode 100644 index 0000000..dba69fd --- /dev/null +++ b/docs/config.yml @@ -0,0 +1,39 @@ +baseurl: https://gqlgen.com/ +metadataformat: yaml +title: gqlgen +enableGitInfo: true +pygmentsCodeFences: true +pygmentsUseClasses: true +canonifyURLs: true + +params: + name: gqlgen + description: graphql servers the easy way + +menu: + main: + - name: Introduction + url: / + weight: -10 + - name: Reference + identifier: reference + weight: 5 + - name: Recipes + identifier: recipes + weight: 10 + - name: pkg.go.dev → + parent: reference + url: https://pkg.go.dev/github.com/niko0xdev/gqlgen + +security: + funcs: + getenv: + - '^HUGO_' + - 'VERSIONS' + - 'CURRENT_VERSION' + +go_initialisms: + replace_defaults: false + initialisms: + - 'CC' + - 'BCC' diff --git a/docs/content/_introduction.md b/docs/content/_introduction.md new file mode 120000 index 0000000..fe84005 --- /dev/null +++ b/docs/content/_introduction.md @@ -0,0 +1 @@ +../../README.md \ No newline at end of file diff --git a/docs/content/config.md b/docs/content/config.md new file mode 100644 index 0000000..3dd7709 --- /dev/null +++ b/docs/content/config.md @@ -0,0 +1,191 @@ +--- +linkTitle: Configuration +title: How to configure gqlgen using gqlgen.yml +description: How to configure gqlgen using gqlgen.yml +menu: main +weight: -5 +--- + +gqlgen can be configured using a `gqlgen.yml` file, by default it will be loaded from the current directory, or any parent directory. + +Example: + +```yml +# Where are all the schema files located? globs are supported eg src/**/*.graphqls +schema: + - graph/*.graphqls + +# Where should the generated server code go? +exec: + layout: follow-schema + dir: graph/generated + package: generated + +# Enable Apollo federation support +federation: + filename: graph/federation.go + package: graph + +# Where should any generated models go? +model: + filename: graph/model/models_gen.go + package: model + # Optional: Pass in a path to a new gotpl template to use for generating the models + # model_template: [your/path/model.gotpl] + +# Where should the resolver implementations go? +resolver: + layout: follow-schema + dir: graph + package: graph + filename_template: "{name}.resolvers.go" + # Optional: turn on to not generate template comments above resolvers + # omit_template_comment: false + # Optional: Pass in a path to a new gotpl template to use for generating resolvers + # resolver_template: [your/path/resolver.gotpl] + +# Optional: turn on use ` + "`" + `gqlgen:"fieldName"` + "`" + ` tags in your models +# struct_tag: json + +# Optional: turn on to use []Thing instead of []*Thing +# omit_slice_element_pointers: false + +# Optional: turn on to omit Is() methods to interface and unions +# omit_interface_checks : true + +# Optional: turn on to skip generation of ComplexityRoot struct content and Complexity function +# omit_complexity: false + +# Optional: turn on to not generate any file notice comments in generated files +# omit_gqlgen_file_notice: false + +# Optional: turn on to exclude the gqlgen version in the generated file notice. No effect if `omit_gqlgen_file_notice` is true. +# omit_gqlgen_version_in_file_notice: false + +# Optional: turn on to exclude root models such as Query and Mutation from the generated models file. +# omit_root_models: false + +# Optional: turn off to make struct-type struct fields not use pointers +# e.g. type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing } +# struct_fields_always_pointers: true + +# Optional: turn off to make resolvers return values instead of pointers for structs +# resolvers_always_return_pointers: true + +# Optional: turn on to return pointers instead of values in unmarshalInput +# return_pointers_in_unmarshalinput: false + +# Optional: wrap nullable input fields with Omittable +# nullable_input_omittable: true + +# Optional: turn on to return pointers instead of values in unmarshalInput +# return_pointers_in_unmarshalinput: false + +# 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 + +# Optional: set build tags that will be used to load packages +# go_build_tags: +# - private +# - enterprise + +# Optional: set to modify the initialisms regarded for Go names +# go_initialisms: +# replace_defaults: false # if true, the default initialisms will get dropped in favor of the new ones instead of being added +# initialisms: # List of initialisms to for Go names +# - 'CC' +# - 'BCC' + +# 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: +# - "github.com/[YOUR_APP_DIR]/graph/model" + +# This section declares type mapping between the GraphQL and go type systems +# +# The first line in each type will be used as defaults for resolver arguments and +# modelgen, the others will be allowed when binding to fields. Configure them to +# your liking +models: + ID: + model: + - github.com/niko0xdev/gqlgen/graphql.ID + - github.com/niko0xdev/gqlgen/graphql.Int + - github.com/niko0xdev/gqlgen/graphql.Int64 + - github.com/niko0xdev/gqlgen/graphql.Int32 + Int: + model: + - github.com/niko0xdev/gqlgen/graphql.Int + - github.com/niko0xdev/gqlgen/graphql.Int64 + - github.com/niko0xdev/gqlgen/graphql.Int32 + UUID: + model: + - github.com/niko0xdev/gqlgen/graphql.UUID +``` + +Everything has defaults, so add things as you need. + +## Inline config with directives + +gqlgen ships with some builtin directives that make it a little easier to manage wiring. + +To start using them you first need to define them: + +```graphql +directive @goModel( + model: String + models: [String!] + forceGenerate: Boolean +) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION + +directive @goField( + forceResolver: Boolean + name: String + omittable: Boolean +) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION + +directive @goTag( + key: String! + value: String +) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION +``` + +> Here be dragons +> +> gqlgen doesnt currently support user-configurable directives for SCALAR, ENUM, INTERFACE or UNION. This only works +> for internal directives. You can track the progress [here](https://github.com/niko0xdev/gqlgen/issues/760) + +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) + @goTag(key: "xorm", value: "-") + @goTag(key: "yaml") +} + +# This make sense when autobind activated. +type Person @goModel(forceGenerate: true) { + id: ID! + name: String! +} +``` + +The builtin directives `goField`, `goModel` and `goTag` are automatically registered to `skip_runtime`. Any directives registered as `skip_runtime` will not exposed during introspection and are used during code generation only. + +If you have created a new code generation plugin using a directive which does not require runtime execution, the directive will need to be set to `skip_runtime`. + +e.g. a custom directive called `constraint` would be set as `skip_runtime` using the following configuration + +```yml +# custom directives which are not exposed during introspection. These directives are +# used for code generation only +directives: + constraint: + skip_runtime: true +``` diff --git a/docs/content/feature-comparison.md b/docs/content/feature-comparison.md new file mode 100644 index 0000000..c7b5cd2 --- /dev/null +++ b/docs/content/feature-comparison.md @@ -0,0 +1,29 @@ +--- +linkTitle: Feature Comparison +title: Comparing Features of Other Go GraphQL Implementations +description: Comparing Features of Other Go GraphQL Implementations +menu: main +weight: -1 +--- + +| | [gqlgen](https://github.com/niko0xdev/gqlgen) | [gophers](https://github.com/graph-gophers/graphql-go) | [graphql-go](https://github.com/graphql-go/graphql) | [thunder](https://github.com/samsarahq/thunder) | +| --------: | :-------- | :-------- | :-------- | :-------- | +| Kind | schema first | schema first | run time types | struct first | +| Boilerplate | less | more | more | some | +| Docs | [docs](https://gqlgen.com) & [examples](https://github.com/niko0xdev/gqlgen/tree/master/_examples) | [examples](https://github.com/graph-gophers/graphql-go/tree/master/example/starwars) | [examples](https://github.com/graphql-go/graphql/tree/master/examples) | [examples](https://github.com/samsarahq/thunder/tree/master/example)| +| Query | 👍 | 👍 | 👍 | 👍 | +| Mutation | 👍 | 🚧 [pr](https://github.com/graph-gophers/graphql-go/pull/182) | 👍 | 👍 | +| Subscription | 👍 | 🚧 [pr](https://github.com/graph-gophers/graphql-go/pull/182) | 👍 | 👍 | +| Type Safety | 👍 | 👍 | ⛔️ | 👍 | +| Type Binding | 👍 | 👍 | ⛔️ | 👍 | +| Embedding | 👍 | ⛔️ | 🚧 [pr](https://github.com/graphql-go/graphql/pull/371) | ⛔️ | +| Interfaces | 👍 | 👍 | 👍 | ⛔️ [is](https://github.com/samsarahq/thunder/issues/78) | +| Generated Enums | 👍 | ⛔️ | ⛔️ | ⛔️ | +| Generated Inputs | 👍 | ⛔️ | ⛔️ | ⛔️ | +| Federation | 👍 | ⛔️ | ⛔️ | ⛔️ | +| Opentracing | 👍 | 👍 | ⛔️ | ✂️[pr](https://github.com/samsarahq/thunder/pull/77) | +| Hooks for error logging | 👍 | ⛔️ | ⛔️ | ⛔️ | +| Dataloading | 👍 | 👍 | 👍 | ⚠️ | +| Concurrency | 👍 | 👍 | 👍 | 👍 | +| Custom errors & error.path | 👍 | ⛔️ [is](https://github.com/graphql-go/graphql/issues/259) | ⛔️ | ⛔️ | +| Query complexity | 👍 | ⛔️ [is](https://github.com/graphql-go/graphql/issues/231) | ⛔️ | ⛔️ | diff --git a/docs/content/getting-started.md b/docs/content/getting-started.md new file mode 100644 index 0000000..b7780ff --- /dev/null +++ b/docs/content/getting-started.md @@ -0,0 +1,280 @@ +--- +linkTitle: Getting Started +title: Building GraphQL servers in golang +description: Get started building type-safe GraphQL servers in Golang using gqlgen +menu: main +weight: -7 +--- + +This tutorial will take you through the process of building a GraphQL server with gqlgen that can: + + - Return a list of todos + - Create new todos + - Mark off todos as they are completed + +You can find the finished code for this tutorial [here](https://github.com/vektah/gqlgen-tutorials/tree/master/gettingstarted) + +## Set up Project + +Create a directory for your project, and [initialise it as a Go Module](https://golang.org/doc/tutorial/create-module): + +```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/niko0xdev/gqlgen" +) +``` + +To automatically add the dependency to your `go.mod` run +```shell +go mod tidy +``` + +By default you'll be using the latest version of gqlgen, but if you want to specify a particular version you can use `go get` (replacing `VERSION` with the particular version desired) +```shell +go get -d github.com/niko0xdev/gqlgen@VERSION +``` + + + +## Building the server + +### Create the project skeleton + +```shell +go run github.com/niko0xdev/gqlgen init +``` + +This will create our suggested package layout. You can modify these paths in gqlgen.yml if you need to. +``` +├── go.mod +├── go.sum +├── gqlgen.yml - The gqlgen config file, knobs for controlling the generated code. +├── graph +│   ├── generated - A package that only contains the generated runtime +│   │   └── generated.go +│   ├── model - A package for all your graph models, generated or otherwise +│   │   └── models_gen.go +│   ├── resolver.go - The root graph resolver type. This file wont get regenerated +│   ├── schema.graphqls - Some schema. You can split the schema into as many graphql files as you like +│   └── schema.resolvers.go - the resolver implementation for schema.graphql +└── server.go - The entry point to your app. Customize it however you see fit +``` + +### Define your schema + +gqlgen is a schema-first library — before writing code, you describe your API using the GraphQL +[Schema Definition Language](http://graphql.org/learn/schema/). By default this goes into a file called +`schema.graphqls` but you can break it up into as many different files as you want. + +The schema that was generated for us was: +```graphql +type Todo { + id: ID! + text: String! + done: Boolean! + user: User! +} + +type User { + id: ID! + name: String! +} + +type Query { + todos: [Todo!]! +} + +input NewTodo { + text: String! + userId: String! +} + +type Mutation { + createTodo(input: NewTodo!): Todo! +} +``` + +### Implement the resolvers + +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: + +```go +func (r *mutationResolver) CreateTodo(ctx context.Context, input model.NewTodo) (*model.Todo, error) { + panic(fmt.Errorf("not implemented")) +} + +func (r *queryResolver) Todos(ctx context.Context) ([]*model.Todo, error) { + panic(fmt.Errorf("not implemented")) +} +``` + +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`. 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 +} +``` + +Returning to `graph/schema.resolvers.go`, let's implement the bodies of those automatically generated resolver functions. For `CreateTodo`, we'll use the [`crypto.rand` package](https://pkg.go.dev/crypto/rand#Int) 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) { + randNumber, _ := rand.Int(rand.Reader, big.NewInt(100)) + todo := &model.Todo{ + Text: input.Text, + ID: fmt.Sprintf("T%d", randNumber), + User: &model.User{ID: input.UserID, Name: "user " + input.UserID}, + } + r.todos = append(r.todos, todo) + return todo, nil +} + +func (r *queryResolver) Todos(ctx context.Context) ([]*model.Todo, error) { + return r.todos, nil +} +``` + +### Run the server + +We now have a working server, to start it: +```bash +go run server.go +``` + +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" }) { + user { + id + } + text + done + } +} +``` + +And then querying for it: + +```graphql +query findTodos { + todos { + text + done + user { + name + } + } +} +``` + +### Don't eagerly fetch the user + +This example is great, but in the real world fetching most objects is expensive. We don't want to load the User on the +todo unless the user actually asked for it. So lets replace the generated `Todo` model with something slightly more +realistic. + +First let's enable `autobind`, allowing gqlgen to use your custom models if it can find them rather than generating them. We do this by uncommenting the `autobind` config line in `gqlgen.yml`: + +```yml +# 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: + - "github.com/[username]/gqlgen-todos/graph/model" +``` + +And add `Todo` fields resolver config in `gqlgen.yml` to generate resolver for `user` field +```yml +# This section declares type mapping between the GraphQL and go type systems +# +# The first line in each type will be used as defaults for resolver arguments and +# modelgen, the others will be allowed when binding to fields. Configure them to +# your liking +models: + ID: + model: + - github.com/niko0xdev/gqlgen/graphql.ID + - github.com/niko0xdev/gqlgen/graphql.Int + - github.com/niko0xdev/gqlgen/graphql.Int64 + - github.com/niko0xdev/gqlgen/graphql.Int32 + Int: + model: + - github.com/niko0xdev/gqlgen/graphql.Int + - github.com/niko0xdev/gqlgen/graphql.Int64 + - github.com/niko0xdev/gqlgen/graphql.Int32 + Todo: + fields: + user: + resolver: true +``` + +Next, create a new file called `graph/model/todo.go` + +```go +package model + +type Todo struct { + ID string `json:"id"` + Text string `json:"text"` + Done bool `json:"done"` + UserID string `json:"userId"` + User *User `json:"user"` +} +``` + +And run `go run github.com/niko0xdev/gqlgen generate`. + +> +> If you run into this error `package github.com/niko0xdev/gqlgen: no Go files` while executing the `generate` command above, follow the instructions in [this](https://github.com/niko0xdev/gqlgen/issues/800#issuecomment-888908950) comment for a possible solution. + +Now if we look in `graph/schema.resolvers.go` we can see a new resolver, lets implement it and fix `CreateTodo`. +```go +func (r *mutationResolver) CreateTodo(ctx context.Context, input model.NewTodo) (*model.Todo, error) { + randNumber, _ := rand.Int(rand.Reader, big.NewInt(100)) + todo := &model.Todo{ + Text: input.Text, + ID: fmt.Sprintf("T%d", randNumber), + UserID: input.UserID, + } + r.todos = append(r.todos, todo) + return todo, nil +} + +func (r *todoResolver) User(ctx context.Context, obj *model.Todo) (*model.User, error) { + return &model.User{ID: obj.UserID, Name: "user " + obj.UserID}, nil +} +``` + +## Finishing touches + +At the top of our `resolver.go`, between `package` and `import`, add the following line: + +```go +//go:generate go run github.com/niko0xdev/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: + +```go +go generate ./... +``` diff --git a/docs/content/introduction.md b/docs/content/introduction.md new file mode 100644 index 0000000..6ee0d14 --- /dev/null +++ b/docs/content/introduction.md @@ -0,0 +1,6 @@ +--- +linkTitle: Introduction +title: Type-safe GraphQL for Go +type: homepage +date: 2018-03-17T13:06:47+11:00 +--- diff --git a/docs/content/recipes/authentication.md b/docs/content/recipes/authentication.md new file mode 100644 index 0000000..e1cfe35 --- /dev/null +++ b/docs/content/recipes/authentication.md @@ -0,0 +1,205 @@ +--- +title: "Providing authentication details through context" +description: How to using golang context.Context to authenticate users and pass user data to resolvers. +linkTitle: Authentication +menu: { main: { parent: 'recipes' } } +--- + +We have an app where users are authenticated using a cookie in the HTTP request, and we want to check this authentication status somewhere in our graph. Because GraphQL is transport agnostic we can't assume there will even be an HTTP request, so we need to expose these authentication details to our graph using a middleware. + + +```go +package auth + +import ( + "database/sql" + "net/http" + "context" +) + +// A private key for context that only this package can access. This is important +// to prevent collisions between different context uses +var userCtxKey = &contextKey{"user"} +type contextKey struct { + name string +} + +// A stand-in for our database backed user object +type User struct { + Name string + IsAdmin bool +} + +// Middleware decodes the share session cookie and packs the session into context +func Middleware(db *sql.DB) func(http.Handler) http.Handler { + return func(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + c, err := r.Cookie("auth-cookie") + + // Allow unauthenticated users in + if err != nil || c == nil { + next.ServeHTTP(w, r) + return + } + + userId, err := validateAndGetUserID(c) + if err != nil { + http.Error(w, "Invalid cookie", http.StatusForbidden) + return + } + + // get the user from the database + user := getUserByID(db, userId) + + // put it in context + ctx := context.WithValue(r.Context(), userCtxKey, user) + + // and call the next with our new context + r = r.WithContext(ctx) + next.ServeHTTP(w, r) + }) + } +} + +// ForContext finds the user from the context. REQUIRES Middleware to have run. +func ForContext(ctx context.Context) *User { + raw, _ := ctx.Value(userCtxKey).(*User) + return raw +} +``` + +**Note:** `getUserByID` and `validateAndGetUserID` have been left to the user to implement. + +Now when we create the server we should wrap it in our authentication middleware: +```go +package main + +import ( + "net/http" + + "github.com/niko0xdev/gqlgen/_examples/starwars" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/playground" + "github.com/go-chi/chi" +) + +func main() { + router := chi.NewRouter() + + router.Use(auth.Middleware(db)) + + srv := handler.NewDefaultServer(starwars.NewExecutableSchema(starwars.NewResolver())) + router.Handle("/", playground.Handler("Starwars", "/query")) + router.Handle("/query", srv) + + err := http.ListenAndServe(":8080", router) + if err != nil { + panic(err) + } +} +``` + +And in our resolvers (or directives) we can call `ForContext` to retrieve the data back out: +```go + +func (r *queryResolver) Hero(ctx context.Context, episode Episode) (Character, error) { + if user := auth.ForContext(ctx) ; user == nil || !user.IsAdmin { + return Character{}, fmt.Errorf("Access denied") + } + + if episode == EpisodeEmpire { + return r.humans["1000"], nil + } + return r.droid["2001"], nil +} +``` + +### Websockets + +If you need access to the websocket init payload you can add your `InitFunc` in `AddTransport`. +Your InitFunc implementation could then attempt to extract items from the payload: + +```go +package main + +import ( + "context" + "errors" + "log" + "net/http" + "os" + "time" + + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/handler/extension" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" + "github.com/niko0xdev/gqlgen/graphql/playground" + "github.com/go-chi/chi" + "github.com/gorilla/websocket" + "github.com/gqlgen/_examples/websocket-initfunc/server/graph" + "github.com/gqlgen/_examples/websocket-initfunc/server/graph/generated" + "github.com/rs/cors" +) + +func webSocketInit(ctx context.Context, initPayload transport.InitPayload) (context.Context, error) { + // Get the token from payload + any := initPayload["authToken"] + token, ok := any.(string) + if !ok || token == "" { + return nil, errors.New("authToken not found in transport payload") + } + + // Perform token verification and authentication... + userId := "john.doe" // e.g. userId, err := GetUserFromAuthentication(token) + + // put it in context + ctxNew := context.WithValue(ctx, "username", userId) + + return ctxNew, nil +} + +const defaultPort = "8080" + +func main() { + port := os.Getenv("PORT") + if port == "" { + port = defaultPort + } + + router := chi.NewRouter() + + // CORS setup, allow any for now + // https://gqlgen.com/recipes/cors/ + c := cors.New(cors.Options{ + AllowedOrigins: []string{"*"}, + AllowCredentials: true, + Debug: false, + }) + + srv := handler.New(generated.NewExecutableSchema(generated.Config{Resolvers: &graph.Resolver{}})) + srv.AddTransport(transport.POST{}) + srv.AddTransport(transport.Websocket{ + KeepAlivePingInterval: 10 * time.Second, + Upgrader: websocket.Upgrader{ + CheckOrigin: func(r *http.Request) bool { + return true + }, + }, + InitFunc: func(ctx context.Context, initPayload transport.InitPayload) (context.Context, error) { + return webSocketInit(ctx, initPayload) + }, + }) + srv.Use(extension.Introspection{}) + + router.Handle("/", playground.Handler("My GraphQL App", "/app")) + router.Handle("/app", c.Handler(srv)) + + log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) + log.Fatal(http.ListenAndServe(":"+port, router)) +} +``` + +> Note +> +> Subscriptions are long lived, if your tokens can timeout or need to be refreshed you should keep the token in +context too and verify it is still valid in `auth.ForContext`. diff --git a/docs/content/recipes/cors.md b/docs/content/recipes/cors.md new file mode 100644 index 0000000..1e44b2c --- /dev/null +++ b/docs/content/recipes/cors.md @@ -0,0 +1,62 @@ +--- +title: "Setting CORS headers using rs/cors for gqlgen" +description: Use the best of breed rs/cors library to set CORS headers when working with gqlgen +linkTitle: CORS +menu: { main: { parent: "recipes" } } +--- + +Cross-Origin Resource Sharing (CORS) headers are required when your graphql server lives on a different domain to the one your client code is served. You can read more about CORS in the [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS). + +## rs/cors + +gqlgen doesn't include a CORS implementation, but it is built to work with all standard http middleware. Here we are going to use the fantastic `chi` and `rs/cors` to build our server. + +```go +package main + +import ( + "net/http" + + "github.com/niko0xdev/gqlgen/graphql/handler/transport" + "github.com/niko0xdev/gqlgen/_examples/starwars" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/go-chi/chi" + "github.com/rs/cors" + "github.com/gorilla/websocket" + "github.com/niko0xdev/gqlgen/graphql/playground" +) + +func main() { + router := chi.NewRouter() + + // Add CORS middleware around every request + // See https://github.com/rs/cors for full option listing + router.Use(cors.New(cors.Options{ + AllowedOrigins: []string{"http://localhost:8080"}, + AllowCredentials: true, + Debug: true, + }).Handler) + + + srv := handler.NewDefaultServer(starwars.NewExecutableSchema(starwars.NewResolver())) + srv.AddTransport(&transport.Websocket{ + Upgrader: websocket.Upgrader{ + CheckOrigin: func(r *http.Request) bool { + // Check against your desired domains here + return r.Host == "example.org" + }, + ReadBufferSize: 1024, + WriteBufferSize: 1024, + }, + }) + + router.Handle("/", playground.Handler("Starwars", "/query")) + router.Handle("/query", srv) + + err := http.ListenAndServe(":8080", router) + if err != nil { + panic(err) + } +} + +``` diff --git a/docs/content/recipes/extra_fields.md b/docs/content/recipes/extra_fields.md new file mode 100644 index 0000000..38d9f37 --- /dev/null +++ b/docs/content/recipes/extra_fields.md @@ -0,0 +1,47 @@ +--- +title: "Generation of additional extra fields for internal use" +description: Pass implementation specific fields to the children resolvers without being forced to define your own types for a GraphQL model. +linkTitle: Generated Model Extra Fields +menu: { main: { parent: 'recipes' } } +--- + +Extra fields allows you to generate additional fields for your models. +These fields can be used at runtime when implementing field resolvers. + +## Extending your models +Imagine you have a model named User and you want to extend a generated struct with additional data used in your service. + +The schema is: + +```graphql +type User { + id: ID! + name: String! +} +``` + +Extra fields can be defined in gqlgen.yaml configuration: + +```yaml +models: + User: + extraFields: + Session: + description: "A Session used by this user" + type: "github.com/author/mypkg.Session" +``` + +The generated code would look like: + +```go +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +type User struct { + ID string + Name string + // A Session used by this user. + Session mypkg.Session +} +``` + +After these steps you have an extra field for your server implementation and the field is not being exposed to a caller. diff --git a/docs/content/recipes/federation.md b/docs/content/recipes/federation.md new file mode 100644 index 0000000..f843434 --- /dev/null +++ b/docs/content/recipes/federation.md @@ -0,0 +1,203 @@ +--- +title: 'Using Apollo federation gqlgen' +description: How federate many services into a single graph using Apollo +linkTitle: Apollo Federation +menu: { main: { parent: 'recipes' } } +--- + +In this quick guide we are going to implement the example [Apollo Federation](https://www.apollographql.com/docs/apollo-server/federation/introduction/) +server in gqlgen. You can find the finished result in the [examples directory](https://github.com/niko0xdev/gqlgen/tree/master/_examples/federation). + +## Enable federation + +Uncomment federation configuration in your `gqlgen.yml` + +```yml +# Uncomment to enable federation +federation: + filename: graph/federation.go + package: graph +``` + +### Federation 2 + +If you are using Apollo's Federation 2 standard, your schema should automatically be upgraded so long as you include the required `@link` directive within your schema. If you want to force Federation 2 composition, the `federation` configuration supports a `version` flag to override that. For example: + +```yml +federation: + filename: graph/federation.go + package: graph + version: 2 +``` + +## Create the federated servers + +For each server to be federated we will create a new gqlgen project. + +```bash +go run github.com/niko0xdev/gqlgen +``` + +Update the schema to reflect the federated example +```graphql +type Review { + body: String + author: User @provides(fields: "username") + product: Product +} + +extend type User @key(fields: "id") { + id: ID! @external # External directive not required for key fields in federation v2 + reviews: [Review] +} + +extend type Product @key(fields: "upc") { + upc: String! @external # External directive not required for key fields in federation v2 + reviews: [Review] +} +``` + + +and regenerate +```bash +go run github.com/niko0xdev/gqlgen +``` + +then implement the resolvers +```go +// These two methods are required for gqlgen to resolve the internal id-only wrapper structs. +// This boilerplate might be removed in a future version of gqlgen that can no-op id only nodes. +func (r *entityResolver) FindProductByUpc(ctx context.Context, upc string) (*model.Product, error) { + return &model.Product{ + Upc: upc, + }, nil +} + +func (r *entityResolver) FindUserByID(ctx context.Context, id string) (*model.User, error) { + return &model.User{ + ID: id, + }, nil +} + +// Here we implement the stitched part of this service, returning reviews for a product. Of course normally you would +// go back to the database, but we are just making some data up here. +func (r *productResolver) Reviews(ctx context.Context, obj *model.Product) ([]*model.Review, error) { + switch obj.Upc { + case "top-1": + return []*model.Review{{ + Body: "A highly effective form of birth control.", + }}, nil + + case "top-2": + return []*model.Review{{ + Body: "Fedoras are one of the most fashionable hats around and can look great with a variety of outfits.", + }}, nil + + case "top-3": + return []*model.Review{{ + Body: "This is the last straw. Hat you will wear. 11/10", + }}, nil + + } + return nil, nil +} + +func (r *userResolver) Reviews(ctx context.Context, obj *model.User) ([]*model.Review, error) { + if obj.ID == "1234" { + return []*model.Review{{ + Body: "Has an odd fascination with hats.", + }}, nil + } + return nil, nil +} +``` + +> Note +> +> Repeat this step for each of the services in the apollo doc (accounts, products, reviews) + +## Create the federation gateway + +```bash +npm install --save @apollo/gateway apollo-server graphql +``` + +```typescript +const { ApolloServer } = require('apollo-server'); +const { ApolloGateway } = require("@apollo/gateway"); + +const gateway = new ApolloGateway({ + serviceList: [ + { name: 'accounts', url: 'http://localhost:4001/query' }, + { name: 'products', url: 'http://localhost:4002/query' }, + { name: 'reviews', url: 'http://localhost:4003/query' } + ], +}); + +const server = new ApolloServer({ + gateway, + + subscriptions: false, +}); + +server.listen().then(({ url }) => { + console.log(`🚀 Server ready at ${url}`); +}); +``` + +## Start all the services + +In separate terminals: +```bash +go run accounts/server.go +go run products/server.go +go run reviews/server.go +node gateway/index.js +``` + +## Query the federated gateway + +The examples from the apollo doc should all work, eg + +```graphql +query { + me { + username + reviews { + body + product { + name + upc + } + } + } +} +``` + +should return + +```json +{ + "data": { + "me": { + "username": "Me", + "reviews": [ + { + "body": "A highly effective form of birth control.", + "product": { + "name": "Trilby", + "upc": "top-1" + } + }, + { + "body": "Fedoras are one of the most fashionable hats around and can look great with a variety of outfits.", + "product": { + "name": "Trilby", + "upc": "top-1" + } + } + ] + } + } +} +``` diff --git a/docs/content/recipes/gin.md b/docs/content/recipes/gin.md new file mode 100644 index 0000000..a75eefd --- /dev/null +++ b/docs/content/recipes/gin.md @@ -0,0 +1,107 @@ +--- +title: "Using Gin to setup HTTP handlers" +description: Setting up HTTP handlers using Gin, a HTTP web framework written in Go. +linkTitle: Gin +menu: { main: { parent: 'recipes' } } +--- + +Gin is an excellent alternative for the `net/http` router. From their official [GitHub page](https://github.com/gin-gonic/gin): + +> Gin is a web framework written in Go (Golang). It features a martini-like API with much better performance, up to 40 times faster thanks to httprouter. If you need performance and good productivity, you will love Gin. + +Here are the steps to setup Gin and gqlgen together: + +Install Gin: +```bash +$ 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 them together in the Gin router: + +```go +import ( + "github.com/[username]/gqlgen-todos/graph" // Replace username with your github username + "github.com/gin-gonic/gin" + + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/playground" +) + +// Defining the Graphql handler +func graphqlHandler() gin.HandlerFunc { + // NewExecutableSchema and Config are in the generated.go file + // Resolver is in the resolver.go file + h := handler.NewDefaultServer(graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}})) + + return func(c *gin.Context) { + h.ServeHTTP(c.Writer, c.Request) + } +} + +// Defining the Playground handler +func playgroundHandler() gin.HandlerFunc { + h := playground.Handler("GraphQL", "/query") + + return func(c *gin.Context) { + h.ServeHTTP(c.Writer, c.Request) + } +} + +func main() { + // Setting up Gin + r := gin.Default() + r.POST("/query", graphqlHandler()) + r.GET("/", playgroundHandler()) + r.Run() +} + +``` + +## Accessing gin.Context +At the Resolver level, `gqlgen` gives you access to the `context.Context` object. One way to access the `gin.Context` is to add it to the context and retrieve it again. + +First, create a `gin` middleware to add its context to the `context.Context`: +```go +func GinContextToContextMiddleware() gin.HandlerFunc { + return func(c *gin.Context) { + ctx := context.WithValue(c.Request.Context(), "GinContextKey", c) + c.Request = c.Request.WithContext(ctx) + c.Next() + } +} +``` + +In the router definition, use the middleware: +```go +r.Use(GinContextToContextMiddleware()) +``` + +Define a function to recover the `gin.Context` from the `context.Context` struct: +```go +func GinContextFromContext(ctx context.Context) (*gin.Context, error) { + ginContext := ctx.Value("GinContextKey") + if ginContext == nil { + err := fmt.Errorf("could not retrieve gin.Context") + return nil, err + } + + gc, ok := ginContext.(*gin.Context) + if !ok { + err := fmt.Errorf("gin.Context has wrong type") + return nil, err + } + return gc, nil +} +``` + +Lastly, in the Resolver, retrieve the `gin.Context` with the previous defined function: +```go +func (r *resolver) Todo(ctx context.Context) (*Todo, error) { + gc, err := GinContextFromContext(ctx) + if err != nil { + return nil, err + } + + // ... +} +``` diff --git a/docs/content/recipes/migration-0.11.md b/docs/content/recipes/migration-0.11.md new file mode 100644 index 0000000..258f93e --- /dev/null +++ b/docs/content/recipes/migration-0.11.md @@ -0,0 +1,147 @@ +--- +title: "Migrating to 0.11" +description: Changes in gqlgen 0.11 +linkTitle: Migrating to 0.11 +menu: { main: { parent: 'recipes' } } +--- + +## Updated gqlparser + +gqlparser had a breaking change, if you have any references to it in your project your going to need to update +them from `github.com/vektah/gqlparser` to `github.com/vektah/gqlparser/v2`. + +```bash +sed -i 's/github.com\/vektah\/gqlparser/github.com\/vektah\/gqlparser\/v2/' $(find -name '*.go') +``` + +## Handler Refactor + +The handler package has grown organically for a long time, 0.11 is a large cleanup of the handler package to make it +more modular and easier to maintain once we get to 1.0. + + +### Transports + +Transports are the first thing that run, they handle decoding the incoming http request, and encoding the graphql +response. Supported transports are: + + - GET + - JSON POST + - Multipart form + - UrlEncoded form + - GRAPHQL + - Websockets + +new usage looks like this +```go +srv := New(es) + +srv.AddTransport(transport.Websocket{ + KeepAlivePingInterval: 10 * time.Second, +}) +srv.AddTransport(transport.Options{}) +srv.AddTransport(transport.GET{}) +srv.AddTransport(transport.POST{}) +srv.AddTransport(transport.MultipartForm{}) +srv.AddTransport(transport.UrlEncodedForm{}) +srv.AddTransport(transport.GRAPHQL{}) +``` + +### New handler extension API + +The core of this changes the handler package to be a set of composable extensions. The extensions implement a set of optional interfaces: + + - **OperationParameterMutator** runs before creating a OperationContext (formerly RequestContext). allows manipulating the raw query before parsing. + - **OperationContextMutator** runs after creating the OperationContext, but before executing the root resolver. + - **OperationInterceptor** runs for each incoming query after parsing and validation, for basic requests the writer will be invoked once, for subscriptions it will be invoked multiple times. + - **ResponseInterceptor** runs around each graphql operation response. This can be called many times for a single operation the case of subscriptions. + - **FieldInterceptor** runs around each field + +![Anatomy of a request@2x](https://user-images.githubusercontent.com/2247982/68181515-c8a27c00-ffeb-11e9-86f6-1673e7179ecb.png) + +Users of an extension should not need to know which extension points are being used by a given extension, they are added to the server simply by calling `Use(extension)`. + +There are a few convenience methods for defining middleware inline, instead of creating an extension + +```go +srv := handler.New(es) +srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + // this function will be called around every field. next() will evaluate the field and return + // its computed value. + return next(ctx) +}) +srv.AroundOperations(func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler { + // This function will be called around every operation, next() will return a function that when + // called will evaluate one response. Eventually next will return nil, signalling there are no + // more results to be returned by the server. + return next(ctx) +}) +srv.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + // This function will be called around each response in the operation. next() will evaluate + // and return a single response. + return next(ctx) +}) +``` + + +Some of the features supported out of the box by handler extensions: + + - APQ + - Query Complexity + - Error Presenters and Recover Func + - Introspection Query support + - Query AST cache + - Tracing API + +They can be `Use`'d like this: + +```go +srv := handler.New(es) +srv.Use(extension.Introspection{}) +srv.Use(extension.AutomaticPersistedQuery{ + Cache: lru.New(100), +}) +srv.Use(apollotracing.Tracer{}) +``` + +### Default server + +We provide a set of default extensions and transports if you aren't ready to customize them yet. Simply: +```go +handler.NewDefaultServer(es) +``` + +### More consistent naming + +As part of cleaning up the names the RequestContext has been renamed to OperationContext, as there can be multiple created during the lifecycle of a request. A new ResponseContext has also been created and error handling has been moved here. This allows each response in a subscription to have its own errors. I'm not sure what bugs this might have been causing before... + +### Removal of tracing + +Many of the old interfaces collapse down into just a few extension points: + +![Anatomy of a request](/request_anatomy.png) + +The tracing interface has also been removed, tracing stats are now measured in core (eg time to parse query) and made available on the operation/response contexts. Much of the old interface was designed so that users of a tracer don't need to know which extension points it was listening to, the new handler extensions have the same goal. + +### Backward compatibility + +There is a backwards compatibility layer that keeps most of the original interface in place. There are a few places where BC is known to be broken: + + - ResponseMiddleware: The signature used to be `func(ctx context.Context, next func(ctx context.Context) []byte) []byte` and is now `func(ctx context.Context) *Response`. We could maintain BC by marshalling to json before and after, but the change is pretty easy to make and is likely to cause less issues. + - The Tracer interface has been removed, any tracers will need to be reimplemented against the new extension interface. + +## New resolver layout + +0.11 also added a new way to generate and layout resolvers on disk. We used to only generate resolver implementations +whenever the file didnt exist. This behaviour is still there for those that are already used to it, However there is a +new mode you can turn on in config: + +```yaml +resolver: + layout: follow-schema + dir: graph +``` + +This tells gqlgen to generate resolvers next to the schema file that declared the graphql field, which looks like this: + +![follow-schema layout](/schema_layout.png) diff --git a/docs/content/recipes/modelgen-hook.md b/docs/content/recipes/modelgen-hook.md new file mode 100644 index 0000000..c268cf0 --- /dev/null +++ b/docs/content/recipes/modelgen-hook.md @@ -0,0 +1,180 @@ +--- +title: "Allowing mutation of generated models before rendering" +description: How to use a model mutation function to insert a ORM-specific tags onto struct fields. +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 +is a common use case since it allows for better field matching of DB queries and +the generated data structure. + +First of all, we need to create a function that will mutate the generated model. +Then we can attach the function to the plugin and use it like any other plugin. + +Create `generate.go` file in the same folder as `resolver.go` (usually in `graph` folder) and add the following code: + +```go +//go:build ignore + +package main + +import ( + "fmt" + "os" + + "github.com/niko0xdev/gqlgen/api" + "github.com/niko0xdev/gqlgen/codegen/config" + "github.com/niko0xdev/gqlgen/plugin/modelgen" +) + +// Defining mutation function +func mutateHook(b *modelgen.ModelBuild) *modelgen.ModelBuild { + for _, model := range b.Models { + for _, field := range model.Fields { + field.Tag += ` orm_binding:"` + model.Name + `.` + field.Name + `"` + } + } + + return b +} + +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{ + MutateHook: mutateHook, + } + + err = api.Generate(cfg, api.ReplacePlugin(&p)) + + if err != nil { + fmt.Fprintln(os.Stderr, err.Error()) + os.Exit(3) + } +} +``` + +In `resolver.go`, add `//go:generate go run generate.go` (or replace `//go:generate go run github.com/niko0xdev/gqlgen generate` if you have it there). + +Now you can run `go generate ./...` to generate the code. + +Now fields from generated models will contain a additional tag `orm_binding`. + +This schema: + +```graphql +type Object { + field1: String + field2: Int +} +``` + +Will gen generated into: + +```go +type Object struct { + field1 *string `json:"field1" orm_binding:"Object.field1"` + 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/niko0xdev/gqlgen/api" + "github.com/niko0xdev/gqlgen/codegen/config" + "github.com/niko0xdev/gqlgen/plugin/modelgen" +) + +// Defining mutation function +func constraintFieldHook(td *ast.Definition, fd *ast.FieldDefinition, f *modelgen.Field) (*modelgen.Field, error) { + // Call default hook to proceed standard directives like goField and goTag. + // You can omit it, if you don't need. + if f, err := modelgen.DefaultFieldMutateHook(td, fd, f); err != nil { + return f, err + } + + 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 should not be published during introspection, the directive should be listed with `skip_runtime:true` in gqlgen.yml + +```yaml +directives: + constraint: + skip_runtime: true +``` + +The built-in directives `@goField` and `@goTag` is implemented using the FieldMutateHook. See: `plugin/modelgen/models.go` functions `GoFieldHook` and `GoTagFieldHook` diff --git a/docs/content/recipes/subscriptions.md b/docs/content/recipes/subscriptions.md new file mode 100644 index 0000000..7f881d3 --- /dev/null +++ b/docs/content/recipes/subscriptions.md @@ -0,0 +1,336 @@ +--- +title: "Subscriptions" +description: Subscriptions allow for streaming real-time events to your clients. This is how to do that with gqlgen. +linkTitle: "Subscriptions" +menu: { main: { parent: 'recipes' } } +--- + +GraphQL Subscriptions allow you to stream events to your clients in real-time. +This is easy to do in gqlgen and this recipe will show you how to setup a quick example. + +## Preparation + +This recipe starts with the empty project after the quick start steps were followed. +Although the steps are the same in an existing, more complex projects you will need +to be careful to configure routing correctly. + +In this recipe you will learn how to + +1. add WebSocket Transport to your server +2. add the `Subscription` type to your schema +3. implement a real-time resolver. + +## Adding WebSocket Transport + +To send real-time data to clients, your GraphQL server needs to have an open connection +with the client. This is done using WebSockets. + +To add the WebSocket transport change your `main.go` by calling `AddTransport(&transport.Websocket{})` +on your query handler. + +**If you are using an external router, remember to send *ALL* `/query`-requests to your handler!** +**Not just POST requests!** + +```go +package main + +import ( + "log" + "net/http" + "os" + + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" + "github.com/niko0xdev/gqlgen/graphql/playground" + "github.com/example/test/graph" + "github.com/example/test/graph/generated" +) + +const defaultPort = "8080" + +func main() { + port := os.Getenv("PORT") + if port == "" { + port = defaultPort + } + + srv := handler.NewDefaultServer(generated.NewExecutableSchema(generated.Config{Resolvers: &graph.Resolver{}})) + + srv.AddTransport(&transport.Websocket{}) // <---- This is the important part! + + http.Handle("/", playground.Handler("GraphQL playground", "/query")) + http.Handle("/query", srv) + + log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) + log.Fatal(http.ListenAndServe(":"+port, nil)) +} +``` + +## Adding Subscriptions to your Schema + +Next you'll have to define the subscriptions in your schema in the `Subscription` top-level type. + +```graphql +""" +Make sure you have at least something in your `Query` type. +If you don't have a query the playground will be unable +to introspect your schema! +""" +type Query { + placeholder: String +} + +""" +`Time` is a simple type only containing the current time as +a unix epoch timestamp and a string timestamp. +""" +type Time { + unixTime: Int! + timeStamp: String! +} + +""" +`Subscription` is where all the subscriptions your clients can +request. You can use Schema Directives like normal to restrict +access. +""" +type Subscription { + """ + `currentTime` will return a stream of `Time` objects. + """ + currentTime: Time! +} +``` + +## Implementing your Resolver + +After regenerating your code with `go run github.com/niko0xdev/gqlgen generate` you'll find a +new resolver for your subscription. It will look like any other resolver, except it expects +a `<-chan *model.Time` (or whatever your type is). This is a +[channel](https://go.dev/tour/concurrency/2). Channels in Go are used to send objects to a +single receiver. + +The resolver for our example `currentTime` subscription looks as follows: + +```go +// CurrentTime is the resolver for the currentTime field. +func (r *subscriptionResolver) CurrentTime(ctx context.Context) (<-chan *model.Time, error) { + // First you'll need to `make()` your channel. Use your type here! + ch := make(chan *model.Time) + + // You can (and probably should) handle your channels in a central place outside of `schema.resolvers.go`. + // For this example we'll simply use a Goroutine with a simple loop. + go func() { + // Handle deregistration of the channel here. Note the `defer` + defer close(ch) + + for { + // In our example we'll send the current time every second. + time.Sleep(1 * time.Second) + fmt.Println("Tick") + + // Prepare your object. + currentTime := time.Now() + t := &model.Time{ + UnixTime: int(currentTime.Unix()), + TimeStamp: currentTime.Format(time.RFC3339), + } + + // The subscription may have got closed due to the client disconnecting. + // Hence we do send in a select block with a check for context cancellation. + // This avoids goroutine getting blocked forever or panicking, + select { + case <-ctx.Done(): // This runs when context gets cancelled. Subscription closes. + fmt.Println("Subscription Closed") + // Handle deregistration of the channel here. `close(ch)` + return // Remember to return to end the routine. + + case ch <- t: // This is the actual send. + // Our message went through, do nothing + } + } + }() + + // We return the channel and no error. + return ch, nil +} +``` + +## Trying it out + +To try out your new subscription visit your GraphQL playground. This is exposed on +`http://localhost:8080` by default. + +Use the following query: + +```graphql +subscription { + currentTime { + unixTime + timeStamp + } +} +``` + +Run your query and you should see a response updating with the current timestamp every +second. To gracefully stop the connection click the `Execute query` button again. + + +## Adding Server-Sent Events transport +You can use instead of WebSocket (or in addition) [Server-Sent Events](https://en.wikipedia.org/wiki/Server-sent_events) +as transport for subscriptions. This can have advantages and disadvantages over transport via WebSocket and requires a +compatible client library, for instance [graphql-sse](https://github.com/enisdenjo/graphql-sse). The connection between +server and client should be HTTP/2+. The client must send the subscription request via POST with +the header `accept: text/event-stream` and `content-type: application/json` in order to be accepted by the SSE transport. +The underling protocol is documented at [distinct connections mode](https://github.com/enisdenjo/graphql-sse/blob/master/PROTOCOL.md). + +Add the SSE transport as first of all other transports, as the order is important. For that reason, `New` instead of +`NewDefaultServer` will be used. +```go +srv := handler.New(generated.NewExecutableSchema(generated.Config{Resolvers: &graph.Resolver{}})) +srv.AddTransport(transport.SSE{}) // <---- This is the important + +// default server +srv.AddTransport(transport.Options{}) +srv.AddTransport(transport.GET{}) +srv.AddTransport(transport.POST{}) +srv.AddTransport(transport.MultipartForm{}) +srv.SetQueryCache(lru.New(1000)) +srv.Use(extension.Introspection{}) +srv.Use(extension.AutomaticPersistedQuery{ + Cache: lru.New(100), +}) +``` + +The GraphQL playground does not support SSE yet. You can try out the subscription via curl: +```bash +curl -N --request POST --url http://localhost:8080/query \ +--data '{"query":"subscription { currentTime { unixTime timeStamp } }"}' \ +-H "accept: text/event-stream" -H 'content-type: application/json' \ +--verbose +``` + +## Full Files + +Here are all files at the end of this tutorial. Only files changed from the end +of the quick start are listed. + +### main.go + +```go +package main + +import ( + "log" + "net/http" + "os" + + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" + "github.com/niko0xdev/gqlgen/graphql/playground" + "github.com/example/test/graph" + "github.com/example/test/graph/generated" +) + +const defaultPort = "8080" + +func main() { + port := os.Getenv("PORT") + if port == "" { + port = defaultPort + } + + srv := handler.NewDefaultServer(generated.NewExecutableSchema(generated.Config{Resolvers: &graph.Resolver{}})) + + srv.AddTransport(&transport.Websocket{}) + + http.Handle("/", playground.Handler("GraphQL playground", "/query")) + http.Handle("/query", srv) + + log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) + log.Fatal(http.ListenAndServe(":"+port, nil)) +} +``` + +### schema.graphqls + +```graphql +type Query { + placeholder: String +} + +type Time { + unixTime: Int! + timeStamp: String! +} + +type Subscription { + currentTime: Time! +} +``` + +### schema.resolvers.go + +```go +package graph + +// 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" + "fmt" + "time" + + "github.com/example/test/graph/generated" + "github.com/example/test/graph/model" +) + +// Placeholder is the resolver for the placeholder field. +func (r *queryResolver) Placeholder(ctx context.Context) (*string, error) { + str := "Hello World" + return &str, nil +} + +// CurrentTime is the resolver for the currentTime field. +func (r *subscriptionResolver) CurrentTime(ctx context.Context) (<-chan *model.Time, error) { + ch := make(chan *model.Time) + + go func() { + defer close(ch) + + for { + time.Sleep(1 * time.Second) + fmt.Println("Tick") + + currentTime := time.Now() + + t := &model.Time{ + UnixTime: int(currentTime.Unix()), + TimeStamp: currentTime.Format(time.RFC3339), + } + + select { + case <-ctx.Done(): + // Exit on cancellation + fmt.Println("Subscription closed.") + return + + case ch <- t: + // Our message went through, do nothing + } + + } + }() + return ch, nil +} + +// Query returns generated.QueryResolver implementation. +func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } + +// Subscription returns generated.SubscriptionResolver implementation. +func (r *Resolver) Subscription() generated.SubscriptionResolver { return &subscriptionResolver{r} } + +type queryResolver struct{ *Resolver } +type subscriptionResolver struct{ *Resolver } +``` diff --git a/docs/content/reference/apq.md b/docs/content/reference/apq.md new file mode 100644 index 0000000..0ba0d0c --- /dev/null +++ b/docs/content/reference/apq.md @@ -0,0 +1,80 @@ +--- +title: "Automatic persisted queries" +description: +linkTitle: "APQ" +menu: { main: { parent: 'reference', weight: 10 } } +--- + +When you work with GraphQL by default your queries are transferred with every request. That can waste significant +bandwidth. To avoid that you can use Automatic Persisted Queries (APQ). + +With APQ you send only query hash to the server. If hash is not found on a server then client makes a second request +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://www.apollographql.com/docs/resources/graphql-glossary/#automatic-persisted-queries-apq) documentation. + +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 +import ( + "context" + "time" + + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/handler/extension" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" + "github.com/go-redis/redis" +) + +type Cache struct { + client redis.UniversalClient + ttl time.Duration +} + +const apqPrefix = "apq:" + +func NewCache(redisAddress string, ttl time.Duration) (*Cache, error) { + client := redis.NewClient(&redis.Options{ + Addr: redisAddress, + }) + + err := client.Ping().Err() + if err != nil { + return nil, fmt.Errorf("could not create cache: %w", err) + } + + return &Cache{client: client, ttl: ttl}, nil +} + +func (c *Cache) Add(ctx context.Context, key string, value interface{}) { + c.client.Set(apqPrefix+key, value, c.ttl) +} + +func (c *Cache) Get(ctx context.Context, key string) (interface{}, bool) { + s, err := c.client.Get(apqPrefix + key).Result() + if err != nil { + return struct{}{}, false + } + return s, true +} + +func main() { + cache, err := NewCache(cfg.RedisAddress, 24*time.Hour) + if err != nil { + log.Fatalf("cannot create APQ redis cache: %v", err) + } + + c := Config{ Resolvers: &resolvers{} } + gqlHandler := handler.New( + generated.NewExecutableSchema(c), + ) + gqlHandler.AddTransport(transport.POST{}) + gqlHandler.Use(extension.AutomaticPersistedQuery{Cache: cache}) + http.Handle("/query", gqlHandler) +} +``` diff --git a/docs/content/reference/changesets.md b/docs/content/reference/changesets.md new file mode 100644 index 0000000..513eb67 --- /dev/null +++ b/docs/content/reference/changesets.md @@ -0,0 +1,70 @@ +--- +linkTitle: Changesets +title: Using maps as changesets +description: Falling back to map[string]interface{} to allow for presence checks. +menu: { main: { parent: 'reference', weight: 10 } } +--- + +Occasionally you need to distinguish presence from nil (undefined vs null). In gqlgen we do this using maps: + + +```graphql +type Mutation { + updateUser(id: ID!, changes: UserChanges!): User +} + +input UserChanges { + name: String + email: String +} +``` + +Then in config set the backing type to `map[string]interface{}` +```yaml +models: + UserChanges: + model: "map[string]interface{}" +``` + +After running go generate you should end up with a resolver that looks like this: +```go +func (r *mutationResolver) UpdateUser(ctx context.Context, id int, changes map[string]interface{}) (*User, error) { + u := fetchFromDb(id) + /// apply the changes + saveToDb(u) + return u, nil +} +``` + +Please note that map values are automatically coerced to the types defined in the schema. +This means that optional, nested inputs or scalars will conform to their expected types. + +We often use the mapstructure library to directly apply these changesets directly to the object using reflection: +```go + +func ApplyChanges(changes map[string]interface{}, to interface{}) error { + dec, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{ + ErrorUnused: true, + TagName: "json", + Result: to, + ZeroFields: true, + // This is needed to get mapstructure to call the gqlgen unmarshaler func for custom scalars (eg Date) + DecodeHook: func(a reflect.Type, b reflect.Type, v interface{}) (interface{}, error) { + if reflect.PtrTo(b).Implements(reflect.TypeOf((*graphql.Unmarshaler)(nil)).Elem()) { + resultType := reflect.New(b) + result := resultType.MethodByName("UnmarshalGQL").Call([]reflect.Value{reflect.ValueOf(v)}) + err, _ := result[0].Interface().(error) + return resultType.Elem().Interface(), err + } + + return v, nil + }, + }) + + if err != nil { + return err + } + + return dec.Decode(changes) +} +``` diff --git a/docs/content/reference/complexity.md b/docs/content/reference/complexity.md new file mode 100644 index 0000000..8086cc0 --- /dev/null +++ b/docs/content/reference/complexity.md @@ -0,0 +1,84 @@ +--- +title: "Preventing overly complex queries" +description: Avoid denial of service attacks by calculating query costs and limiting complexity. +linkTitle: Query Complexity +menu: { main: { parent: "reference", weight: 10 } } +--- + +GraphQL provides a powerful way to query your data, but putting great power in the hands of your API clients also exposes you to a risk of denial of service attacks. You can mitigate that risk with gqlgen by limiting the complexity of the queries you allow. + +## Expensive Queries + +Consider a schema that allows listing blog posts. Each blog post is also related to other posts. + +```graphql +type Query { + posts(count: Int = 10): [Post!]! +} + +type Post { + title: String! + text: String! + related(count: Int = 10): [Post!]! +} +``` + +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 + } + } + } + } +} +``` + +The size of the response grows exponentially with each additional level of the `related` field. Fortunately, gqlgen's `http.Handler` includes a way to guard against this type of query. + +## Limiting Query Complexity + +Limiting query complexity is as simple as specifying it with the provided extension package. + +```go +func main() { + c := Config{ Resolvers: &resolvers{} } + + srv := handler.NewDefaultServer(blog.NewExecutableSchema(c)) + srv.Use(extension.FixedComplexityLimit(5)) // This line is key + r.Handle("/query", srv) +} +``` + +Now any query with complexity greater than 5 is rejected by the API. By default, each field and level of depth adds one to the overall query complexity. You can also use `extension.ComplexityLimit` to dynamically configure the complexity limit per request. + +This helps, but we still have a problem: the `posts` and `related` fields, which return arrays, are much more expensive to resolve than the scalar `title` and `text` fields. However, the default complexity calculation weights them equally. It would make more sense to apply a higher cost to the array fields. + +## Custom Complexity Calculation + +To apply higher costs to certain fields, we can use custom complexity functions. + +```go +func main() { + c := Config{ Resolvers: &resolvers{} } + + 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.Use(extension.FixedComplexityLimit(5)) + http.Handle("/query", gqlHandler) +} +``` + +When we assign a function to the appropriate `Complexity` field, that function is used in the complexity calculation. Here, the `posts` and `related` fields are weighted according to the value of their `count` parameter. This means that the more posts a client requests, the higher the query complexity. And just like the size of the response would increase exponentially in our original query, the complexity would also increase exponentially, so any client trying to abuse the API would run into the limit very quickly. + +By applying a query complexity limit and specifying custom complexity functions in the right places, you can easily prevent clients from using a disproportionate amount of resources and disrupting your service. diff --git a/docs/content/reference/dataloaders.md b/docs/content/reference/dataloaders.md new file mode 100644 index 0000000..3f2f538 --- /dev/null +++ b/docs/content/reference/dataloaders.md @@ -0,0 +1,194 @@ +--- +title: "Optimizing N+1 database queries using Dataloaders" +description: Speeding up your GraphQL requests by reducing the number of round trips to the database. +linkTitle: Dataloaders +menu: { main: { parent: 'reference', weight: 10 } } +--- + +Dataloaders consolidate the retrieval of information into fewer, batched calls. This example demonstrates the value of dataloaders by consolidating many SQL queries into a single bulk query. + +## The Problem + +Imagine your graph has query that lists todos... + +```graphql +query { todos { user { name } } } +``` + +and the `todo.user` resolver reads the `User` from a database... +```go +func (r *todoResolver) User(ctx context.Context, obj *model.Todo) (*model.User, error) { + stmt, err := r.db.PrepareContext(ctx, "SELECT id, name FROM users WHERE id = ?") + if err != nil { + return nil, err + } + defer stmt.Close() + + rows, err := stmt.QueryContext(ctx, obj.UserID) + if err != nil { + return nil, err + } + defer rows.Close() + + if !rows.Next() { + return nil, rows.Err() + } + + var user model.User + if err := rows.Scan(&user.ID, &user.Name); err != nil { + return nil, err + } + return &user, nil +} + + +``` + +The query executor will call the `Query.Todos` resolver which does a `select * from todo` and returns `N` todos. If the nested `User` is selected, the above `UserRaw` resolver will run a separate query for each user, resulting in `N+1` database queries. + +eg: +```sql +SELECT id, todo, user_id FROM todo +SELECT id, name FROM users WHERE id = ? +SELECT id, name FROM users WHERE id = ? +SELECT id, name FROM users WHERE id = ? +SELECT id, name FROM users WHERE id = ? +SELECT id, name FROM users WHERE id = ? +SELECT id, name FROM users WHERE id = ? +``` + +Whats even worse? most of those todos are all owned by the same user! We can do better than this. + +## Dataloader + +Dataloaders allow us to consolidate the fetching of `todo.user` across all resolvers for a given GraphQL request into a single database query and even cache the results for subsequent requests. + +We're going to use [vikstrous/dataloadgen](https://github.com/vikstrous/dataloadgen) to implement a dataloader for bulk-fetching users. + +```bash +go get github.com/vikstrous/dataloadgen +``` + +Next, we implement a data loader and a middleware for injecting the data loader on a request context. + +```go +package loaders + +// import vikstrous/dataloadgen with your other imports +import ( + "context" + "database/sql" + "net/http" + "strings" + "time" + + "github.com/vikstrous/dataloadgen" +) + +type ctxKey string + +const ( + loadersKey = ctxKey("dataloaders") +) + +// userReader reads Users from a database +type userReader struct { + db *sql.DB +} + +// getUsers implements a batch function that can retrieve many users by ID, +// for use in a dataloader +func (u *userReader) getUsers(ctx context.Context, userIDs []string) ([]*model.User, []error) { + stmt, err := u.db.PrepareContext(ctx, `SELECT id, name FROM users WHERE id IN (?`+strings.Repeat(",?", len(userIDs)-1)+`)`) + if err != nil { + return nil, []error{err} + } + defer stmt.Close() + + rows, err := stmt.QueryContext(ctx, userIDs) + if err != nil { + return nil, []error{err} + } + defer rows.Close() + + users := make([]*model.User, 0, len(userIDs)) + errs := make([]error, 0, len(userIDs)) + for rows.Next() { + var user model.User + if err := rows.Scan(&user.ID, &user.Name); err != nil { + errs = append(errs, err) + continue + } + users = append(users, &user) + } + return users, errs +} + +// Loaders wrap your data loaders to inject via middleware +type Loaders struct { + UserLoader *dataloadgen.Loader[string, *model.User] +} + +// NewLoaders instantiates data loaders for the middleware +func NewLoaders(conn *sql.DB) *Loaders { + // define the data loader + ur := &userReader{db: conn} + return &Loaders{ + UserLoader: dataloadgen.NewLoader(ur.getUsers, dataloadgen.WithWait(time.Millisecond)), + } +} + +// Middleware injects data loaders into the context +func Middleware(conn *sql.DB, next http.Handler) http.Handler { + // return a middleware that injects the loader to the request context + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + loader := NewLoaders(conn) + r = r.WithContext(context.WithValue(r.Context(), loadersKey, loader)) + next.ServeHTTP(w, r) + }) +} + +// For returns the dataloader for a given context +func For(ctx context.Context) *Loaders { + return ctx.Value(loadersKey).(*Loaders) +} + +// GetUser returns single user by id efficiently +func GetUser(ctx context.Context, userID string) (*model.User, error) { + loaders := For(ctx) + return loaders.UserLoader.Load(ctx, userID) +} + +// GetUsers returns many users by ids efficiently +func GetUsers(ctx context.Context, userIDs []string) ([]*model.User, error) { + loaders := For(ctx) + return loaders.UserLoader.LoadAll(ctx, userIDs) +} + +``` + +Add the dataloader middleware to your server... +```go +// create the query handler +var srv http.Handler = handler.NewDefaultServer(generated.NewExecutableSchema(...)) +// wrap the query handler with middleware to inject dataloader in requests. +// pass in your dataloader dependencies, in this case the db connection. +srv = loaders.Middleware(db, srv) +// register the wrapped handler +http.Handle("/query", srv) +``` + +Now lets update our resolver to call the dataloader: +```go +func (r *todoResolver) User(ctx context.Context, obj *model.Todo) (*model.User, error) { + return loaders.GetUser(ctx, obj.UserID) +} +``` + +The end result? Just 2 queries! +```sql +SELECT id, todo, user_id FROM todo +SELECT id, name from user WHERE id IN (?,?,?,?,?) +``` + +You can see an end-to-end example [here](https://github.com/vikstrous/dataloadgen-example). \ No newline at end of file diff --git a/docs/content/reference/directives.md b/docs/content/reference/directives.md new file mode 100644 index 0000000..0343860 --- /dev/null +++ b/docs/content/reference/directives.md @@ -0,0 +1,74 @@ +--- +title: Using schema directives to implement permission checks +description: Implementing graphql schema directives in golang for permission checks. +linkTitle: Schema Directives +menu: { main: { parent: 'reference', weight: 10 } } +--- + +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. + +## Restricting access based on user role + +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 + +enum Role { + ADMIN + USER +} +``` + +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) +} +``` + +The arguments are: + - *ctx*: the parent context + - *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(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 + +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 := generated.Config{ Resolvers: &resolvers{} } + c.Directives.HasRole = func(ctx context.Context, obj interface{}, next graphql.Resolver, role model.Role) (interface{}, error) { + if !getCurrentUser(ctx).HasRole(role) { + // block calling the next resolver + return nil, fmt.Errorf("Access denied") + } + + // or let it pass through + return next(ctx) + } + + 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 new file mode 100644 index 0000000..7985304 --- /dev/null +++ b/docs/content/reference/errors.md @@ -0,0 +1,174 @@ +--- +linkTitle: Handling Errors +title: Sending custom error data in the graphql response +description: Customising graphql error types to send custom error data back to the client using gqlgen. +menu: { main: { parent: 'reference', weight: 10 } } +--- + +## Returning errors + +All resolvers simply return an error to be sent to the user. The assumption is that any error message returned +here is appropriate for end users. If certain messages aren't safe, customise the error presenter. + +### Multiple errors + +To return multiple errors you can call the `graphql.Error` functions like so: + +```go +package foo + +import ( + "context" + "errors" + + "github.com/vektah/gqlparser/v2/gqlerror" + "github.com/niko0xdev/gqlgen/graphql" +) + +// DoThings add errors to the stack. +func (r Query) DoThings(ctx context.Context) (bool, error) { + // Print a formatted string + graphql.AddErrorf(ctx, "Error %d", 1) + + // Pass an existing error out + graphql.AddError(ctx, gqlerror.Errorf("zzzzzt")) + + // Or fully customize the error + graphql.AddError(ctx, &gqlerror.Error{ + Path: graphql.GetPath(ctx), + Message: "A descriptive error message", + Extensions: map[string]interface{}{ + "code": "10-4", + }, + }) + + // And you can still return an error if you need + return false, gqlerror.Errorf("BOOM! Headshot") +} +``` + +They will be returned in the same order in the response, eg: +```json +{ + "data": { + "todo": null + }, + "errors": [ + { "message": "Error 1", "path": [ "todo" ] }, + { "message": "zzzzzt", "path": [ "todo" ] }, + { "message": "A descriptive error message", "path": [ "todo" ], "extensions": { "code": "10-4" } }, + { "message": "BOOM! Headshot", "path": [ "todo" ] } + ] +} +``` + +or you can simply return multiple errors + +```go +package foo + +import ( + "context" + "errors" + + "github.com/vektah/gqlparser/v2/gqlerror" + "github.com/niko0xdev/gqlgen/graphql" +) + +var errSomethingWrong = errors.New("some validation failed") + +// DoThingsReturnMultipleErrors collect errors and returns it if any. +func (r Query) DoThingsReturnMultipleErrors(ctx context.Context) (bool, error) { + errList := gqlerror.List{} + + // Add existing error + errList = append(errList, gqlerror.Wrap(errSomethingWrong)) + + // Create new formatted and append + errList = append(errList, gqlerror.Errorf("invalid value: %s", "invalid")) + + // Or fully customize the error and append + errList = append(errList, &gqlerror.Error{ + Path: graphql.GetPath(ctx), + Message: "A descriptive error message", + Extensions: map[string]interface{}{ + "code": "10-4", + }, + }) + + return false, errList +} +``` + +They will be returned in the same order in the response, eg: +```json +{ + "data": { + "todo": null + }, + "errors": [ + { "message": "some validation failed", "path": [ "todo" ] }, + { "message": "invalid value: invalid", "path": [ "todo" ] }, + { "message": "A descriptive error message", "path": [ "todo" ], "extensions": { "code": "10-4" } }, + ] +} +``` + +## Hooks + +### The error presenter + +All `errors` returned by resolvers, or from validation, pass through a hook before being displayed to the user. +This hook gives you the ability to customise errors however makes sense in your app. + +The default error presenter will capture the resolver path and use the Error() message in the response. + +You change this when creating the server: +```go +package bar + +import ( + "context" + "errors" + + "github.com/vektah/gqlparser/v2/gqlerror" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +func main() { + server := handler.NewDefaultServer(MakeExecutableSchema(resolvers)) + server.SetErrorPresenter(func(ctx context.Context, e error) *gqlerror.Error { + err := graphql.DefaultErrorPresenter(ctx, e) + + var myErr *MyError + if errors.As(e, &myErr) { + err.Message = "Eeek!" + } + + return err + }) +} + +``` + +This function will be called with the same resolver context that generated it, so you can extract the +current resolver path and whatever other state you might want to notify the client about. + + +### The panic handler + +There is also a panic handler, called whenever a panic happens to gracefully return a message to the user before +stopping parsing. This is a good spot to notify your bug tracker and send a custom message to the user. Any errors +returned from here will also go through the error presenter. + +You change this when creating the server: +```go +server := handler.NewDefaultServer(MakeExecutableSchema(resolvers)) +server.SetRecoverFunc(func(ctx context.Context, err interface{}) error { + // notify bug tracker... + + return gqlerror.Errorf("Internal server error!") +}) +``` + diff --git a/docs/content/reference/field-collection.md b/docs/content/reference/field-collection.md new file mode 100644 index 0000000..a45bddc --- /dev/null +++ b/docs/content/reference/field-collection.md @@ -0,0 +1,120 @@ +--- +title: 'Determining which fields were requested by a query' +description: How to determine which fields a query requested in a resolver. +linkTitle: Field Collection +menu: { main: { parent: 'reference', weight: 10 } } +--- + +Often it is useful to know which fields were queried for in a resolver. Having this information can allow a resolver to only fetch the set of fields required from a data source, rather than over-fetching everything and allowing gqlgen to do the rest. + +This process is known as [Field Collection](https://spec.graphql.org/draft/#sec-Field-Collection) — gqlgen automatically does this in order to know which fields should be a part of the response payload. The set of collected fields does however depend on the type being resolved. Queries can contain fragments, and resolvers can return interfaces and unions, therefore the set of collected fields cannot be fully determined until the type of the resolved object is known. + +Within a resolver, there are several API methods available to query the selected fields. + +## CollectAllFields + +`CollectAllFields` is the simplest way to get the set of queried fields. It will return a slice of strings of the field names from the query. This will be a unique set of fields, and will return all fragment fields, ignoring fragment Type Conditions. + +Given the following example query: + +```graphql +query { + foo { + fieldA + ... on Bar { + fieldB + } + ... on Baz { + fieldC + } + } +} +``` + +Calling `CollectAllFields` from a resolver will yield a string slice containing `fieldA`, `fieldB`, and `fieldC`. + +## CollectFieldsCtx + +`CollectFieldsCtx` is useful in cases where more information on matches is required, or the set of collected fields should match fragment type conditions for a resolved type. `CollectFieldsCtx` takes a `satisfies` parameter, which should be a slice of strings of types that the resolved type will satisfy. + +For example, given the following schema: + +```graphql +interface Shape { + area: Float +} +type Circle implements Shape { + radius: Float + area: Float +} +union Shapes = Circle +``` + +The type `Circle` would satisfy `Circle`, `Shape`, and `Shapes` — these values should be passed to `CollectFieldsCtx` to get the set of collected fields for a resolved `Circle` object. + +> Note +> +> `CollectFieldsCtx` is just a convenience wrapper around `CollectFields` that calls the later with the selection set automatically passed through from the resolver context. + +## Practical example + +Say we have the following GraphQL query + +```graphql +query { + flowBlocks { + id + block { + id + title + type + choices { + id + title + description + slug + } + } + } +} +``` + +We don't want to overfetch our database so we want to know which field are requested. +Here is an example which get's all requested field as convenient string slice, which can be easily checked. + +```golang +func GetPreloads(ctx context.Context) []string { + return GetNestedPreloads( + graphql.GetOperationContext(ctx), + graphql.CollectFieldsCtx(ctx, nil), + "", + ) +} + +func GetNestedPreloads(ctx *graphql.OperationContext, fields []graphql.CollectedField, prefix string) (preloads []string) { + for _, column := range fields { + prefixColumn := GetPreloadString(prefix, column.Name) + preloads = append(preloads, prefixColumn) + preloads = append(preloads, GetNestedPreloads(ctx, graphql.CollectFields(ctx, column.Selections, nil), prefixColumn)...) + } + return +} + +func GetPreloadString(prefix, name string) string { + if len(prefix) > 0 { + return prefix + "." + name + } + return name +} + +``` + +So if we call these helpers in our resolver: +```golang +func (r *queryResolver) FlowBlocks(ctx context.Context) ([]*FlowBlock, error) { + preloads := GetPreloads(ctx) +``` +it will result in the following string slice: +``` +["id", "block", "block.id", "block.title", "block.type", "block.choices", "block.choices.id", "block.choices.title", "block.choices.description", "block.choices.slug"] +``` diff --git a/docs/content/reference/file-upload.md b/docs/content/reference/file-upload.md new file mode 100644 index 0000000..06871c2 --- /dev/null +++ b/docs/content/reference/file-upload.md @@ -0,0 +1,173 @@ +--- +title: "File Upload" +description: How to upload files. +linkTitle: File Upload +menu: { main: { parent: "reference", weight: 10 } } +--- + +Graphql server has an already built-in Upload scalar to upload files using a multipart request. \ +It implements the following spec [https://github.com/jaydenseric/graphql-multipart-request-spec](https://github.com/jaydenseric/graphql-multipart-request-spec), +that defines an interoperable multipart form field structure for GraphQL requests, used by +various file upload client implementations. + +To use it you need to add the Upload scalar in your schema, and it will automatically add the +marshalling behaviour to Go types. + +# Configuration + +There are two specific options that can be configured for uploading files: + +- uploadMaxSize \ + This option specifies the maximum number of bytes used to parse a request body as multipart/form-data. +- uploadMaxMemory \ + This option specifies the maximum number of bytes used to parse a request body as + multipart/form-data in memory, with the remainder stored on disk in temporary files. + +# Examples + +## Single file upload + +For this use case, the schema could look like this. + +```graphql +"The `UploadFile, // b.txt` scalar type represents a multipart file upload." +scalar Upload + +"The `Query` type, represents all of the entry points into our object graph." +type Query { + ... +} + +"The `Mutation` type, represents all updates we can make to our data." +type Mutation { + singleUpload(file: Upload!): Boolean! +} +``` + +cURL can be used the make a query as follows: + +``` +curl localhost:4000/graphql \ + -F operations='{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) }", "variables": { "file": null } }' \ + -F map='{ "0": ["variables.file"] }' \ + -F 0=@a.txt +``` + +That invokes the following operation: + +```javascript +{ + query: ` + mutation($file: Upload!) { + singleUpload(file: $file) + } + `, + variables: { + file: File // a.txt + } +} +``` + +## Multiple file upload + +For this use case, the schema could look like this. + +```graphql +"The `Upload` scalar type represents a multipart file upload." +scalar Upload + +"The `File` type, represents the response of uploading a file." +type File { + id: Int! + name: String! + content: String! +} + +"The `UploadFile` type, represents the request for uploading a file with a certain payload." +input UploadFile { + id: Int! + file: Upload! +} + +"The `Query` type, represents all of the entry points into our object graph." +type Query { + ... +} + +"The `Mutation` type, represents all updates we can make to our data." +type Mutation { + multipleUpload(req: [UploadFile!]!): [File!]! +} + +``` + +cURL can be used the make a query as follows: + +```bash +curl localhost:4000/query \ + -F operations='{ "query": "mutation($req: [UploadFile!]!) { multipleUpload(req: $req) { id, name, content } }", "variables": { "req": [ { "id": 1, "file": null }, { "id": 2, "file": null } ] } }' \ + -F map='{ "0": ["variables.req.0.file"], "1": ["variables.req.1.file"] }' \ + -F 0=@b.txt \ + -F 1=@c.txt +``` + +That invokes the following operation: + +```javascript +{ + query: ` + mutation($req: [UploadFile!]!) + multipleUpload(req: $req) { + id, + name, + content + } + } + `, + variables: { + req: [ + { + id: 1, + File, // b.txt + }, + { + id: 2, + File, // c.txt + } + ] + } +} +``` + +See the [_examples/fileupload](https://github.com/niko0xdev/gqlgen/tree/master/_examples/fileupload) package for more examples. + +# Usage with Apollo + +[apollo-upload-client](https://github.com/jaydenseric/apollo-upload-client) needs to be installed in order for file uploading to work with Apollo: + +```javascript +import ApolloClient from "apollo-client"; +import { createUploadLink } from "apollo-upload-client"; + +const client = new ApolloClient({ + cache: new InMemoryCache(), + link: createUploadLink({ uri: "/graphql" }) +}); +``` + +A `File` object can then be passed into your mutation as a variable: + +```javascript +{ + query: ` + mutation($file: Upload!) { + singleUpload(file: $file) { + id + } + } + `, + variables: { + file: new File(...) + } +} +``` diff --git a/docs/content/reference/introspection.md b/docs/content/reference/introspection.md new file mode 100644 index 0000000..bd1dcfb --- /dev/null +++ b/docs/content/reference/introspection.md @@ -0,0 +1,37 @@ +--- +title: 'Disabling introspection' +description: Prevent users from introspecting schemas in production. +linkTitle: Introspection +menu: { main: { parent: 'reference', weight: 10 } } +--- + +One of the best features of GraphQL is it's powerful discoverability and its is automatically included when using `NewDefaultServer`. + +## Disable introspection for the whole server + +To opt out of introspection globally you should build your own server with only the features you use. For example a simple server that only does POST, and only has introspection in dev could look like: +```go +srv := handler.New(es) + +srv.AddTransport(transport.Options{}) +srv.AddTransport(transport.POST{}) + +if os.Getenv("ENVIRONMENT") == "development" { + srv.Use(extension.Introspection{}) +} +``` + +## Disabling introspection based on authentication + +Introspection can also be enabled on a per-request context basis. For example, you could modify it in a middleware based on user authentication: + +```go +srv := handler.NewDefaultServer(es) +srv.AroundOperations(func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler { + if !userForContext(ctx).IsAdmin { + graphql.GetOperationContext(ctx).DisableIntrospection = true + } + + return next(ctx) +}) +``` diff --git a/docs/content/reference/model-generation.md b/docs/content/reference/model-generation.md new file mode 100644 index 0000000..1ec40de --- /dev/null +++ b/docs/content/reference/model-generation.md @@ -0,0 +1,57 @@ +--- +title: Model generation +description: Examples of ways to alter generated model output +linkTitle: Model Generation +menu: { main: {parent: 'reference', weight: 10 }} +--- + +While we do our best to create Go models that are equivalent to their GraphQL counterparts, it can sometimes be +advantageous, or even necessary, to have control over some aspects of this output depending on runtime environment. + +## json ",omitempty" + +By default, fields that are marked as nullable in the GraphQL schema, e.g. `field: String` rather than `field: String!`, +have the [json ",omitempty"](https://pkg.go.dev/encoding/json#Marshal) field tag applied to them. This is probably fine +if the downstream consumers of json serialized representations of this model are all written in Go, but obviously this +is not always true. + +To that end, you expressly disable the addition of the `,omitempty` json field tag by setting the top-level +[config](https://gqlgen.com/config/) field `enable_model_json_omitempty_tag` to `false`: + +### Examples + +```graphql +# graphql + +type OmitEmptyJsonTagTest { + ValueNonNil: String! + Value: String +} +``` + +Without `enable_model_json_omitempty_tag` configured: + +```go +type OmitEmptyJSONTagTest struct { + ValueNonNil string `json:"ValueNonNil" database:"OmitEmptyJsonTagTestValueNonNil"` + Value *string `json:"Value,omitempty" database:"OmitEmptyJsonTagTestValue"` +} +``` + +With `enable_model_json_omitempty_tag: true` (same as un-configured): + +```go +type OmitEmptyJSONTagTest struct { + ValueNonNil string `json:"ValueNonNil" database:"OmitEmptyJsonTagTestValueNonNil"` + Value *string `json:"Value,omitempty" database:"OmitEmptyJsonTagTestValue"` +} +``` + +With `enable_model_json_omitempty_tag: false`: + +```go +type OmitEmptyJSONTagTest struct { + ValueNonNil string `json:"ValueNonNil" database:"OmitEmptyJsonTagTestValueNonNil"` + Value *string `json:"Value" database:"OmitEmptyJsonTagTestValue"` +} +``` diff --git a/docs/content/reference/name-collision.md b/docs/content/reference/name-collision.md new file mode 100644 index 0000000..09d8cd6 --- /dev/null +++ b/docs/content/reference/name-collision.md @@ -0,0 +1,223 @@ +--- +title: Handling type naming collisions +description: Examples of logic used to avoid type name collision +linkTitle: Name Collision +menu: { main: { parent: 'reference', weight: 10 }} +--- + +While most generated Golang types must have unique names by virtue of being based on their GraphQL `type` counterpart, +which themselves must be unique, there are a few edge scenarios where conflicts can occur. This document describes +how those collisions are handled. + +## Enum Constants + +Enum type generation is a prime example of where naming collisions can occur, as we build the const names per value +as a composite of the Enum name and each individual value. + +### Example Problem + +Currently, enum types are transposed as such: + +```graphql +# graphql + +enum MyEnum { + value1 + value2 + value3 + value4 +} +``` + +Which will result in the following Golang: + +```go +// golang + +type MyEnum string + +const ( + MyEnumValue1 MyEnum = "value1" + MyEnumValue2 MyEnum = "value2" + MyEnumValue3 MyEnum = "value3" + MyEnumValue4 MyEnum = "value4" +) +``` + +However, those above enum values are just strings. What if you encounter a scenario where the following is +necessary: + +```graphql +# graphql + +enum MyEnum { + value1 + value2 + value3 + value4 + Value4 + Value_4 +} +``` + +The `Value4` and `Value_4` enum values cannot be directly transposed into the same "pretty" naming convention as their +resulting constant names would conflict with the name for `value4`, as so: + +```go +// golang + +type MyEnum string + +const ( + MyEnumValue1 MyEnum = "value1" + MyEnumValue2 MyEnum = "value2" + MyEnumValue3 MyEnum = "value3" + MyEnumValue4 MyEnum = "value4" + MyEnumValue4 MyEnum = "Value4" + MyEnumValue4 MyEnum = "Value_4" +) +``` + +Which immediately leads to compilation errors as we now have three constants with the same name, but different values. + +### Resolution + +1. Store each name generated as part of a run for later comparison +2. Try to coerce name into `CapitalCase`. Use if no conflicts. + - This process attempts to break apart identifiers into "words", identified by separating on capital letters, + underscores, hyphens, and spaces. + - Each "word" is capitalized and appended to previous word. +3. If non-composite name, append integer to end of name, starting at 0 and going to `math.MaxInt` +4. If composite name, in reverse order, the pieces of the name have a less opinionated converter applied +5. If all else fails, append integer to end of name, starting at 0 and going to `math.MaxInt` + +The first step to produce a name that does not conflict with an existing name succeeds. + +## Examples + +### Example A +GraphQL: +```graphql +# graphql + +enum MyEnum { + Value + value + TitleValue + title_value +} +``` +Go: +```go +// golang + +type MyEnum string + +const ( + MyEnumValue MyEnum = "Value" + MyEnumvalue MyEnum = "value" + MyEnumTitleValue MyEnum = "TitleValue" + MyEnumtitle_value MyEnum = "title_value" +) +``` + +### Example B +GraphQL: +```graphql +# graphql + +enum MyEnum { + TitleValue + title_value + title_Value + Title_Value +} +``` +Go: +```go +// golang + +type MyEnum string + +const ( + MyEnumTitleValue MyEnum = "TitleValue" + MyEnumtitle_value MyEnum = "title_value" + MyEnumtitle_Value MyEnum = "title_Value" + MyEnumTitle_Value MyEnum = "Title_Value" +) +``` + +### Example C +GraphQL: +```graphql +# graphql + +enum MyEnum { + value + Value +} +``` +Go: +```go +// golang + +type MyEnum string + +const ( + MyEnumValue = "value" + MyEnumValue0 = "Value" +) +``` + +## Warning + +Name collision resolution is handled per-name, as they come in. If you change the order of an enum, you could very +well end up with the same constant resolving to a different value. + +Lets mutate [Example C](#example-c): + +### Example C - State A +GraphQL: +```graphql +# graphql + +enum MyEnum { + value + Value +} +``` +Go: +```go +// golang + +type MyEnum string + +const ( + MyEnumValue = "value" + MyEnumValue0 = "Value" +) +``` + +### Example C - State B +GraphQL: +```graphql +# graphql + +enum MyEnum { + Value + value +} +``` +Go: +```go +// golang + +type MyEnum string + +const ( + MyEnumValue = "Value" + MyEnumValue0 = "value" +) +``` + +Notice how the constant names are the same, but the value that each applies to has changed. diff --git a/docs/content/reference/plugins.md b/docs/content/reference/plugins.md new file mode 100644 index 0000000..9cee480 --- /dev/null +++ b/docs/content/reference/plugins.md @@ -0,0 +1,65 @@ +--- +linkTitle: Plugins +title: How to write plugins for gqlgen +description: Use plugins to customize code generation and integrate with other libraries +menu: { main: { parent: "reference", weight: 10 } } +--- + +Plugins provide a way to hook into the gqlgen code generation lifecycle. In order to use anything other than the +default plugins you will need to create your own entrypoint: + +## Using a plugin + +To use a plugin during code generation, you need to create a new entry point. Create `generate.go` in the same folder as `resolver.go` with the following code: + +```go +// go:build ignore + +package main + +import ( + "flag" + "fmt" + "io" + "log" + "os" + "time" + + "github.com/niko0xdev/gqlgen/api" + "github.com/niko0xdev/gqlgen/codegen/config" + "github.com/niko0xdev/gqlgen/plugin/stubgen" +) + +func main() { + cfg, err := config.LoadConfigFromDefaultLocations() + if err != nil { + fmt.Fprintln(os.Stderr, "failed to load config", err.Error()) + os.Exit(2) + } + + + err = api.Generate(cfg, + api.AddPlugin(yourplugin.New()), // This is the magic line + ) + if err != nil { + fmt.Fprintln(os.Stderr, err.Error()) + os.Exit(3) + } +} + +``` + +In `resolver.go`, add `//go:generate go run generate.go`. Now you can run `go generate ./...` instead of `go run github.com/niko0xdev/gqlgen generate` to generate the code. + +## Writing a plugin + +There are currently only two hooks: + +- MutateConfig: Allows a plugin to mutate the config before codegen starts. This allows plugins to add + custom directives, define types, and implement resolvers. see + [modelgen](https://github.com/niko0xdev/gqlgen/tree/master/plugin/modelgen) for an example +- GenerateCode: Allows a plugin to generate a new output file, see + [stubgen](https://github.com/niko0xdev/gqlgen/tree/master/plugin/stubgen) for an example + +Take a look at [plugin.go](https://github.com/niko0xdev/gqlgen/blob/master/plugin/plugin.go) for the full list of +available hooks. These are likely to change with each release. diff --git a/docs/content/reference/resolvers.md b/docs/content/reference/resolvers.md new file mode 100644 index 0000000..d4a1157 --- /dev/null +++ b/docs/content/reference/resolvers.md @@ -0,0 +1,227 @@ +--- +linkTitle: Resolvers +title: Resolving graphQL requests +description: Different ways of binding graphQL requests to resolvers +menu: { main: { parent: 'reference', weight: 10 } } +--- + +There are multiple ways that a graphQL type can be bound to a Go struct that allows for many usecases. + + +## Bind directly to struct field names +This is the most common use case where the names of the fields on the Go struct match the names of the +fields in the graphQL type. If a Go struct field is unexported, it will not be bound to the graphQL type. + +```go +type Car struct { + Make string + Model string + Color string + OdometerReading int +} +``` + +And then in your graphQL schema: +```graphql +type Car { + make: String! + model: String! + color: String! + odometerReading: Int! +} +``` + +And in the gqlgen config file: +```yaml +models: + Car: + model: github.com/my/app/models.Car +``` + +In this case, each field in the graphQL type will be bound to the respective field on the go struct +ignoring the case of the fields + + +## Bind to a method name + +This is also very common use case that comes up where we want to bind a graphQL field to a Go struct method + +```go +type Person struct { + Name string +} + +type Car struct { + Make string + Model string + Color string + OwnerID *string + OdometerReading int +} + +func (c *Car) Owner() (*Person) { + // get the car owner + //.... + return owner +} +``` + +And then in your graphQL schema: +```graphql +type Car { + make: String! + model: String! + color: String! + odometerReading: Int! + owner: Person +} +``` + +And in the gqlgen config file: +```yaml +models: + Car: + model: github.com/my/app/models.Car + Person: + model: github.com/my/app/models.Person +``` + +Here, we see that there is a method on car with the name ```Owner```, thus the ```Owner``` function will be called if +a graphQL request includes that field to be resolved. + +Model methods can optionally take a context as their first argument. If a +context is required, the model method will also be run in parallel. + +## Bind when the field names do not match + +There are two ways you can bind to fields when the the Go struct and the graphQL type do not match. + + +The first way is you can bind resolvers to a struct based off of struct tags like the following: + +```go +type Car struct { + Make string + ShortState string + LongState string `gqlgen:"state"` + Model string + Color string + OdometerReading int +} +``` + +And then in your graphQL schema: +```graphql +type Car { + make: String! + model: String! + state: String! + color: String! + odometerReading: Int! +} +``` + +And in the gqlgen config file add the line: +```yaml +struct_tag: gqlgen + +models: + Car: + model: github.com/my/app/models.Car +``` + +Here even though the graphQL type and Go struct have different field names, there is a Go struct tag field on ```longState``` +that matches and thus ```state``` will be bound to ```LongState```. + + +The second way you can bind fields is by adding a line into the config file such as: +```go +type Car struct { + Make string + ShortState string + LongState string + Model string + Color string + OdometerReading int +} +``` + +And then in your graphQL schema: +```graphql +type Car { + make: String! + model: String! + state: String! + color: String! + odometerReading: Int! +} +``` + +And in the gqlgen config file add the line: +```yaml +models: + Car: + model: github.com/my/app/models.Car + fields: + state: + fieldName: LongState +``` + +## Binding to Anonymous or Embedded Structs +All of the rules from above apply to a struct that has an embedded struct. +Here is an example +```go +type Truck struct { + Car + + Is4x4 bool +} + +type Car struct { + Make string + ShortState string + LongState string + Model string + Color string + OdometerReading int +} +``` + +And then in your graphQL schema: +```graphql +type Truck { + make: String! + model: String! + state: String! + color: String! + odometerReading: Int! + is4x4: Bool! +} +``` + +Here all the fields from the Go struct Car will still be bound to the respective fields in the graphQL schema that match + +Embedded structs are a good way to create thin wrappers around data access types an example would be: + +```go +type Cat struct { + db.Cat + //... +} + +func (c *Cat) ID() string { + // return a custom id based on the db shard and the cat's id + return fmt.Sprintf("%d:%d", c.Shard, c.Id) +} +``` + +Which would correlate with a gqlgen config file of: +```yaml +models: + Cat: + model: github.com/my/app/models.Cat +``` + +## Binding Priority +If a ```struct_tags``` config exists, then struct tag binding has the highest priority over all other types of binding. +In all other cases, the first Go struct field found that matches the graphQL type field will be the field that is bound. diff --git a/docs/content/reference/scalars.md b/docs/content/reference/scalars.md new file mode 100644 index 0000000..6a06f95 --- /dev/null +++ b/docs/content/reference/scalars.md @@ -0,0 +1,291 @@ +--- +linkTitle: Scalars +title: Mapping GraphQL scalar types to Go types +description: Mapping GraphQL scalar types to Go types +menu: { main: { parent: "reference", weight: 10 } } +--- + +## Built-in helpers + +gqlgen ships with some built-in helpers for common custom scalar use-cases, `Time`, `Any`, `Upload` and `Map`. +Adding any of these to a schema will automatically add the marshalling behaviour to Go types. + +### Time + +```graphql +scalar Time +``` + +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. + +### Universally Unique Identifier (UUID) + +```graphql +scalar UUID +``` +This maps a `UUID` scalar value to a `uuid.UUID` type. + +If you add to gqlgen.yml: +```yaml +models: + UUID: + model: + - github.com/niko0xdev/gqlgen/graphql.UUID +``` + +And then add `scalar UUID` to `schema.graphql` + +See the _examples/uuid package for more examples. + +### Map + +```graphql +scalar Map +``` + +Maps an arbitrary GraphQL value to a `map[string]interface{}` Go type. + +### Upload + +```graphql +scalar Upload +``` + +Maps a `Upload` GraphQL scalar to a `graphql.Upload` struct, defined as follows: + +```go +type Upload struct { + File io.ReadSeeker + Filename string + Size int64 + ContentType string +} +``` + +### Any + +```graphql +scalar Any +``` + +Maps an arbitrary GraphQL value to a `interface{}` Go type. + +### Duration + +```graphql +scalar Duration +``` +This maps a `Duration` scalar value conforming to the `ISO8601` standard (ex.: `P1Y2D`) to a `time.Duration` type. + +If you add to gqlgen.yml: +```yaml +models: + Duration: + model: + - github.com/niko0xdev/gqlgen/graphql.Duration +``` + +And then add `scalar Duration` to `schema.graphql` + +## Custom scalars with user defined types + +For user defined types you can implement the [graphql.Marshaler](https://pkg.go.dev/github.com/niko0xdev/gqlgen/graphql#Marshaler) and [graphql.Unmarshaler](https://pkg.go.dev/github.com/niko0xdev/gqlgen/graphql#Unmarshaler) or implement the [graphql.ContextMarshaler](https://pkg.go.dev/github.com/niko0xdev/gqlgen/graphql#ContextMarshaler) and [graphql.ContextUnmarshaler](https://pkg.go.dev/github.com/niko0xdev/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 +func (y *YesNo) UnmarshalGQL(v interface{}) error { + yes, ok := v.(string) + if !ok { + return fmt.Errorf("YesNo must be a string") + } + + if yes == "yes" { + *y = true + } else { + *y = false + } + return nil +} + +// MarshalGQL implements the graphql.Marshaler interface +func (y YesNo) MarshalGQL(w io.Writer) { + if y { + w.Write([]byte(`"yes"`)) + } else { + 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: + +```yaml +models: + YesNo: + model: github.com/me/mypkg.YesNo +``` + +## Custom scalars with third party types + +Sometimes you are unable to add add methods to a type — perhaps you don't own the type, or it is part of the standard +library (eg `string` or `time.Time`). To support this we can build an external marshaler: + +```go +package mypkg + +import ( + "fmt" + "io" + "strings" + + "github.com/niko0xdev/gqlgen/graphql" +) + + +func MarshalMyCustomBooleanScalar(b bool) graphql.Marshaler { + return graphql.WriterFunc(func(w io.Writer) { + if b { + w.Write([]byte("true")) + } else { + w.Write([]byte("false")) + } + }) +} + +func UnmarshalMyCustomBooleanScalar(v interface{}) (bool, error) { + switch v := v.(type) { + case string: + return "true" == strings.ToLower(v), nil + case int: + return v != 0, nil + case bool: + return v, nil + default: + return false, fmt.Errorf("%T is not a bool", v) + } +} +``` + +Then in `.gqlgen.yml` point to the name without the Marshal|Unmarshal in front: + +```yaml +models: + MyCustomBooleanScalar: + model: github.com/me/mypkg.MyCustomBooleanScalar +``` + +**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 [_examples/scalars](https://github.com/niko0xdev/gqlgen/tree/master/_examples/scalars) package for more examples. + +## Marshaling/Unmarshaling Errors + +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 +extend type Mutation{ + updateUser(userInput: UserInput!): User! +} + +input UserInput { + name: String! + primaryContactDetails: ContactDetailsInput! + secondaryContactDetails: ContactDetailsInput! +} + +scalar Email + +input ContactDetailsInput { + email: Email! +} +``` + +... and the following variables: + +```json +{ + "userInput": { + "name": "George", + "primaryContactDetails": { + "email": "not-an-email" + }, + "secondaryContactDetails": { + "email": "george@gmail.com" + } + } +} +``` + +... and an unmarshal function that returns an error if the email is invalid. +The mutation will return an error containing the full path: + +```json +{ + "message": "email invalid", + "path": [ + "updateUser", + "userInput", + "primaryContactDetails", + "email" + ] +} +``` + +**Note:** Marshaling errors can only be returned when using the `graphql.ContextMarshaler` style interface. diff --git a/docs/layouts/404.html b/docs/layouts/404.html new file mode 100644 index 0000000..6c298de --- /dev/null +++ b/docs/layouts/404.html @@ -0,0 +1,5 @@ +{{ define "main" }} +

Page not found

+ + I'm sorry, but the requested page wasn’t found on the server. +{{ end }} \ No newline at end of file diff --git a/docs/layouts/_default/baseof.html b/docs/layouts/_default/baseof.html new file mode 100644 index 0000000..41083c0 --- /dev/null +++ b/docs/layouts/_default/baseof.html @@ -0,0 +1,34 @@ + + + + + + {{- if .Params.description }} + {{- else }} + {{- end }} + + {{ if not .IsHome }}{{ .Title }} —{{ end }} {{ .Site.Title }} + + + + + + + + + + + + + + {{ partial "version-switcher" . }} + {{ partial "sidebar" . }} {{ block "main" . }}{{ end }} + + + diff --git a/docs/layouts/_default/single.html b/docs/layouts/_default/single.html new file mode 100644 index 0000000..2eb8631 --- /dev/null +++ b/docs/layouts/_default/single.html @@ -0,0 +1,20 @@ +{{ define "main" }} +
+
+

{{ .LinkTitle }}

+
{{ .Title }}
+ + [edit] + +
+
+ +
+
+ {{partial "version-banner"}} + {{ .Content }} +
+
+{{ end }} diff --git a/docs/layouts/index.html b/docs/layouts/index.html new file mode 100644 index 0000000..c8f0b7b --- /dev/null +++ b/docs/layouts/index.html @@ -0,0 +1,23 @@ +{{ define "main" }} + {{ range where .Site.Pages "Type" "homepage" }} +
+ {{ .Description }} +
+

{{ .LinkTitle }}

+
{{ .Title }}
+
+
+ +
+
+ {{partial "version-banner"}} + {{ .Content }} + {{.Scratch.Set "intro" (readFile "content/_introduction.md")}} + {{.Scratch.Set "intro" (split (.Scratch.Get "intro") "\n")}} + {{.Scratch.Set "intro" (after 2 (.Scratch.Get "intro"))}} + {{.Scratch.Set "intro" (delimit (.Scratch.Get "intro") "\n")}} + {{.Scratch.Get "intro"|markdownify}} +
+
+ {{ end }} +{{ end }} diff --git a/docs/layouts/partials/gqlgen.svg b/docs/layouts/partials/gqlgen.svg new file mode 100644 index 0000000..e0f1638 --- /dev/null +++ b/docs/layouts/partials/gqlgen.svg @@ -0,0 +1 @@ + diff --git a/docs/layouts/partials/sidebar.html b/docs/layouts/partials/sidebar.html new file mode 100644 index 0000000..140356b --- /dev/null +++ b/docs/layouts/partials/sidebar.html @@ -0,0 +1,44 @@ + + + diff --git a/docs/layouts/partials/version-banner.html b/docs/layouts/partials/version-banner.html new file mode 100644 index 0000000..924c505 --- /dev/null +++ b/docs/layouts/partials/version-banner.html @@ -0,0 +1,14 @@ +{{ $currentVersion := getenv "CURRENT_VERSION" }} +{{ $versionString := getenv "VERSIONS" }} +{{ $versions := split $versionString "," }} +{{ $latestVersion := index $versions 0 }} + +{{ if (eq $currentVersion "master") }} +
+ You are looking at the docs for the unreleased master branch. The latest version is {{ $latestVersion }}. +
+{{ else if not (eq $latestVersion $currentVersion) }} +
+ You are looking at the docs for an older version ({{ $currentVersion }}). The latest version is {{ $latestVersion }}. +
+{{ end }} diff --git a/docs/layouts/partials/version-switcher.html b/docs/layouts/partials/version-switcher.html new file mode 100644 index 0000000..18041c8 --- /dev/null +++ b/docs/layouts/partials/version-switcher.html @@ -0,0 +1,15 @@ +{{ $VersionString := getenv "VERSIONS" }} +{{ $Versions := split $VersionString "," }} +{{ $currentVersion := getenv "CURRENT_VERSION" }} + +
+ {{ $currentVersion }} +
+ {{$currentVersion}} + {{ range $i, $version := $Versions }} + {{ if not (eq $currentVersion $version) }} + {{$version}} + {{ end }} + {{ end }} +
+
diff --git a/docs/layouts/sitemap.xml b/docs/layouts/sitemap.xml new file mode 100644 index 0000000..b5a19b0 --- /dev/null +++ b/docs/layouts/sitemap.xml @@ -0,0 +1,13 @@ + + {{ range .Data.Pages }} + {{ if or .Description (eq .Kind "home") }} + + {{ .Permalink }} + {{ if not .Lastmod.IsZero }}{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}{{ end }} + {{ with .Sitemap.ChangeFreq }}{{ . }}{{ end }} + {{ if ge .Sitemap.Priority 0.0 }}{{ .Sitemap.Priority }}{{ end }} + + {{ end }} + {{ end }} + + diff --git a/docs/readme.md b/docs/readme.md new file mode 100644 index 0000000..83bd7b7 --- /dev/null +++ b/docs/readme.md @@ -0,0 +1,20 @@ +Documentation +==== + +This directory contains the markdown source files for the static doc site hosted at [gqlgen.com](https://gqlgen.com) + + +## Install hugo + +Before working with these docs you will need to install hugo, see [Quickstart](https://gohugo.io/getting-started/quick-start/) for instructions. + + +## Editing docs + +When editing docs run `hugo serve` and a live reload server will start, then navigate to http://localhost:1313 in your browser. Any changes made will be updated in the browser. + + +## Publishing docs + +Docs are hosted using [render.com](https://render.com/) and will be automatically deployed when merging to master. + diff --git a/docs/static/external-link-alt.svg b/docs/static/external-link-alt.svg new file mode 100644 index 0000000..fb0c7ad --- /dev/null +++ b/docs/static/external-link-alt.svg @@ -0,0 +1,5 @@ + + diff --git a/docs/static/favicon.ico b/docs/static/favicon.ico new file mode 100644 index 0000000..b136cce Binary files /dev/null and b/docs/static/favicon.ico differ diff --git a/docs/static/main.css b/docs/static/main.css new file mode 100644 index 0000000..ed49726 --- /dev/null +++ b/docs/static/main.css @@ -0,0 +1,545 @@ +:root { + --font-text: 'Roboto', sans-serif; + --font-heading: 'Work Sans', sans-serif; + --font-code: 'Source Code Pro', monospace; + + --main-bg-color: coral; + + --color-link: #336699; + --color-text: #556; + + --color-heading-text: #445; + --color-heading-background: #e9ebed; + + --color-nav-text: #eee; + --color-nav-background: #0A215C; + --color-nav-active: #284578; + + --color-anchor-default: #DDD; + --color-anchor-hover: #666; + + --color-code-text: #445; + --color-code-background: #f5f9fc; + + --color-blockquote-background: #fffaf3; + --color-blockquote-highlight: rgba(0, 0, 0, 0.1); + + --margin-default: 15px; +} + +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, aside, details, figcaption, figure, +footer, header, hgroup, menu, nav, section { + display: block; +} +ol, ul { + margin-bottom: var(--margin-default); + list-style: disc; + margin-left: 1.5em; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, +q:before, q:after { + content: ''; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; +} + +body { + font-family: var(--font-text); + font-size: 15px; + line-height: 1.55em; + display: flex; + flex-direction: column; + min-height: 100vh; +} + +a { + color: var(--color-link); + text-decoration: none; +} + +img { + max-width: 100%; +} + +a:hover { + text-decoration: underline; +} + +@media (min-width: 768px) { + body { + display: grid; + grid-template: + 'logo header' + 'nav content' + 'nav footer'; + grid-template-columns: 200px 1fr; + grid-template-rows: min-content auto min-content; + } +} + +main { + flex: 1; + padding: 0 20px 20px; + color: var(--color-text); +} + +.content { + position: relative; + grid-area: content; + max-width: 920px; + margin: auto; +} + +main .content { + margin-top: 40px; +} + +header { + grid-area: header; + background: var(--color-heading-background); + padding: 45px 20px; + overflow: hidden; +} + +footer { + padding: 2px; + text-align: center; + font-size: 0.7em; + color: var(--color-heading-text); +} + +h1,h2,h3,h4,h5,h6 { + font-family: var(--font-heading); + color: #445; +} + +h1 { + font-size: 25px; + font-weight: 700; + margin: 15px 0 10px 0; + position: relative; +} + +.description { + font-family: 'Work Sans', sans-serif; + font-size: 18px; + color: var(--color-text); +} + +.header-link { + position: absolute; + top: 0; + right: 0; +} + +h2 { + margin-top: 2em; + margin-bottom: var(--margin-default); + font-size: 19px; + font-weight: 700; +} + +h3 { + margin-top: 1.5em; + margin-bottom: var(--margin-default); + font-size: 16px; + font-weight: 500; +} + +p { + margin-bottom: var(--margin-default); +} + +nav { + grid-area: nav; + color: var(--color-nav-text); + background-color: var(--color-nav-background); + font-family: var(--font-heading); + font-weight: 500; +} + +.menu { + +} + +.menu a { + color: inherit; +} + +.menu a:hover { + text-decoration: none; +} + +.menu-item { + display: block; + padding: 5px 10px; +} + +.submenu .menu-item { + padding: 5px 20px; +} + +.submenu-heading { + margin-top: 15px; +} + +ul.menu { + margin-left:0; + list-style: none; +} + +ul.submenu { + margin-left: 0; + list-style: none; + margin-bottom: 0; +} + +ul.submenu span { + padding: 5px 10px; +} + +ul.menu li.active, +ul.menu a:hover { + background-color: var(--color-nav-active); +} + +.layout--logo { + grid-area: logo; + background-color: var(--color-nav-background); +} + +.logo { + grid-area: logo; + color: #eee; + margin: 15px; + text-align: center; + display: block; +} + +.logo svg { + fill: currentColor; + max-width: 30px; +} + +.logo--name { + vertical-align: top; + height: 100%; + font-size: 30px; +} + +.logo:hover { + text-decoration: none; +} + +code { + font-family: var(--font-code); + font-weight: 500; + color: var(--color-code-text); + background-color: var(--color-code-background); + border-radius: 3px; + display: inline-block; + padding: 0px 5px; + font-size: 13px; + line-height: 1.5; +} + +pre > code { + overflow: auto; + display: block; + padding: 5px 10px; + margin-bottom: var(--margin-default); +} + +strong { + font-weight: 700; +} + +em { + font-style: italic; +} + +.anchor-link { + display: inline-block; +} + +.anchor-link:hover { + text-decoration: none; +} + +.anchor-icon { + fill: var(--color-anchor-default); + display: inline-block; + vertical-align: middle; + padding: 0 5px; + width: 14px; +} + +.anchor-icon:hover { + fill: var(--color-anchor-hover); +} + +@media (min-width: 768px) { + .logo { + margin: 20px 50px; + + } + .logo svg { + max-width: none; + margin: 5px; + } + nav input { + display: none; + } +} + +/* pure css hamburger, adapted from https://codepen.io/erikterwan/pen/EVzeRP */ + +@media (max-width: 767px) { + .layout--logo { + z-index: 2; + } + + nav { + -webkit-user-select: none; + user-select: none; + + } + + .hamburger { + position: absolute; + top: 0px; + left: 0px; + margin: 15px; + z-index: 3; + } + + nav input { + display: block; + width: 70px; + height: 70px; + position: absolute; + top: -7px; + left: -5px; + + cursor: pointer; + + opacity: 0; /* hide this */ + z-index: 4; /* and place it over the hamburger */ + + -webkit-touch-callout: none; + } + + .hamburger span { + display: block; + width: 28px; + height: 4px; + margin: 5px; + position: relative; + background: currentColor; + border-radius: 3px; + z-index: 1; + transform-origin: 0 1.5px; + + transition: transform 0.5s cubic-bezier(0.77, 0.2, 0.05, 1.0), + background 0.5s cubic-bezier(0.77, 0.2, 0.05, 1.0), + opacity 0.55s ease; + } + + nav input:checked ~ .hamburger span { + opacity: 1; + transform: rotate(45deg) translate(-2px, -1px); + } + + nav input:checked ~ .hamburger span:nth-last-child(2) { + opacity: 0; + transform: rotate(0deg) scale(0.2, 0.2); + } + + nav input:checked ~ .hamburger span:nth-last-child(1) { + transform: rotate(-45deg) translate(0, -1px); + } + + .menu { + z-index: 1; + position: absolute; + width: 300px; + height: 100%; + margin: -100px 0 0 -50px; + padding: 150px 0; + + color: var(--color-heading-text); + background-color: var(--color-heading-background); + font-family: var(--font-heading); + + list-style-type: none; + -webkit-font-smoothing: antialiased; + /* to stop flickering of text in safari */ + + transform-origin: 0% 0%; + transform: translate(-100%, 0); + + transition: transform 0.5s cubic-bezier(0.77, 0.2, 0.05, 1.0); + } + + ul.menu li.active, + ul.menu a:hover { + background-color: #d3d5d7; + } + + nav input:checked ~ ul { + transform: none; + } + +} + + +blockquote { + background-color: var(--color-blockquote-background); + border-left-color: var(--color-blockquote-highlight); + border-left-width: 9px; + border-left-style: solid; + padding: 1em 20px 1em 11px; + margin-bottom: var(--margin-default); + margin-left: -20px; + margin-right: -20px; +} + +blockquote p { + margin-bottom: 0; +} + +/* Blockquote headings. */ +blockquote p:first-of-type { + font-weight: bold; +} + +blockquote code { + background-color: var(--color-blockquote-highlight); +} + +table { + width: 100%; +} + +td, th { + padding: 0.2em 1em; +} + +tr { + border-bottom: 1px solid var(--color-heading-background); +} + +tr td:first-child, th { + font-weight: bold; +} + +.version-switcher { + position: absolute; + top: 18px; + right: 16px; + display: inline-block; + width: 80px; + z-index: 3; + color: white; +} + + +.version-switcher-options { + display: none; + /*opacity: 40%;*/ + color: var(--color-text); + position: absolute; + top: 0; + right: 0; + background-color: #f9f9f9; + width: 80px; + box-shadow: 0px 3px 7px 0px rgba(0,0,0,0.2); + z-index: 2; +} + +@media (min-width: 768px) { + .version-switcher { + color: var(--color-text); + } +} + +.version-switcher-options a, .version-switcher span { + list-style-type: none; + padding: 3px 10px; + display: block; + cursor: pointer; + font-family: var(--font-code); +} + +.version-switcher-options a { + color: var(--color-text); +} + +.version-switcher-options a:hover { + background: #bbb; + text-decoration: none; +} + +.version-switcher-options a:first-child { + background: #ccc; +} + +.version-switcher:hover .version-switcher-options { + display: block; +} + +.alert-warning { + background-color: rgba(255, 85, 35, 0.84); + padding: 10px; + color: white; + font-weight: bolder; +} + +.alert-warning a { + color: #ff6; +} + +.icon { + display: inline-block; + line-height: .75em; + width: 1em; +} + +.icon svg { + display: block; +} + +.icon svg path { + fill: currentColor; +} + +ul.submenu span.icon { + padding: 0; +} diff --git a/docs/static/main.js b/docs/static/main.js new file mode 100644 index 0000000..189d660 --- /dev/null +++ b/docs/static/main.js @@ -0,0 +1,32 @@ +var anchorForId = function (id) { + var anchor = document.createElement("a"); + anchor.className = "anchor-link"; + anchor.href = "#" + id; + anchor.innerHTML = ' '; + return anchor; +}; + +var linkifyAnchors = function (level, containingElement) { + var headers = containingElement.getElementsByTagName("h" + level); + for (var h = 0; h < headers.length; h++) { + var header = headers[h]; + + if (typeof header.id !== "undefined" && header.id !== "") { + header.appendChild(anchorForId(header.id)); + + } + } +}; + + +document.onreadystatechange = function () { + if (this.readyState === "complete") { + var contentBlock = document.getElementsByTagName("body")[0] + if (!contentBlock) { + return; + } + for (var level = 2; level <= 4; level++) { + linkifyAnchors(level, contentBlock); + } + } +}; diff --git a/docs/static/request_anatomy.png b/docs/static/request_anatomy.png new file mode 100644 index 0000000..3254765 Binary files /dev/null and b/docs/static/request_anatomy.png differ diff --git a/docs/static/schema_layout.png b/docs/static/schema_layout.png new file mode 100644 index 0000000..66b1a04 Binary files /dev/null and b/docs/static/schema_layout.png differ diff --git a/docs/static/syntax.css b/docs/static/syntax.css new file mode 100644 index 0000000..4f561d4 --- /dev/null +++ b/docs/static/syntax.css @@ -0,0 +1,57 @@ +.chroma .c { color: #aaaaaa; font-style: italic } /* Comment */ +.chroma .err { color: #F00000; background-color: #F0A0A0 } /* Error */ +.chroma .k { color: #0000aa } /* Keyword */ +.chroma .cm { color: #aaaaaa; font-style: italic } /* Comment.Multiline */ +.chroma .cp { color: #4c8317 } /* Comment.Preproc */ +.chroma .c1 { color: #aaaaaa; font-style: italic } /* Comment.Single */ +.chroma .cs { color: #0000aa; font-style: italic } /* Comment.Special */ +.chroma .gd { color: #aa0000 } /* Generic.Deleted */ +.chroma .ge { font-style: italic } /* Generic.Emph */ +.chroma .gr { color: #aa0000 } /* Generic.Error */ +.chroma .gh { color: #000080; font-weight: bold } /* Generic.Heading */ +.chroma .gi { color: #00aa00 } /* Generic.Inserted */ +.chroma .go { color: #888888 } /* Generic.Output */ +.chroma .gp { color: #555555 } /* Generic.Prompt */ +.chroma .gs { font-weight: bold } /* Generic.Strong */ +.chroma .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ +.chroma .gt { color: #aa0000 } /* Generic.Traceback */ +.chroma .kc { color: #0000aa } /* Keyword.Constant */ +.chroma .kd { color: #0000aa } /* Keyword.Declaration */ +.chroma .kn { color: #0000aa } /* Keyword.Namespace */ +.chroma .kp { color: #0000aa } /* Keyword.Pseudo */ +.chroma .kr { color: #0000aa } /* Keyword.Reserved */ +.chroma .kt { color: #00aaaa } /* Keyword.Type */ +.chroma .m { color: #009999 } /* Literal.Number */ +.chroma .s { color: #aa5500 } /* Literal.String */ +.chroma .na { color: #1e90ff } /* Name.Attribute */ +.chroma .nb { color: #00aaaa } /* Name.Builtin */ +.chroma .nc { color: #00aa00; text-decoration: underline } /* Name.Class */ +.chroma .no { color: #aa0000 } /* Name.Constant */ +.chroma .nd { color: #888888 } /* Name.Decorator */ +.chroma .ni { color: #800000; font-weight: bold } /* Name.Entity */ +.chroma .nf { color: #00aa00 } /* Name.Function */ +.chroma .nn { color: #00aaaa; text-decoration: underline } /* Name.Namespace */ +.chroma .nt { color: #1e90ff; font-weight: bold } /* Name.Tag */ +.chroma .nv { color: #aa0000 } /* Name.Variable */ +.chroma .ow { color: #0000aa } /* Operator.Word */ +.chroma .w { color: #bbbbbb } /* Text.Whitespace */ +.chroma .mf { color: #009999 } /* Literal.Number.Float */ +.chroma .mh { color: #009999 } /* Literal.Number.Hex */ +.chroma .mi { color: #009999 } /* Literal.Number.Integer */ +.chroma .mo { color: #009999 } /* Literal.Number.Oct */ +.chroma .sb { color: #aa5500 } /* Literal.String.Backtick */ +.chroma .sc { color: #aa5500 } /* Literal.String.Char */ +.chroma .sd { color: #aa5500 } /* Literal.String.Doc */ +.chroma .s2 { color: #aa5500 } /* Literal.String.Double */ +.chroma .se { color: #aa5500 } /* Literal.String.Escape */ +.chroma .sh { color: #aa5500 } /* Literal.String.Heredoc */ +.chroma .si { color: #aa5500 } /* Literal.String.Interpol */ +.chroma .sx { color: #aa5500 } /* Literal.String.Other */ +.chroma .sr { color: #009999 } /* Literal.String.Regex */ +.chroma .s1 { color: #aa5500 } /* Literal.String.Single */ +.chroma .ss { color: #0000aa } /* Literal.String.Symbol */ +.chroma .bp { color: #00aaaa } /* Name.Builtin.Pseudo */ +.chroma .vc { color: #aa0000 } /* Name.Variable.Class */ +.chroma .vg { color: #aa0000 } /* Name.Variable.Global */ +.chroma .vi { color: #aa0000 } /* Name.Variable.Instance */ +.chroma .il { color: #009999 } /* Literal.Number.Integer.Long */ diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..016ba9b --- /dev/null +++ b/go.mod @@ -0,0 +1,37 @@ +module github.com/niko0xdev/gqlgen + +go 1.18 + +require ( + github.com/PuerkitoBio/goquery v1.8.1 + github.com/google/uuid v1.3.0 + github.com/gorilla/websocket v1.5.0 + github.com/hashicorp/golang-lru/v2 v2.0.3 + github.com/kevinmbeaulieu/eq-go v1.0.0 + github.com/logrusorgru/aurora/v3 v3.0.0 + github.com/matryer/moq v0.2.7 + github.com/mattn/go-colorable v0.1.13 + github.com/mattn/go-isatty v0.0.19 + github.com/mitchellh/mapstructure v1.5.0 + github.com/sosodev/duration v1.1.0 + github.com/stretchr/testify v1.8.2 + github.com/urfave/cli/v2 v2.25.5 + github.com/vektah/gqlparser/v2 v2.5.10 + golang.org/x/text v0.13.0 + golang.org/x/tools v0.9.3 + google.golang.org/protobuf v1.30.0 + gopkg.in/yaml.v3 v3.0.1 +) + +require ( + github.com/agnivade/levenshtein v1.1.1 // indirect + github.com/andybalholm/cascadia v1.3.1 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.2 // 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 + github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect + golang.org/x/mod v0.10.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sys v0.13.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..379d011 --- /dev/null +++ b/go.sum @@ -0,0 +1,120 @@ +github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM= +github.com/PuerkitoBio/goquery v1.8.1/go.mod h1:Q8ICL1kNUJ2sXGoAhPGUdYDJvgQgHzJsnnd3H7Ho5jQ= +github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8= +github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo= +github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= +github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c= +github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA= +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.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= +github.com/cpuguy83/go-md2man/v2 v2.0.2/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/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/hashicorp/golang-lru/v2 v2.0.3 h1:kmRrRLlInXvng0SmLxmQpQkpbYAvcXm7NPDrgxJa9mE= +github.com/hashicorp/golang-lru/v2 v2.0.3/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= +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/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.7 h1:RtpiPUM8L7ZSCbSwK+QcZH/E9tgqAkFjKQxsRs25b4w= +github.com/matryer/moq v0.2.7/go.mod h1:kITsx543GOENm48TUAQyJ9+SAvFSr7iGQXPoth/VUBk= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/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/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.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= +github.com/sosodev/duration v1.1.0 h1:kQcaiGbJaIsRqgQy7VGlZrVw1giWO+lDoX3MCPnpVO4= +github.com/sosodev/duration v1.1.0/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/urfave/cli/v2 v2.25.5 h1:d0NIAyhh5shGscroL7ek/Ya9QYQE0KNabJgiUinIQkc= +github.com/urfave/cli/v2 v2.25.5/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= +github.com/vektah/gqlparser/v2 v2.5.10 h1:6zSM4azXC9u4Nxy5YmdmGu4uKamfwsdKTwp5zsEealU= +github.com/vektah/gqlparser/v2 v2.5.10/go.mod h1:1rCcfwB2ekJofmluGWXMSEnPMZgbxzwj6FaZ/4OT8Cc= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= +golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +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/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.9.3 h1:Gn1I8+64MsuTb/HpH+LmQtNas23LhUVr3rYZ0eKuaMM= +golang.org/x/tools v0.9.3/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= +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= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/graphql/any.go b/graphql/any.go new file mode 100644 index 0000000..6ea8bf2 --- /dev/null +++ b/graphql/any.go @@ -0,0 +1,19 @@ +package graphql + +import ( + "encoding/json" + "io" +) + +func MarshalAny(v interface{}) Marshaler { + return WriterFunc(func(w io.Writer) { + err := json.NewEncoder(w).Encode(v) + if err != nil { + panic(err) + } + }) +} + +func UnmarshalAny(v interface{}) (interface{}, error) { + return v, nil +} diff --git a/graphql/bool.go b/graphql/bool.go new file mode 100644 index 0000000..f435e0c --- /dev/null +++ b/graphql/bool.go @@ -0,0 +1,27 @@ +package graphql + +import ( + "fmt" + "io" + "strings" +) + +func MarshalBoolean(b bool) Marshaler { + if b { + return WriterFunc(func(w io.Writer) { w.Write(trueLit) }) + } + return WriterFunc(func(w io.Writer) { w.Write(falseLit) }) +} + +func UnmarshalBoolean(v interface{}) (bool, error) { + switch v := v.(type) { + case string: + return strings.ToLower(v) == "true", nil + case int: + return v != 0, nil + case bool: + return v, nil + default: + return false, fmt.Errorf("%T is not a bool", v) + } +} diff --git a/graphql/bool_test.go b/graphql/bool_test.go new file mode 100644 index 0000000..147237a --- /dev/null +++ b/graphql/bool_test.go @@ -0,0 +1,19 @@ +package graphql + +import ( + "bytes" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestBoolean(t *testing.T) { + assert.Equal(t, "true", doBooleanMarshal(true)) + assert.Equal(t, "false", doBooleanMarshal(false)) +} + +func doBooleanMarshal(b bool) string { + var buf bytes.Buffer + MarshalBoolean(b).MarshalGQL(&buf) + return buf.String() +} diff --git a/graphql/cache.go b/graphql/cache.go new file mode 100644 index 0000000..e552ce6 --- /dev/null +++ b/graphql/cache.go @@ -0,0 +1,29 @@ +package graphql + +import "context" + +// Cache is a shared store for APQ and query AST caching +type Cache interface { + // Get looks up a key's value from the cache. + Get(ctx context.Context, key string) (value interface{}, ok bool) + + // Add adds a value to the cache. + Add(ctx context.Context, key string, value interface{}) +} + +// MapCache is the simplest implementation of a cache, because it can not evict it should only be used in tests +type MapCache map[string]interface{} + +// Get looks up a key's value from the cache. +func (m MapCache) Get(_ context.Context, key string) (value interface{}, ok bool) { + v, ok := m[key] + return v, ok +} + +// Add adds a value to the cache. +func (m MapCache) Add(_ context.Context, key string, value interface{}) { m[key] = value } + +type NoCache struct{} + +func (n NoCache) Get(_ context.Context, _ string) (value interface{}, ok bool) { return nil, false } +func (n NoCache) Add(_ context.Context, _ string, _ interface{}) {} diff --git a/graphql/coercion.go b/graphql/coercion.go new file mode 100644 index 0000000..d3d3c18 --- /dev/null +++ b/graphql/coercion.go @@ -0,0 +1,56 @@ +package graphql + +import ( + "encoding/json" +) + +// CoerceList applies coercion from a single value to a list. +func CoerceList(v interface{}) []interface{} { + var vSlice []interface{} + if v != nil { + switch v := v.(type) { + case []interface{}: + // already a slice no coercion required + vSlice = v + case []string: + if len(v) > 0 { + vSlice = []interface{}{v[0]} + } + case []json.Number: + if len(v) > 0 { + vSlice = []interface{}{v[0]} + } + case []bool: + if len(v) > 0 { + vSlice = []interface{}{v[0]} + } + case []map[string]interface{}: + if len(v) > 0 { + vSlice = []interface{}{v[0]} + } + case []float64: + if len(v) > 0 { + vSlice = []interface{}{v[0]} + } + case []float32: + if len(v) > 0 { + vSlice = []interface{}{v[0]} + } + case []int: + if len(v) > 0 { + vSlice = []interface{}{v[0]} + } + case []int32: + if len(v) > 0 { + vSlice = []interface{}{v[0]} + } + case []int64: + if len(v) > 0 { + vSlice = []interface{}{v[0]} + } + default: + vSlice = []interface{}{v} + } + } + return vSlice +} diff --git a/graphql/coercion_test.go b/graphql/coercion_test.go new file mode 100644 index 0000000..658b4c0 --- /dev/null +++ b/graphql/coercion_test.go @@ -0,0 +1,36 @@ +package graphql + +import ( + "encoding/json" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestCoerceList(t *testing.T) { + mapInput := map[string]interface{}{ + "test": "value", + "nested": map[string]interface{}{ + "nested": true, + }, + } + + jsonNumber := json.Number("12") + + assert.Equal(t, []interface{}{"test", "values"}, CoerceList([]interface{}{"test", "values"})) + assert.Equal(t, []interface{}{"test"}, CoerceList("test")) + assert.Equal(t, []interface{}{"test"}, CoerceList([]string{"test"})) + assert.Equal(t, []interface{}{3}, CoerceList([]int{3})) + assert.Equal(t, []interface{}{3}, CoerceList(3)) + assert.Equal(t, []interface{}{int32(3)}, CoerceList([]int32{3})) + assert.Equal(t, []interface{}{int64(2)}, CoerceList([]int64{2})) + assert.Equal(t, []interface{}{float32(3.14)}, CoerceList([]float32{3.14})) + assert.Equal(t, []interface{}{3.14}, CoerceList([]float64{3.14})) + assert.Equal(t, []interface{}{jsonNumber}, CoerceList([]json.Number{jsonNumber})) + assert.Equal(t, []interface{}{jsonNumber}, CoerceList(jsonNumber)) + assert.Equal(t, []interface{}{true}, CoerceList([]bool{true})) + assert.Equal(t, []interface{}{mapInput}, CoerceList(mapInput)) + assert.Equal(t, []interface{}{mapInput}, CoerceList([]interface{}{mapInput})) + assert.Equal(t, []interface{}{mapInput}, CoerceList([]map[string]interface{}{mapInput})) + assert.Empty(t, CoerceList(nil)) +} diff --git a/graphql/context_field.go b/graphql/context_field.go new file mode 100644 index 0000000..1f9a6e8 --- /dev/null +++ b/graphql/context_field.go @@ -0,0 +1,113 @@ +package graphql + +import ( + "context" + "time" + + "github.com/vektah/gqlparser/v2/ast" +) + +type key string + +const resolverCtx key = "resolver_context" + +// Deprecated: Use FieldContext instead +type ResolverContext = FieldContext + +type FieldContext struct { + Parent *FieldContext + // The name of the type this field belongs to + Object string + // These are the args after processing, they can be mutated in middleware to change what the resolver will get. + Args map[string]interface{} + // The raw field + Field CollectedField + // The index of array in path. + Index *int + // The result object of resolver + Result interface{} + // IsMethod indicates if the resolver is a method + IsMethod bool + // IsResolver indicates if the field has a user-specified resolver + IsResolver bool + // Child allows getting a child FieldContext by its field collection description. + // Note that, the returned child FieldContext represents the context as it was + // before the execution of the field resolver. For example: + // + // srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + // fc := graphql.GetFieldContext(ctx) + // op := graphql.GetOperationContext(ctx) + // collected := graphql.CollectFields(opCtx, fc.Field.Selections, []string{"User"}) + // + // child, err := fc.Child(ctx, collected[0]) + // if err != nil { + // return nil, err + // } + // fmt.Println("child context %q with args: %v", child.Field.Name, child.Args) + // + // return next(ctx) + // }) + // + Child func(context.Context, CollectedField) (*FieldContext, error) +} + +type FieldStats struct { + // When field execution started + Started time.Time + + // When argument marshaling finished + ArgumentsCompleted time.Time + + // When the field completed running all middleware. Not available inside field middleware! + Completed time.Time +} + +func (r *FieldContext) Path() ast.Path { + var path ast.Path + for it := r; it != nil; it = it.Parent { + if it.Index != nil { + path = append(path, ast.PathIndex(*it.Index)) + } else if it.Field.Field != nil { + path = append(path, ast.PathName(it.Field.Alias)) + } + } + + // because we are walking up the chain, all the elements are backwards, do an inplace flip. + for i := len(path)/2 - 1; i >= 0; i-- { + opp := len(path) - 1 - i + path[i], path[opp] = path[opp], path[i] + } + + return path +} + +// Deprecated: Use GetFieldContext instead +func GetResolverContext(ctx context.Context) *ResolverContext { + return GetFieldContext(ctx) +} + +func GetFieldContext(ctx context.Context) *FieldContext { + if val, ok := ctx.Value(resolverCtx).(*FieldContext); ok { + return val + } + return nil +} + +func WithFieldContext(ctx context.Context, rc *FieldContext) context.Context { + rc.Parent = GetFieldContext(ctx) + return context.WithValue(ctx, resolverCtx, rc) +} + +func equalPath(a ast.Path, b ast.Path) bool { + if len(a) != len(b) { + return false + } + + for i := 0; i < len(a); i++ { + if a[i] != b[i] { + return false + } + } + + return true +} diff --git a/graphql/context_field_test.go b/graphql/context_field_test.go new file mode 100644 index 0000000..bffd485 --- /dev/null +++ b/graphql/context_field_test.go @@ -0,0 +1,32 @@ +package graphql + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/v2/ast" +) + +func TestGetResolverContext(t *testing.T) { + require.Nil(t, GetFieldContext(context.Background())) + + rc := &FieldContext{} + require.Equal(t, rc, GetFieldContext(WithFieldContext(context.Background(), rc))) +} + +func testContext(sel ast.SelectionSet) context.Context { + ctx := context.Background() + + rqCtx := &OperationContext{} + ctx = WithOperationContext(ctx, rqCtx) + + root := &FieldContext{ + Field: CollectedField{ + Selections: sel, + }, + } + ctx = WithFieldContext(ctx, root) + + return ctx +} diff --git a/graphql/context_operation.go b/graphql/context_operation.go new file mode 100644 index 0000000..3e6a221 --- /dev/null +++ b/graphql/context_operation.go @@ -0,0 +1,125 @@ +package graphql + +import ( + "context" + "errors" + "net/http" + + "github.com/vektah/gqlparser/v2/ast" + "github.com/vektah/gqlparser/v2/gqlerror" +) + +// Deprecated: Please update all references to OperationContext instead +type RequestContext = OperationContext + +type OperationContext struct { + RawQuery string + Variables map[string]interface{} + OperationName string + Doc *ast.QueryDocument + Headers http.Header + + Operation *ast.OperationDefinition + DisableIntrospection bool + RecoverFunc RecoverFunc + ResolverMiddleware FieldMiddleware + RootResolverMiddleware RootFieldMiddleware + + Stats Stats +} + +func (c *OperationContext) Validate(ctx context.Context) error { + if c.Doc == nil { + return errors.New("field 'Doc'is required") + } + if c.RawQuery == "" { + return errors.New("field 'RawQuery' is required") + } + if c.Variables == nil { + c.Variables = make(map[string]interface{}) + } + 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 + } + + return nil +} + +const operationCtx key = "operation_context" + +// Deprecated: Please update all references to GetOperationContext instead +func GetRequestContext(ctx context.Context) *RequestContext { + return GetOperationContext(ctx) +} + +func GetOperationContext(ctx context.Context) *OperationContext { + if val, ok := ctx.Value(operationCtx).(*OperationContext); ok && val != nil { + return val + } + panic("missing operation context") +} + +func WithOperationContext(ctx context.Context, rc *OperationContext) context.Context { + return context.WithValue(ctx, operationCtx, rc) +} + +// HasOperationContext checks if the given context is part of an ongoing operation +// +// Some errors can happen outside of an operation, eg json unmarshal errors. +func HasOperationContext(ctx context.Context) bool { + val, ok := ctx.Value(operationCtx).(*OperationContext) + return ok && val != nil +} + +// This is just a convenient wrapper method for CollectFields +func CollectFieldsCtx(ctx context.Context, satisfies []string) []CollectedField { + resctx := GetFieldContext(ctx) + return CollectFields(GetOperationContext(ctx), resctx.Field.Selections, satisfies) +} + +// CollectAllFields returns a slice of all GraphQL field names that were selected for the current resolver context. +// The slice will contain the unique set of all field names requested regardless of fragment type conditions. +func CollectAllFields(ctx context.Context) []string { + resctx := GetFieldContext(ctx) + collected := CollectFields(GetOperationContext(ctx), resctx.Field.Selections, nil) + uniq := make([]string, 0, len(collected)) +Next: + for _, f := range collected { + for _, name := range uniq { + if name == f.Name { + continue Next + } + } + uniq = append(uniq, f.Name) + } + return uniq +} + +// Errorf sends an error string to the client, passing it through the formatter. +// Deprecated: use graphql.AddErrorf(ctx, err) instead +func (c *OperationContext) Errorf(ctx context.Context, format string, args ...interface{}) { + AddErrorf(ctx, format, args...) +} + +// Error add error or multiple errors (if underlaying type is gqlerror.List) into the stack. +// Then it will be sends to the client, passing it through the formatter. +func (c *OperationContext) Error(ctx context.Context, err error) { + if errList, ok := err.(gqlerror.List); ok { + for _, e := range errList { + AddError(ctx, e) + } + return + } + + AddError(ctx, err) +} + +func (c *OperationContext) Recover(ctx context.Context, err interface{}) error { + return ErrorOnPath(ctx, c.RecoverFunc(ctx, err)) +} diff --git a/graphql/context_operation_test.go b/graphql/context_operation_test.go new file mode 100644 index 0000000..cd4e61e --- /dev/null +++ b/graphql/context_operation_test.go @@ -0,0 +1,167 @@ +package graphql + +import ( + "context" + "testing" + "time" + + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/v2/ast" +) + +// implement context.Context interface +type testGraphRequestContext struct { + opContext *OperationContext +} + +func (t *testGraphRequestContext) Deadline() (deadline time.Time, ok bool) { + return time.Time{}, false +} + +func (t *testGraphRequestContext) Done() <-chan struct{} { + return nil +} + +func (t *testGraphRequestContext) Err() error { + return nil +} + +func (t *testGraphRequestContext) Value(key interface{}) interface{} { + return t.opContext +} + +func TestGetOperationContext(t *testing.T) { + rc := &OperationContext{} + + t.Run("with operation context", func(t *testing.T) { + ctx := WithOperationContext(context.Background(), rc) + + require.True(t, HasOperationContext(ctx)) + require.Equal(t, rc, GetOperationContext(ctx)) + }) + + t.Run("without operation context", func(t *testing.T) { + ctx := context.Background() + + require.False(t, HasOperationContext(ctx)) + require.Panics(t, func() { + GetOperationContext(ctx) + }) + }) + + t.Run("with nil operation context", func(t *testing.T) { + ctx := &testGraphRequestContext{opContext: nil} + + require.False(t, HasOperationContext(ctx)) + require.Panics(t, func() { + GetOperationContext(ctx) + }) + }) +} + +func TestCollectAllFields(t *testing.T) { + t.Run("collect fields", func(t *testing.T) { + ctx := testContext(ast.SelectionSet{ + &ast.Field{ + Name: "field", + }, + }) + s := CollectAllFields(ctx) + require.Equal(t, []string{"field"}, s) + }) + + t.Run("unique field names", func(t *testing.T) { + ctx := testContext(ast.SelectionSet{ + &ast.Field{ + Name: "field", + }, + &ast.Field{ + Name: "field", + Alias: "field alias", + }, + }) + s := CollectAllFields(ctx) + require.Equal(t, []string{"field"}, s) + }) + + t.Run("collect fragments", func(t *testing.T) { + ctx := testContext(ast.SelectionSet{ + &ast.Field{ + Name: "fieldA", + }, + &ast.InlineFragment{ + TypeCondition: "ExampleTypeA", + SelectionSet: ast.SelectionSet{ + &ast.Field{ + Name: "fieldA", + }, + }, + }, + &ast.InlineFragment{ + TypeCondition: "ExampleTypeB", + SelectionSet: ast.SelectionSet{ + &ast.Field{ + Name: "fieldB", + }, + }, + }, + }) + s := CollectAllFields(ctx) + require.Equal(t, []string{"fieldA", "fieldB"}, s) + }) + + t.Run("collect fragments with same field name on different types", func(t *testing.T) { + ctx := testContext(ast.SelectionSet{ + &ast.InlineFragment{ + TypeCondition: "ExampleTypeA", + SelectionSet: ast.SelectionSet{ + &ast.Field{ + Name: "fieldA", + ObjectDefinition: &ast.Definition{Name: "ExampleTypeA"}, + }, + }, + }, + &ast.InlineFragment{ + TypeCondition: "ExampleTypeB", + SelectionSet: ast.SelectionSet{ + &ast.Field{ + Name: "fieldA", + ObjectDefinition: &ast.Definition{Name: "ExampleTypeB"}, + }, + }, + }, + }) + resCtx := GetFieldContext(ctx) + collected := CollectFields(GetOperationContext(ctx), resCtx.Field.Selections, nil) + require.Len(t, collected, 2) + require.NotEqual(t, collected[0], collected[1]) + require.Equal(t, collected[0].Name, collected[1].Name) + }) + + t.Run("collect fragments with same field name and different alias", func(t *testing.T) { + ctx := testContext(ast.SelectionSet{ + &ast.InlineFragment{ + TypeCondition: "ExampleTypeA", + SelectionSet: ast.SelectionSet{ + &ast.Field{ + Name: "fieldA", + Alias: "fieldA", + ObjectDefinition: &ast.Definition{Name: "ExampleTypeA"}, + }, + &ast.Field{ + Name: "fieldA", + Alias: "fieldA Alias", + ObjectDefinition: &ast.Definition{Name: "ExampleTypeA"}, + }, + }, + ObjectDefinition: &ast.Definition{Name: "ExampleType", Kind: ast.Interface}, + }, + }) + resCtx := GetFieldContext(ctx) + collected := CollectFields(GetOperationContext(ctx), resCtx.Field.Selections, nil) + require.Len(t, collected, 2) + require.NotEqual(t, collected[0], collected[1]) + require.Equal(t, collected[0].Name, collected[1].Name) + require.NotEqual(t, collected[0].Alias, collected[1].Alias) + }) +} diff --git a/graphql/context_path.go b/graphql/context_path.go new file mode 100644 index 0000000..a46ed83 --- /dev/null +++ b/graphql/context_path.go @@ -0,0 +1,77 @@ +package graphql + +import ( + "context" + + "github.com/vektah/gqlparser/v2/ast" +) + +const fieldInputCtx key = "path_context" + +type PathContext struct { + ParentField *FieldContext + Parent *PathContext + Field *string + Index *int +} + +func (fic *PathContext) Path() ast.Path { + var path ast.Path + for it := fic; it != nil; it = it.Parent { + if it.Index != nil { + path = append(path, ast.PathIndex(*it.Index)) + } else if it.Field != nil { + path = append(path, ast.PathName(*it.Field)) + } + } + + // because we are walking up the chain, all the elements are backwards, do an inplace flip. + for i := len(path)/2 - 1; i >= 0; i-- { + opp := len(path) - 1 - i + path[i], path[opp] = path[opp], path[i] + } + + if fic.ParentField != nil { + fieldPath := fic.ParentField.Path() + return append(fieldPath, path...) + + } + + return path +} + +func NewPathWithField(field string) *PathContext { + return &PathContext{Field: &field} +} + +func NewPathWithIndex(index int) *PathContext { + return &PathContext{Index: &index} +} + +func WithPathContext(ctx context.Context, fic *PathContext) context.Context { + if fieldContext := GetFieldContext(ctx); fieldContext != nil { + fic.ParentField = fieldContext + } + if fieldInputContext := GetPathContext(ctx); fieldInputContext != nil { + fic.Parent = fieldInputContext + } + + return context.WithValue(ctx, fieldInputCtx, fic) +} + +func GetPathContext(ctx context.Context) *PathContext { + if val, ok := ctx.Value(fieldInputCtx).(*PathContext); ok { + return val + } + return nil +} + +func GetPath(ctx context.Context) ast.Path { + if pc := GetPathContext(ctx); pc != nil { + return pc.Path() + } + if fc := GetFieldContext(ctx); fc != nil { + return fc.Path() + } + return nil +} diff --git a/graphql/context_path_test.go b/graphql/context_path_test.go new file mode 100644 index 0000000..085b40c --- /dev/null +++ b/graphql/context_path_test.go @@ -0,0 +1,15 @@ +package graphql + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestGetFieldInputContext(t *testing.T) { + require.Nil(t, GetFieldContext(context.Background())) + + rc := &PathContext{} + require.Equal(t, rc, GetPathContext(WithPathContext(context.Background(), rc))) +} diff --git a/graphql/context_response.go b/graphql/context_response.go new file mode 100644 index 0000000..6d223c8 --- /dev/null +++ b/graphql/context_response.go @@ -0,0 +1,161 @@ +package graphql + +import ( + "context" + "fmt" + "sync" + + "github.com/vektah/gqlparser/v2/gqlerror" +) + +type responseContext struct { + errorPresenter ErrorPresenterFunc + recover RecoverFunc + + errors gqlerror.List + errorsMu sync.Mutex + + extensions map[string]interface{} + extensionsMu sync.Mutex +} + +const resultCtx key = "result_context" + +func getResponseContext(ctx context.Context) *responseContext { + val, ok := ctx.Value(resultCtx).(*responseContext) + if !ok { + panic("missing response context") + } + return val +} + +func WithResponseContext(ctx context.Context, presenterFunc ErrorPresenterFunc, recoverFunc RecoverFunc) context.Context { + return context.WithValue(ctx, resultCtx, &responseContext{ + errorPresenter: presenterFunc, + recover: recoverFunc, + }) +} + +func WithFreshResponseContext(ctx context.Context) context.Context { + e := getResponseContext(ctx) + return context.WithValue(ctx, resultCtx, &responseContext{ + errorPresenter: e.errorPresenter, + recover: e.recover, + }) +} + +// AddErrorf writes a formatted error to the client, first passing it through the error presenter. +func AddErrorf(ctx context.Context, format string, args ...interface{}) { + AddError(ctx, fmt.Errorf(format, args...)) +} + +// AddError sends an error to the client, first passing it through the error presenter. +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, presentedError) +} + +func Recover(ctx context.Context, err interface{}) (userMessage error) { + c := getResponseContext(ctx) + return ErrorOnPath(ctx, c.recover(ctx, err)) +} + +// HasFieldError returns true if the given field has already errored +func HasFieldError(ctx context.Context, rctx *FieldContext) bool { + c := getResponseContext(ctx) + + c.errorsMu.Lock() + defer c.errorsMu.Unlock() + + if len(c.errors) == 0 { + return false + } + + path := rctx.Path() + for _, err := range c.errors { + if equalPath(err.Path, path) { + return true + } + } + return false +} + +// GetFieldErrors returns a list of errors that occurred in the given field +func GetFieldErrors(ctx context.Context, rctx *FieldContext) gqlerror.List { + c := getResponseContext(ctx) + + c.errorsMu.Lock() + defer c.errorsMu.Unlock() + + if len(c.errors) == 0 { + return nil + } + + path := rctx.Path() + var errs gqlerror.List + for _, err := range c.errors { + if equalPath(err.Path, path) { + errs = append(errs, err) + } + } + return errs +} + +func GetErrors(ctx context.Context) gqlerror.List { + resCtx := getResponseContext(ctx) + resCtx.errorsMu.Lock() + defer resCtx.errorsMu.Unlock() + + if len(resCtx.errors) == 0 { + return nil + } + + errs := resCtx.errors + cpy := make(gqlerror.List, len(errs)) + for i := range errs { + errCpy := *errs[i] + cpy[i] = &errCpy + } + return cpy +} + +// RegisterExtension allows you to add a new extension into the graphql response +func RegisterExtension(ctx context.Context, key string, value interface{}) { + c := getResponseContext(ctx) + c.extensionsMu.Lock() + defer c.extensionsMu.Unlock() + + if c.extensions == nil { + c.extensions = make(map[string]interface{}) + } + + if _, ok := c.extensions[key]; ok { + panic(fmt.Errorf("extension already registered for key %s", key)) + } + + c.extensions[key] = value +} + +// GetExtensions returns any extensions registered in the current result context +func GetExtensions(ctx context.Context) map[string]interface{} { + ext := getResponseContext(ctx).extensions + if ext == nil { + return map[string]interface{}{} + } + + return ext +} + +func GetExtension(ctx context.Context, name string) interface{} { + ext := getResponseContext(ctx).extensions + if ext == nil { + return nil + } + + return ext[name] +} diff --git a/graphql/context_response_test.go b/graphql/context_response_test.go new file mode 100644 index 0000000..acafe95 --- /dev/null +++ b/graphql/context_response_test.go @@ -0,0 +1,94 @@ +package graphql + +import ( + "context" + "errors" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/v2/ast" + "github.com/vektah/gqlparser/v2/gqlerror" +) + +func TestAddError(t *testing.T) { + ctx := WithResponseContext(context.Background(), DefaultErrorPresenter, nil) + + root := &FieldContext{ + Field: CollectedField{ + Field: &ast.Field{ + Alias: "foo", + }, + }, + } + ctx = WithFieldContext(ctx, root) + AddError(ctx, errors.New("foo1")) + AddError(ctx, errors.New("foo2")) + + index := 1 + child := &FieldContext{ + Parent: root, + Index: &index, + } + userProvidedPath := &FieldContext{ + Parent: child, + Field: CollectedField{ + Field: &ast.Field{ + Alias: "works", + }, + }, + } + + ctx = WithFieldContext(ctx, child) + AddError(ctx, errors.New("bar")) + AddError(ctx, &gqlerror.Error{ + Message: "foo3", + Path: append(child.Path(), ast.PathName("works")), + }) + + specs := []struct { + Name string + RCtx *FieldContext + Messages []string + }{ + { + Name: "with root FieldContext", + RCtx: root, + Messages: []string{"foo1", "foo2"}, + }, + { + Name: "with child FieldContext", + RCtx: child, + Messages: []string{"bar"}, + }, + { + Name: "with user provided path", + RCtx: userProvidedPath, + Messages: []string{"foo3"}, + }, + } + + for _, spec := range specs { + t.Run(spec.Name, func(t *testing.T) { + errList := GetFieldErrors(ctx, spec.RCtx) + require.Len(t, errList, len(spec.Messages)) + + for idx, err := range errList { + assert.Equal(t, spec.Messages[idx], err.Message) + } + }) + } +} + +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 0000000..1bf4d13 --- /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 0000000..dfbb859 --- /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/deferred.go b/graphql/deferred.go new file mode 100644 index 0000000..1aeb48c --- /dev/null +++ b/graphql/deferred.go @@ -0,0 +1,26 @@ +package graphql + +import ( + "context" + + "github.com/vektah/gqlparser/v2/ast" + "github.com/vektah/gqlparser/v2/gqlerror" +) + +type Deferrable struct { + Label string +} + +type DeferredGroup struct { + Path ast.Path + Label string + FieldSet *FieldSet + Context context.Context +} + +type DeferredResult struct { + Path ast.Path + Label string + Result Marshaler + Errors gqlerror.List +} diff --git a/graphql/duration.go b/graphql/duration.go new file mode 100644 index 0000000..3eb392d --- /dev/null +++ b/graphql/duration.go @@ -0,0 +1,27 @@ +package graphql + +import ( + "fmt" + "time" + + dur "github.com/sosodev/duration" +) + +// UnmarshalDuration returns the duration from a string in ISO8601 format +func UnmarshalDuration(v interface{}) (time.Duration, error) { + input, ok := v.(string) + if !ok { + return 0, fmt.Errorf("input must be a string") + } + + d2, err := dur.Parse(input) + if err != nil { + return 0, err + } + return d2.ToTimeDuration(), nil +} + +// MarshalDuration returns the duration on ISO8601 format +func MarshalDuration(d time.Duration) Marshaler { + return MarshalString(dur.Format(d)) +} diff --git a/graphql/duration_test.go b/graphql/duration_test.go new file mode 100644 index 0000000..56b6031 --- /dev/null +++ b/graphql/duration_test.go @@ -0,0 +1,26 @@ +package graphql + +import ( + "bytes" + "testing" + "time" + + "github.com/stretchr/testify/assert" +) + +func TestDurationMarshaling(t *testing.T) { + t.Run("UnmarshalDuration", func(t *testing.T) { + d, err := UnmarshalDuration("P2Y") + assert.NoError(t, err) + + assert.Equal(t, float64(365*24*2), d.Hours()) + }) + t.Run("MarshalDuration", func(t *testing.T) { + m := MarshalDuration(time.Hour * 365 * 24 * 2) + + buf := new(bytes.Buffer) + m.MarshalGQL(buf) + + assert.Equal(t, "\"P2Y\"", buf.String()) + }) +} diff --git a/graphql/errcode/codes.go b/graphql/errcode/codes.go new file mode 100644 index 0000000..854b206 --- /dev/null +++ b/graphql/errcode/codes.go @@ -0,0 +1,60 @@ +package errcode + +import ( + "github.com/vektah/gqlparser/v2/gqlerror" +) + +const ( + ValidationFailed = "GRAPHQL_VALIDATION_FAILED" + ParseFailed = "GRAPHQL_PARSE_FAILED" +) + +type ErrorKind int + +const ( + // issues with graphql (validation, parsing). 422s in http, GQL_ERROR in websocket + KindProtocol ErrorKind = iota + // user errors, 200s in http, GQL_DATA in websocket + KindUser +) + +var codeType = map[string]ErrorKind{ + ValidationFailed: KindProtocol, + ParseFailed: KindProtocol, +} + +// RegisterErrorType should be called by extensions that want to customize the http status codes for +// errors they return +func RegisterErrorType(code string, kind ErrorKind) { + codeType[code] = kind +} + +// Set the error code on a given graphql error extension +func Set(err error, value string) { + if err == nil { + return + } + gqlErr, ok := err.(*gqlerror.Error) + if !ok { + return + } + + if gqlErr.Extensions == nil { + gqlErr.Extensions = map[string]interface{}{} + } + + gqlErr.Extensions["code"] = value +} + +// get the kind of the first non User error, defaults to User if no errors have a custom extension +func GetErrorKind(errs gqlerror.List) ErrorKind { + for _, err := range errs { + if code, ok := err.Extensions["code"].(string); ok { + if kind, ok := codeType[code]; ok && kind != KindUser { + return kind + } + } + } + + return KindUser +} diff --git a/graphql/error.go b/graphql/error.go new file mode 100644 index 0000000..f816bef --- /dev/null +++ b/graphql/error.go @@ -0,0 +1,33 @@ +package graphql + +import ( + "context" + "errors" + + "github.com/vektah/gqlparser/v2/gqlerror" +) + +type ErrorPresenterFunc func(ctx context.Context, err error) *gqlerror.Error + +func DefaultErrorPresenter(ctx context.Context, err error) *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) + } + // Return the original error to avoid losing any attached annotation + return err + } + return gqlerror.WrapPath(GetPath(ctx), err) +} diff --git a/graphql/executable_schema.go b/graphql/executable_schema.go new file mode 100644 index 0000000..58f942a --- /dev/null +++ b/graphql/executable_schema.go @@ -0,0 +1,211 @@ +//go:generate go run github.com/matryer/moq -out executable_schema_mock.go . ExecutableSchema + +package graphql + +import ( + "context" + "fmt" + + "github.com/vektah/gqlparser/v2/ast" +) + +type ExecutableSchema interface { + Schema() *ast.Schema + + Complexity(typeName, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) + Exec(ctx context.Context) ResponseHandler +} + +// CollectFields returns the set of fields from an ast.SelectionSet where all collected fields satisfy at least one of the GraphQL types +// passed through satisfies. Providing an empty or nil slice for satisfies will return collect all fields regardless of fragment +// type conditions. +func CollectFields(reqCtx *OperationContext, selSet ast.SelectionSet, satisfies []string) []CollectedField { + return collectFields(reqCtx, selSet, satisfies, map[string]bool{}) +} + +func collectFields(reqCtx *OperationContext, selSet ast.SelectionSet, satisfies []string, visited map[string]bool) []CollectedField { + groupedFields := make([]CollectedField, 0, len(selSet)) + + for _, sel := range selSet { + switch sel := sel.(type) { + case *ast.Field: + if !shouldIncludeNode(sel.Directives, reqCtx.Variables) { + continue + } + f := getOrCreateAndAppendField(&groupedFields, sel.Name, sel.Alias, sel.ObjectDefinition, func() CollectedField { + return CollectedField{Field: sel} + }) + + f.Selections = append(f.Selections, sel.SelectionSet...) + + case *ast.InlineFragment: + if !shouldIncludeNode(sel.Directives, reqCtx.Variables) { + continue + } + if len(satisfies) > 0 && !instanceOf(sel.TypeCondition, satisfies) { + continue + } + + shouldDefer, label := deferrable(sel.Directives, reqCtx.Variables) + + for _, childField := range collectFields(reqCtx, sel.SelectionSet, satisfies, visited) { + f := getOrCreateAndAppendField( + &groupedFields, childField.Name, childField.Alias, childField.ObjectDefinition, + func() CollectedField { return childField }) + f.Selections = append(f.Selections, childField.Selections...) + if shouldDefer { + f.Deferrable = &Deferrable{ + Label: label, + } + } + } + + case *ast.FragmentSpread: + if !shouldIncludeNode(sel.Directives, reqCtx.Variables) { + continue + } + fragmentName := sel.Name + if _, seen := visited[fragmentName]; seen { + continue + } + visited[fragmentName] = true + + fragment := reqCtx.Doc.Fragments.ForName(fragmentName) + if fragment == nil { + // should never happen, validator has already run + panic(fmt.Errorf("missing fragment %s", fragmentName)) + } + + if len(satisfies) > 0 && !instanceOf(fragment.TypeCondition, satisfies) { + continue + } + + shouldDefer, label := deferrable(sel.Directives, reqCtx.Variables) + + for _, childField := range collectFields(reqCtx, fragment.SelectionSet, satisfies, visited) { + f := getOrCreateAndAppendField(&groupedFields, + childField.Name, childField.Alias, childField.ObjectDefinition, + func() CollectedField { return childField }) + f.Selections = append(f.Selections, childField.Selections...) + if shouldDefer { + f.Deferrable = &Deferrable{Label: label} + } + } + + default: + panic(fmt.Errorf("unsupported %T", sel)) + } + } + + return groupedFields +} + +type CollectedField struct { + *ast.Field + + Selections ast.SelectionSet + Deferrable *Deferrable +} + +func instanceOf(val string, satisfies []string) bool { + for _, s := range satisfies { + if val == s { + return true + } + } + return false +} + +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 { + 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] + } + } + for _, ifc := range cf.ObjectDefinition.Interfaces { + if ifc == objectDefinition.Name { + return &(*c)[i] + } + } + } + } + + f := creator() + + *c = append(*c, f) + return &(*c)[len(*c)-1] +} + +func shouldIncludeNode(directives ast.DirectiveList, variables map[string]interface{}) bool { + if len(directives) == 0 { + return true + } + + skip, include := false, true + + if d := directives.ForName("skip"); d != nil { + skip = resolveIfArgument(d, variables) + } + + if d := directives.ForName("include"); d != nil { + include = resolveIfArgument(d, variables) + } + + return !skip && include +} + +func deferrable(directives ast.DirectiveList, variables map[string]interface{}) (shouldDefer bool, label string) { + d := directives.ForName("defer") + if d == nil { + return false, "" + } + + shouldDefer = true + + for _, arg := range d.Arguments { + switch arg.Name { + case "if": + if value, err := arg.Value.Value(variables); err == nil { + shouldDefer, _ = value.(bool) + } + case "label": + if value, err := arg.Value.Value(variables); err == nil { + label, _ = value.(string) + } + default: + panic(fmt.Sprintf("defer: argument '%s' not supported", arg.Name)) + } + } + + return shouldDefer, label +} + +func resolveIfArgument(d *ast.Directive, variables map[string]interface{}) bool { + arg := d.Arguments.ForName("if") + if arg == nil { + panic(fmt.Sprintf("%s: argument 'if' not defined", d.Name)) + } + value, err := arg.Value.Value(variables) + if err != nil { + panic(err) + } + ret, ok := value.(bool) + if !ok { + panic(fmt.Sprintf("%s: argument 'if' is not a boolean", d.Name)) + } + return ret +} diff --git a/graphql/executable_schema_mock.go b/graphql/executable_schema_mock.go new file mode 100644 index 0000000..5e71cb8 --- /dev/null +++ b/graphql/executable_schema_mock.go @@ -0,0 +1,175 @@ +// Code generated by moq; DO NOT EDIT. +// github.com/matryer/moq + +package graphql + +import ( + "context" + "github.com/vektah/gqlparser/v2/ast" + "sync" +) + +// 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) { +// +// // 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. +// +// } +type ExecutableSchemaMock struct { + // ComplexityFunc mocks the Complexity method. + ComplexityFunc func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) + + // ExecFunc mocks the Exec method. + ExecFunc func(ctx context.Context) ResponseHandler + + // SchemaFunc mocks the Schema method. + SchemaFunc func() *ast.Schema + + // calls tracks calls to the methods. + calls struct { + // Complexity holds details about calls to the Complexity method. + Complexity []struct { + // TypeName is the typeName argument value. + TypeName string + // FieldName is the fieldName argument value. + FieldName string + // ChildComplexity is the childComplexity argument value. + ChildComplexity int + // Args is the args argument value. + Args map[string]interface{} + } + // Exec holds details about calls to the Exec method. + Exec []struct { + // Ctx is the ctx argument value. + Ctx context.Context + } + // Schema holds details about calls to the Schema method. + Schema []struct { + } + } + lockComplexity sync.RWMutex + lockExec sync.RWMutex + lockSchema sync.RWMutex +} + +// Complexity calls ComplexityFunc. +func (mock *ExecutableSchemaMock) Complexity(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) { + if mock.ComplexityFunc == nil { + panic("ExecutableSchemaMock.ComplexityFunc: method is nil but ExecutableSchema.Complexity was just called") + } + callInfo := struct { + TypeName string + FieldName string + ChildComplexity int + Args map[string]interface{} + }{ + TypeName: typeName, + FieldName: fieldName, + ChildComplexity: childComplexity, + Args: args, + } + mock.lockComplexity.Lock() + mock.calls.Complexity = append(mock.calls.Complexity, callInfo) + mock.lockComplexity.Unlock() + return mock.ComplexityFunc(typeName, fieldName, childComplexity, args) +} + +// ComplexityCalls gets all the calls that were made to Complexity. +// Check the length with: +// +// len(mockedExecutableSchema.ComplexityCalls()) +func (mock *ExecutableSchemaMock) ComplexityCalls() []struct { + TypeName string + FieldName string + ChildComplexity int + Args map[string]interface{} +} { + var calls []struct { + TypeName string + FieldName string + ChildComplexity int + Args map[string]interface{} + } + mock.lockComplexity.RLock() + calls = mock.calls.Complexity + mock.lockComplexity.RUnlock() + return calls +} + +// Exec calls ExecFunc. +func (mock *ExecutableSchemaMock) Exec(ctx context.Context) ResponseHandler { + if mock.ExecFunc == nil { + panic("ExecutableSchemaMock.ExecFunc: method is nil but ExecutableSchema.Exec was just called") + } + callInfo := struct { + Ctx context.Context + }{ + Ctx: ctx, + } + mock.lockExec.Lock() + mock.calls.Exec = append(mock.calls.Exec, callInfo) + mock.lockExec.Unlock() + return mock.ExecFunc(ctx) +} + +// ExecCalls gets all the calls that were made to Exec. +// Check the length with: +// +// len(mockedExecutableSchema.ExecCalls()) +func (mock *ExecutableSchemaMock) ExecCalls() []struct { + Ctx context.Context +} { + var calls []struct { + Ctx context.Context + } + mock.lockExec.RLock() + calls = mock.calls.Exec + mock.lockExec.RUnlock() + return calls +} + +// Schema calls SchemaFunc. +func (mock *ExecutableSchemaMock) Schema() *ast.Schema { + if mock.SchemaFunc == nil { + panic("ExecutableSchemaMock.SchemaFunc: method is nil but ExecutableSchema.Schema was just called") + } + callInfo := struct { + }{} + mock.lockSchema.Lock() + mock.calls.Schema = append(mock.calls.Schema, callInfo) + mock.lockSchema.Unlock() + return mock.SchemaFunc() +} + +// SchemaCalls gets all the calls that were made to Schema. +// Check the length with: +// +// len(mockedExecutableSchema.SchemaCalls()) +func (mock *ExecutableSchemaMock) SchemaCalls() []struct { +} { + var calls []struct { + } + mock.lockSchema.RLock() + calls = mock.calls.Schema + mock.lockSchema.RUnlock() + return calls +} diff --git a/graphql/executor/executor.go b/graphql/executor/executor.go new file mode 100644 index 0000000..6e1a8f2 --- /dev/null +++ b/graphql/executor/executor.go @@ -0,0 +1,222 @@ +package executor + +import ( + "context" + + "github.com/vektah/gqlparser/v2/ast" + "github.com/vektah/gqlparser/v2/gqlerror" + "github.com/vektah/gqlparser/v2/parser" + "github.com/vektah/gqlparser/v2/validator" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/errcode" +) + +// Executor executes graphql queries against a schema. +type Executor struct { + es graphql.ExecutableSchema + extensions []graphql.HandlerExtension + ext extensions + + errorPresenter graphql.ErrorPresenterFunc + recoverFunc graphql.RecoverFunc + queryCache graphql.Cache +} + +var _ graphql.GraphExecutor = &Executor{} + +// New creates a new Executor with the given schema, and a default error and +// recovery callbacks, and no query cache or extensions. +func New(es graphql.ExecutableSchema) *Executor { + e := &Executor{ + es: es, + errorPresenter: graphql.DefaultErrorPresenter, + recoverFunc: graphql.DefaultRecover, + queryCache: graphql.NoCache{}, + ext: processExtensions(nil), + } + return e +} + +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, + RootResolverMiddleware: e.ext.rootFieldMiddleware, + Stats: graphql.Stats{ + Read: params.ReadTime, + OperationStart: graphql.GetStartTime(ctx), + }, + } + ctx = graphql.WithOperationContext(ctx, rc) + + for _, p := range e.ext.operationParameterMutators { + if err := p.MutateOperationParameters(ctx, params); err != nil { + return rc, gqlerror.List{err} + } + } + + rc.RawQuery = params.Query + rc.OperationName = params.OperationName + rc.Headers = params.Headers + + var listErr gqlerror.List + rc.Doc, listErr = e.parseQuery(ctx, &rc.Stats, params.Query) + if len(listErr) != 0 { + return rc, listErr + } + + rc.Operation = rc.Doc.Operations.ForName(params.OperationName) + if rc.Operation == nil { + err := gqlerror.Errorf("operation %s not found", params.OperationName) + errcode.Set(err, errcode.ValidationFailed) + return rc, gqlerror.List{err} + } + + var err error + rc.Variables, err = validator.VariableValues(e.es.Schema(), rc.Operation, params.Variables) + + if err != nil { + gqlErr, ok := err.(*gqlerror.Error) + if ok { + errcode.Set(gqlErr, errcode.ValidationFailed) + return rc, gqlerror.List{gqlErr} + } + } + rc.Stats.Validation.End = graphql.Now() + + for _, p := range e.ext.operationContextMutators { + if err := p.MutateOperationContext(ctx, rc); err != nil { + return rc, gqlerror.List{err} + } + } + + return rc, nil +} + +func (e *Executor) DispatchOperation( + ctx context.Context, + rc *graphql.OperationContext, +) (graphql.ResponseHandler, context.Context) { + ctx = graphql.WithOperationContext(ctx, rc) + + var innerCtx context.Context + res := e.ext.operationMiddleware(ctx, func(ctx context.Context) graphql.ResponseHandler { + innerCtx = ctx + + tmpResponseContext := graphql.WithResponseContext(ctx, e.errorPresenter, e.recoverFunc) + responses := e.es.Exec(tmpResponseContext) + if errs := graphql.GetErrors(tmpResponseContext); errs != nil { + return graphql.OneShot(&graphql.Response{Errors: errs}) + } + + return func(ctx context.Context) *graphql.Response { + ctx = graphql.WithResponseContext(ctx, e.errorPresenter, e.recoverFunc) + resp := e.ext.responseMiddleware(ctx, func(ctx context.Context) *graphql.Response { + resp := responses(ctx) + if resp == nil { + return nil + } + resp.Errors = append(resp.Errors, graphql.GetErrors(ctx)...) + resp.Extensions = graphql.GetExtensions(ctx) + return resp + }) + if resp == nil { + return nil + } + + return resp + } + }) + + return res, innerCtx +} + +func (e *Executor) DispatchError(ctx context.Context, list gqlerror.List) *graphql.Response { + ctx = graphql.WithResponseContext(ctx, e.errorPresenter, e.recoverFunc) + for _, gErr := range list { + graphql.AddError(ctx, gErr) + } + + resp := e.ext.responseMiddleware(ctx, func(ctx context.Context) *graphql.Response { + resp := &graphql.Response{ + Errors: graphql.GetErrors(ctx), + } + resp.Extensions = graphql.GetExtensions(ctx) + return resp + }) + + return resp +} + +func (e *Executor) PresentRecoveredError(ctx context.Context, err interface{}) error { + return e.errorPresenter(ctx, e.recoverFunc(ctx, err)) +} + +func (e *Executor) SetQueryCache(cache graphql.Cache) { + e.queryCache = cache +} + +func (e *Executor) SetErrorPresenter(f graphql.ErrorPresenterFunc) { + e.errorPresenter = f +} + +func (e *Executor) SetRecoverFunc(f graphql.RecoverFunc) { + e.recoverFunc = f +} + +// parseQuery decodes the incoming query and validates it, pulling from cache if present. +// +// NOTE: This should NOT look at variables, they will change per request. It should only parse and +// validate +// the raw query string. +func (e *Executor) parseQuery( + ctx context.Context, + stats *graphql.Stats, + query string, +) (*ast.QueryDocument, gqlerror.List) { + stats.Parsing.Start = graphql.Now() + + if doc, ok := e.queryCache.Get(ctx, query); ok { + now := graphql.Now() + + stats.Parsing.End = now + stats.Validation.Start = now + return doc.(*ast.QueryDocument), nil + } + + doc, err := parser.ParseQuery(&ast.Source{Input: query}) + if err != nil { + gqlErr, ok := err.(*gqlerror.Error) + if ok { + errcode.Set(gqlErr, errcode.ParseFailed) + return nil, gqlerror.List{gqlErr} + } + } + stats.Parsing.End = graphql.Now() + + stats.Validation.Start = graphql.Now() + + if len(doc.Operations) == 0 { + err = gqlerror.Errorf("no operation provided") + gqlErr, _ := err.(*gqlerror.Error) + errcode.Set(err, errcode.ValidationFailed) + return nil, gqlerror.List{gqlErr} + } + + listErr := validator.Validate(e.es.Schema(), doc) + if len(listErr) != 0 { + for _, e := range listErr { + errcode.Set(e, errcode.ValidationFailed) + } + return nil, listErr + } + + e.queryCache.Add(ctx, query, doc) + + return doc, nil +} diff --git a/graphql/executor/executor_test.go b/graphql/executor/executor_test.go new file mode 100644 index 0000000..edddbbf --- /dev/null +++ b/graphql/executor/executor_test.go @@ -0,0 +1,241 @@ +package executor_test + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/v2/ast" + "github.com/vektah/gqlparser/v2/gqlerror" + "github.com/vektah/gqlparser/v2/parser" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/errcode" + "github.com/niko0xdev/gqlgen/graphql/executor/testexecutor" +) + +func TestExecutor(t *testing.T) { + exec := testexecutor.New() + + t.Run("calls query on executable schema", func(t *testing.T) { + resp := query(exec, "", "{name}") + assert.Equal(t, `{"name":"test"}`, string(resp.Data)) + }) + + t.Run("validates operation", func(t *testing.T) { + t.Run("no operation", func(t *testing.T) { + resp := query(exec, "", "") + assert.Equal(t, "", string(resp.Data)) + assert.Equal(t, 1, len(resp.Errors)) + assert.Equal(t, errcode.ValidationFailed, resp.Errors[0].Extensions["code"]) + }) + + t.Run("bad operation", func(t *testing.T) { + resp := query(exec, "badOp", "query test { name }") + assert.Equal(t, "", string(resp.Data)) + assert.Equal(t, 1, len(resp.Errors)) + assert.Equal(t, errcode.ValidationFailed, resp.Errors[0].Extensions["code"]) + }) + }) + + t.Run("invokes operation middleware in order", func(t *testing.T) { + var calls []string + exec.AroundOperations(func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler { + calls = append(calls, "first") + return next(ctx) + }) + exec.AroundOperations(func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler { + 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 response middleware in order", func(t *testing.T) { + var calls []string + exec.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + calls = append(calls, "first") + return next(ctx) + }) + exec.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + 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 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) { + calls = append(calls, "first") + return next(ctx) + }) + exec.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + 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 operation mutators", func(t *testing.T) { + var calls []string + exec.Use(&testParamMutator{ + Mutate: func(ctx context.Context, req *graphql.RawParams) *gqlerror.Error { + calls = append(calls, "param") + return nil + }, + }) + exec.Use(&testCtxMutator{ + Mutate: func(ctx context.Context, rc *graphql.OperationContext) *gqlerror.Error { + calls = append(calls, "context") + return nil + }, + }) + resp := query(exec, "", "{name}") + assert.Equal(t, `{"name":"test"}`, string(resp.Data)) + assert.Equal(t, []string{"param", "context"}, calls) + }) + + t.Run("get query parse error in AroundResponses", func(t *testing.T) { + var errors1 gqlerror.List + var errors2 gqlerror.List + exec.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + resp := next(ctx) + errors1 = graphql.GetErrors(ctx) + errors2 = resp.Errors + return resp + }) + + resp := query(exec, "", "invalid") + assert.Equal(t, "", string(resp.Data)) + assert.Equal(t, 1, len(resp.Errors)) + assert.Equal(t, 1, len(errors1)) + assert.Equal(t, 1, len(errors2)) + }) + + t.Run("query caching", func(t *testing.T) { + ctx := context.Background() + cache := &graphql.MapCache{} + exec.SetQueryCache(cache) + qry := `query Foo {name}` + + t.Run("cache miss populates cache", func(t *testing.T) { + resp := query(exec, "Foo", qry) + assert.Equal(t, `{"name":"test"}`, string(resp.Data)) + + cacheDoc, ok := cache.Get(ctx, qry) + require.True(t, ok) + require.Equal(t, "Foo", cacheDoc.(*ast.QueryDocument).Operations[0].Name) + }) + + t.Run("cache hits use document from cache", func(t *testing.T) { + doc, err := parser.ParseQuery(&ast.Source{Input: `query Bar {name}`}) + require.Nil(t, err) + cache.Add(ctx, qry, doc) + + resp := query(exec, "Bar", qry) + assert.Equal(t, `{"name":"test"}`, string(resp.Data)) + + cacheDoc, ok := cache.Get(ctx, qry) + require.True(t, ok) + require.Equal(t, "Bar", cacheDoc.(*ast.QueryDocument).Operations[0].Name) + }) + }) +} + +type testParamMutator struct { + Mutate func(context.Context, *graphql.RawParams) *gqlerror.Error +} + +func (m *testParamMutator) ExtensionName() string { + return "Operation: Mutate Parameters" +} + +func (m *testParamMutator) Validate(s graphql.ExecutableSchema) error { + return nil +} + +func (m *testParamMutator) MutateOperationParameters(ctx context.Context, r *graphql.RawParams) *gqlerror.Error { + return m.Mutate(ctx, r) +} + +type testCtxMutator struct { + Mutate func(context.Context, *graphql.OperationContext) *gqlerror.Error +} + +func (m *testCtxMutator) ExtensionName() string { + return "Operation: Mutate the Context" +} + +func (m *testCtxMutator) Validate(s graphql.ExecutableSchema) error { + return nil +} + +func (m *testCtxMutator) MutateOperationContext(ctx context.Context, rc *graphql.OperationContext) *gqlerror.Error { + return m.Mutate(ctx, rc) +} + +func TestErrorServer(t *testing.T) { + exec := testexecutor.NewError() + + t.Run("get resolver error in AroundResponses", func(t *testing.T) { + var errors1 gqlerror.List + var errors2 gqlerror.List + exec.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + resp := next(ctx) + errors1 = graphql.GetErrors(ctx) + errors2 = resp.Errors + return resp + }) + + resp := query(exec, "", "{name}") + assert.Equal(t, "null", string(resp.Data)) + assert.Equal(t, 1, len(errors1)) + assert.Equal(t, 1, len(errors2)) + }) +} + +func query(exec *testexecutor.TestExecutor, op, q string) *graphql.Response { + ctx := graphql.StartOperationTrace(context.Background()) + now := graphql.Now() + rc, err := exec.CreateOperationContext(ctx, &graphql.RawParams{ + Query: q, + OperationName: op, + ReadTime: graphql.TraceTiming{ + Start: now, + End: now, + }, + }) + if err != nil { + return exec.DispatchError(ctx, err) + } + + resp, ctx2 := exec.DispatchOperation(ctx, rc) + return resp(ctx2) +} diff --git a/graphql/executor/extensions.go b/graphql/executor/extensions.go new file mode 100644 index 0000000..033f714 --- /dev/null +++ b/graphql/executor/extensions.go @@ -0,0 +1,195 @@ +package executor + +import ( + "context" + "fmt" + + "github.com/niko0xdev/gqlgen/graphql" +) + +// Use adds the given extension to this Executor. +func (e *Executor) Use(extension graphql.HandlerExtension) { + if err := extension.Validate(e.es); err != nil { + panic(err) + } + + switch extension.(type) { + case graphql.OperationParameterMutator, + graphql.OperationContextMutator, + graphql.OperationInterceptor, + graphql.RootFieldInterceptor, + graphql.FieldInterceptor, + graphql.ResponseInterceptor: + e.extensions = append(e.extensions, extension) + e.ext = processExtensions(e.extensions) + + default: + panic(fmt.Errorf("cannot Use %T as a gqlgen handler extension because it does not implement any extension hooks", extension)) + } +} + +// AroundFields is a convenience method for creating an extension that only implements field middleware +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)) +} + +// AroundResponses is a convenience method for creating an extension that only implements response middleware +func (e *Executor) AroundResponses(f graphql.ResponseMiddleware) { + e.Use(aroundRespFunc(f)) +} + +type extensions struct { + operationMiddleware graphql.OperationMiddleware + responseMiddleware graphql.ResponseMiddleware + rootFieldMiddleware graphql.RootFieldMiddleware + fieldMiddleware graphql.FieldMiddleware + operationParameterMutators []graphql.OperationParameterMutator + operationContextMutators []graphql.OperationContextMutator +} + +func processExtensions(exts []graphql.HandlerExtension) extensions { + e := extensions{ + operationMiddleware: func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler { + return next(ctx) + }, + 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) + }, + } + + // this loop goes backwards so the first extension is the outer most middleware and runs first. + for i := len(exts) - 1; i >= 0; i-- { + p := exts[i] + if p, ok := p.(graphql.OperationInterceptor); ok { + previous := e.operationMiddleware + e.operationMiddleware = func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler { + return p.InterceptOperation(ctx, func(ctx context.Context) graphql.ResponseHandler { + return previous(ctx, next) + }) + } + } + + if p, ok := p.(graphql.ResponseInterceptor); ok { + previous := e.responseMiddleware + e.responseMiddleware = func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + return p.InterceptResponse(ctx, func(ctx context.Context) *graphql.Response { + return previous(ctx, next) + }) + } + } + + 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) { + return p.InterceptField(ctx, func(ctx context.Context) (res interface{}, err error) { + return previous(ctx, next) + }) + } + } + } + + for _, p := range exts { + if p, ok := p.(graphql.OperationParameterMutator); ok { + e.operationParameterMutators = append(e.operationParameterMutators, p) + } + + if p, ok := p.(graphql.OperationContextMutator); ok { + e.operationContextMutators = append(e.operationContextMutators, p) + } + } + + return e +} + +type aroundOpFunc func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler + +func (r aroundOpFunc) ExtensionName() string { + return "InlineOperationFunc" +} + +func (r aroundOpFunc) Validate(schema graphql.ExecutableSchema) error { + if r == nil { + return fmt.Errorf("OperationFunc can not be nil") + } + return nil +} + +func (r aroundOpFunc) InterceptOperation(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler { + return r(ctx, next) +} + +type aroundRespFunc func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response + +func (r aroundRespFunc) ExtensionName() string { + return "InlineResponseFunc" +} + +func (r aroundRespFunc) Validate(schema graphql.ExecutableSchema) error { + if r == nil { + return fmt.Errorf("ResponseFunc can not be nil") + } + return nil +} + +func (r aroundRespFunc) InterceptResponse(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + return r(ctx, next) +} + +type aroundFieldFunc func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) + +func (f aroundFieldFunc) ExtensionName() string { + return "InlineFieldFunc" +} + +func (f aroundFieldFunc) Validate(schema graphql.ExecutableSchema) error { + if f == nil { + return fmt.Errorf("FieldFunc can not be nil") + } + return nil +} + +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 new file mode 100644 index 0000000..679e266 --- /dev/null +++ b/graphql/executor/testexecutor/testexecutor.go @@ -0,0 +1,202 @@ +package testexecutor + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io" + "time" + + "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/executor" +) + +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 { + next := make(chan struct{}) + + schema := gqlparser.MustLoadSchema(&ast.Source{Input: ` + type Query { + name: String! + find(id: Int!): String! + } + type Mutation { + name: String! + } + type Subscription { + name: String! + } + `}) + + exec := &TestExecutor{ + next: next, + } + + exec.schema = &graphql.ExecutableSchemaMock{ + ExecFunc: func(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + switch rc.Operation.Operation { + case ast.Query: + ran := false + return func(ctx context.Context) *graphql.Response { + if ran { + return nil + } + ran = true + // Field execution happens inside the generated code, lets simulate some of it. + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ + Object: "Query", + Field: graphql.CollectedField{ + Field: &ast.Field{ + Name: "name", + Alias: "name", + Definition: schema.Types["Query"].Fields.ForName("name"), + }, + }, + }) + 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) + }) + + 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")) + case ast.Subscription: + return func(context context.Context) *graphql.Response { + select { + case <-ctx.Done(): + return nil + case <-next: + return &graphql.Response{ + Data: []byte(`{"name":"test"}`), + } + } + } + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } + }, + SchemaFunc: func() *ast.Schema { + return schema + }, + ComplexityFunc: func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (i int, b bool) { + return exec.complexity, true + }, + } + + exec.Executor = executor.New(exec.schema) + return exec +} + +// NewError provides a server for use in resolver error 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 NewError() *TestExecutor { + next := make(chan struct{}) + + schema := gqlparser.MustLoadSchema(&ast.Source{Input: ` + type Query { + name: String! + } + `}) + + exec := &TestExecutor{ + next: next, + } + + exec.schema = &graphql.ExecutableSchemaMock{ + ExecFunc: func(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + switch rc.Operation.Operation { + case ast.Query: + ran := false + return func(ctx context.Context) *graphql.Response { + if ran { + return nil + } + ran = true + + graphql.AddError(ctx, fmt.Errorf("resolver error")) + + return &graphql.Response{ + Data: []byte(`null`), + } + } + case ast.Mutation: + return graphql.OneShot(graphql.ErrorResponse(ctx, "mutations are not supported")) + case ast.Subscription: + return graphql.OneShot(graphql.ErrorResponse(ctx, "subscription are not supported")) + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } + }, + SchemaFunc: func() *ast.Schema { + return schema + }, + ComplexityFunc: func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (i int, b bool) { + return exec.complexity, true + }, + } + + exec.Executor = executor.New(exec.schema) + return exec +} + +type TestExecutor struct { + *executor.Executor + schema graphql.ExecutableSchema + next chan struct{} + complexity int +} + +func (e *TestExecutor) Schema() graphql.ExecutableSchema { + return e.schema +} + +func (e *TestExecutor) SendNextSubscriptionMessage() { + select { + case e.next <- struct{}{}: + case <-time.After(1 * time.Second): + fmt.Println("WARNING: no active subscription") + } +} + +func (e *TestExecutor) SetCalculatedComplexity(complexity int) { + e.complexity = complexity +} diff --git a/graphql/fieldset.go b/graphql/fieldset.go new file mode 100644 index 0000000..2c9e3dc --- /dev/null +++ b/graphql/fieldset.go @@ -0,0 +1,70 @@ +package graphql + +import ( + "context" + "io" + "sync" +) + +type FieldSet struct { + fields []CollectedField + Values []Marshaler + Invalids uint32 + delayed []delayedResult +} + +type delayedResult struct { + i int + f func(context.Context) Marshaler +} + +func NewFieldSet(fields []CollectedField) *FieldSet { + return &FieldSet{ + fields: fields, + Values: make([]Marshaler, len(fields)), + } +} + +func (m *FieldSet) AddField(field CollectedField) { + m.fields = append(m.fields, field) + m.Values = append(m.Values, nil) +} + +func (m *FieldSet) Concurrently(i int, f func(context.Context) Marshaler) { + m.delayed = append(m.delayed, delayedResult{i: i, f: f}) +} + +func (m *FieldSet) Dispatch(ctx context.Context) { + if len(m.delayed) == 1 { + // only one concurrent task, no need to spawn a goroutine or deal create waitgroups + d := m.delayed[0] + m.Values[d.i] = d.f(ctx) + } else if len(m.delayed) > 1 { + // more than one concurrent task, use the main goroutine to do one, only spawn goroutines for the others + + var wg sync.WaitGroup + for _, d := range m.delayed[1:] { + wg.Add(1) + go func(d delayedResult) { + defer wg.Done() + m.Values[d.i] = d.f(ctx) + }(d) + } + + m.Values[m.delayed[0].i] = m.delayed[0].f(ctx) + wg.Wait() + } +} + +func (m *FieldSet) MarshalGQL(writer io.Writer) { + writer.Write(openBrace) + for i, field := range m.fields { + if i != 0 { + writer.Write(comma) + } + writeQuotedString(writer, field.Alias) + writer.Write(colon) + m.Values[i].MarshalGQL(writer) + } + writer.Write(closeBrace) +} diff --git a/graphql/float.go b/graphql/float.go new file mode 100644 index 0000000..ccb825d --- /dev/null +++ b/graphql/float.go @@ -0,0 +1,47 @@ +package graphql + +import ( + "context" + "encoding/json" + "fmt" + "io" + "math" + "strconv" +) + +func MarshalFloat(f float64) Marshaler { + return WriterFunc(func(w io.Writer) { + io.WriteString(w, fmt.Sprintf("%g", f)) + }) +} + +func UnmarshalFloat(v interface{}) (float64, error) { + switch v := v.(type) { + case string: + return strconv.ParseFloat(v, 64) + case int: + return float64(v), nil + case int64: + return float64(v), nil + case float64: + return v, nil + case json.Number: + return strconv.ParseFloat(string(v), 64) + default: + 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/float_test.go b/graphql/float_test.go new file mode 100644 index 0000000..7590563 --- /dev/null +++ b/graphql/float_test.go @@ -0,0 +1,22 @@ +package graphql + +import ( + "bytes" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestFloat(t *testing.T) { + assert.Equal(t, "123", m2s(MarshalFloat(123))) + assert.Equal(t, "1.2345678901", m2s(MarshalFloat(1.2345678901))) + assert.Equal(t, "1.2345678901234567", m2s(MarshalFloat(1.234567890123456789))) + assert.Equal(t, "1.2e+20", m2s(MarshalFloat(1.2e+20))) + assert.Equal(t, "1.2e-20", m2s(MarshalFloat(1.2e-20))) +} + +func m2s(m Marshaler) string { + var b bytes.Buffer + m.MarshalGQL(&b) + return b.String() +} diff --git a/graphql/handler.go b/graphql/handler.go new file mode 100644 index 0000000..cd35874 --- /dev/null +++ b/graphql/handler.go @@ -0,0 +1,131 @@ +package graphql + +import ( + "context" + "net/http" + "strconv" + "strings" + + "github.com/vektah/gqlparser/v2/gqlerror" +) + +type ( + OperationMiddleware func(ctx context.Context, next OperationHandler) ResponseHandler + OperationHandler func(ctx context.Context) ResponseHandler + + ResponseHandler func(ctx context.Context) *Response + ResponseMiddleware func(ctx context.Context, next ResponseHandler) *Response + + 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"` + Variables map[string]interface{} `json:"variables"` + Extensions map[string]interface{} `json:"extensions"` + Headers http.Header `json:"headers"` + + ReadTime TraceTiming `json:"-"` + } + + GraphExecutor interface { + CreateOperationContext(ctx context.Context, params *RawParams) (*OperationContext, gqlerror.List) + DispatchOperation(ctx context.Context, rc *OperationContext) (ResponseHandler, context.Context) + DispatchError(ctx context.Context, list gqlerror.List) *Response + } + + // HandlerExtension adds functionality to the http handler. See the list of possible hook points below + // Its important to understand the lifecycle of a graphql request and the terminology we use in gqlgen + // before working with these + // + // +--- REQUEST POST /graphql --------------------------------------------+ + // | +- OPERATION query OpName { viewer { name } } -----------------------+ | + // | | RESPONSE { "data": { "viewer": { "name": "bob" } } } | | + // | +- OPERATION subscription OpName2 { chat { message } } --------------+ | + // | | RESPONSE { "data": { "chat": { "message": "hello" } } } | | + // | | RESPONSE { "data": { "chat": { "message": "byee" } } } | | + // | +--------------------------------------------------------------------+ | + // +------------------------------------------------------------------------+ + HandlerExtension interface { + // ExtensionName should be a CamelCase string version of the extension which may be shown in stats and logging. + ExtensionName() string + // Validate is called when adding an extension to the server, it allows validation against the servers schema. + Validate(schema ExecutableSchema) error + } + + // OperationParameterMutator is called before creating a request context. allows manipulating the raw query + // on the way in. + OperationParameterMutator interface { + MutateOperationParameters(ctx context.Context, request *RawParams) *gqlerror.Error + } + + // OperationContextMutator is called after creating the request context, but before executing the root resolver. + OperationContextMutator interface { + MutateOperationContext(ctx context.Context, rc *OperationContext) *gqlerror.Error + } + + // OperationInterceptor is called for each incoming query, for basic requests the writer will be invoked once, + // for subscriptions it will be invoked multiple times. + OperationInterceptor interface { + InterceptOperation(ctx context.Context, next OperationHandler) ResponseHandler + } + + // ResponseInterceptor is called around each graphql operation response. This can be called many times for a single + // operation the case of subscriptions. + ResponseInterceptor interface { + 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) + } + + // Transport provides support for different wire level encodings of graphql requests, eg Form, Get, Post, Websocket + Transport interface { + Supports(r *http.Request) bool + Do(w http.ResponseWriter, r *http.Request, exec GraphExecutor) + } +) + +type Status int + +func (p *RawParams) AddUpload(upload Upload, key, path string) *gqlerror.Error { + if !strings.HasPrefix(path, "variables.") { + return gqlerror.Errorf("invalid operations paths for key %s", key) + } + + var ptr interface{} = p.Variables + parts := strings.Split(path, ".") + + // skip the first part (variables) because we started there + for i, p := range parts[1:] { + last := i == len(parts)-2 + if ptr == nil { + return gqlerror.Errorf("path is missing \"variables.\" prefix, key: %s, path: %s", key, path) + } + if index, parseNbrErr := strconv.Atoi(p); parseNbrErr == nil { + if last { + ptr.([]interface{})[index] = upload + } else { + ptr = ptr.([]interface{})[index] + } + } else { + if last { + ptr.(map[string]interface{})[p] = upload + } else { + ptr = ptr.(map[string]interface{})[p] + } + } + } + + return nil +} diff --git a/graphql/handler/apollofederatedtracingv1/generated/apollo_trace.pb.go b/graphql/handler/apollofederatedtracingv1/generated/apollo_trace.pb.go new file mode 100644 index 0000000..7972d84 --- /dev/null +++ b/graphql/handler/apollofederatedtracingv1/generated/apollo_trace.pb.go @@ -0,0 +1,3207 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.19.4 +// source: apollo_trace.proto + +package generated + +import ( + reflect "reflect" + sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Trace_CachePolicy_Scope int32 + +const ( + Trace_CachePolicy_UNKNOWN Trace_CachePolicy_Scope = 0 + Trace_CachePolicy_PUBLIC Trace_CachePolicy_Scope = 1 + Trace_CachePolicy_PRIVATE Trace_CachePolicy_Scope = 2 +) + +// Enum value maps for Trace_CachePolicy_Scope. +var ( + Trace_CachePolicy_Scope_name = map[int32]string{ + 0: "UNKNOWN", + 1: "PUBLIC", + 2: "PRIVATE", + } + Trace_CachePolicy_Scope_value = map[string]int32{ + "UNKNOWN": 0, + "PUBLIC": 1, + "PRIVATE": 2, + } +) + +func (x Trace_CachePolicy_Scope) Enum() *Trace_CachePolicy_Scope { + p := new(Trace_CachePolicy_Scope) + *p = x + return p +} + +func (x Trace_CachePolicy_Scope) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Trace_CachePolicy_Scope) Descriptor() protoreflect.EnumDescriptor { + return file_apollo_trace_proto_enumTypes[0].Descriptor() +} + +func (Trace_CachePolicy_Scope) Type() protoreflect.EnumType { + return &file_apollo_trace_proto_enumTypes[0] +} + +func (x Trace_CachePolicy_Scope) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Trace_CachePolicy_Scope.Descriptor instead. +func (Trace_CachePolicy_Scope) EnumDescriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{0, 0, 0} +} + +type Trace_HTTP_Method int32 + +const ( + Trace_HTTP_UNKNOWN Trace_HTTP_Method = 0 + Trace_HTTP_OPTIONS Trace_HTTP_Method = 1 + Trace_HTTP_GET Trace_HTTP_Method = 2 + Trace_HTTP_HEAD Trace_HTTP_Method = 3 + Trace_HTTP_POST Trace_HTTP_Method = 4 + Trace_HTTP_PUT Trace_HTTP_Method = 5 + Trace_HTTP_DELETE Trace_HTTP_Method = 6 + Trace_HTTP_TRACE Trace_HTTP_Method = 7 + Trace_HTTP_CONNECT Trace_HTTP_Method = 8 + Trace_HTTP_PATCH Trace_HTTP_Method = 9 +) + +// Enum value maps for Trace_HTTP_Method. +var ( + Trace_HTTP_Method_name = map[int32]string{ + 0: "UNKNOWN", + 1: "OPTIONS", + 2: "GET", + 3: "HEAD", + 4: "POST", + 5: "PUT", + 6: "DELETE", + 7: "TRACE", + 8: "CONNECT", + 9: "PATCH", + } + Trace_HTTP_Method_value = map[string]int32{ + "UNKNOWN": 0, + "OPTIONS": 1, + "GET": 2, + "HEAD": 3, + "POST": 4, + "PUT": 5, + "DELETE": 6, + "TRACE": 7, + "CONNECT": 8, + "PATCH": 9, + } +) + +func (x Trace_HTTP_Method) Enum() *Trace_HTTP_Method { + p := new(Trace_HTTP_Method) + *p = x + return p +} + +func (x Trace_HTTP_Method) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Trace_HTTP_Method) Descriptor() protoreflect.EnumDescriptor { + return file_apollo_trace_proto_enumTypes[1].Descriptor() +} + +func (Trace_HTTP_Method) Type() protoreflect.EnumType { + return &file_apollo_trace_proto_enumTypes[1] +} + +func (x Trace_HTTP_Method) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Trace_HTTP_Method.Descriptor instead. +func (Trace_HTTP_Method) EnumDescriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{0, 3, 0} +} + +type Trace struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Wallclock time when the trace began. + StartTime *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"` // required + // Wallclock time when the trace ended. + EndTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=end_time,json=endTime,proto3" json:"end_time,omitempty"` // required + // High precision duration of the trace; may not equal end_time-start_time + // (eg, if your machine's clock changed during the trace). + DurationNs uint64 `protobuf:"varint,11,opt,name=duration_ns,json=durationNs,proto3" json:"duration_ns,omitempty"` // required + // A tree containing information about all resolvers run directly by this + // service, including errors. + Root *Trace_Node `protobuf:"bytes,14,opt,name=root,proto3" json:"root,omitempty"` + // In addition to details.raw_query, we include a "signature" of the query, + // which can be normalized: for example, you may want to discard aliases, drop + // unused operations and fragments, sort fields, etc. The most important thing + // here is that the signature match the signature in StatsReports. In + // StatsReports signatures show up as the key in the per_query map (with the + // operation name prepended). The signature should be a valid GraphQL query. + // All traces must have a signature; if this Trace is in a FullTracesReport + // that signature is in the key of traces_per_query rather than in this field. + // Engineproxy provides the signature in legacy_signature_needs_resigning + // instead. + Signature string `protobuf:"bytes,19,opt,name=signature,proto3" json:"signature,omitempty"` + // Optional: when GraphQL parsing or validation against the GraphQL schema fails, these fields + // can include reference to the operation being sent for users to dig into the set of operations + // that are failing validation. + UnexecutedOperationBody string `protobuf:"bytes,27,opt,name=unexecutedOperationBody,proto3" json:"unexecutedOperationBody,omitempty"` + UnexecutedOperationName string `protobuf:"bytes,28,opt,name=unexecutedOperationName,proto3" json:"unexecutedOperationName,omitempty"` + Details *Trace_Details `protobuf:"bytes,6,opt,name=details,proto3" json:"details,omitempty"` + ClientName string `protobuf:"bytes,7,opt,name=client_name,json=clientName,proto3" json:"client_name,omitempty"` + ClientVersion string `protobuf:"bytes,8,opt,name=client_version,json=clientVersion,proto3" json:"client_version,omitempty"` + Http *Trace_HTTP `protobuf:"bytes,10,opt,name=http,proto3" json:"http,omitempty"` + CachePolicy *Trace_CachePolicy `protobuf:"bytes,18,opt,name=cache_policy,json=cachePolicy,proto3" json:"cache_policy,omitempty"` + // If this Trace was created by a gateway, this is the query plan, including + // sub-Traces for federated services. Note that the 'root' tree on the + // top-level Trace won't contain any resolvers (though it could contain errors + // that occurred in the gateway itself). + QueryPlan *Trace_QueryPlanNode `protobuf:"bytes,26,opt,name=query_plan,json=queryPlan,proto3" json:"query_plan,omitempty"` + // Was this response served from a full query response cache? (In that case + // the node tree will have no resolvers.) + FullQueryCacheHit bool `protobuf:"varint,20,opt,name=full_query_cache_hit,json=fullQueryCacheHit,proto3" json:"full_query_cache_hit,omitempty"` + // Was this query specified successfully as a persisted query hash? + PersistedQueryHit bool `protobuf:"varint,21,opt,name=persisted_query_hit,json=persistedQueryHit,proto3" json:"persisted_query_hit,omitempty"` + // Did this query contain both a full query string and a persisted query hash? + // (This typically means that a previous request was rejected as an unknown + // persisted query.) + PersistedQueryRegister bool `protobuf:"varint,22,opt,name=persisted_query_register,json=persistedQueryRegister,proto3" json:"persisted_query_register,omitempty"` + // Was this operation registered and a part of the safelist? + RegisteredOperation bool `protobuf:"varint,24,opt,name=registered_operation,json=registeredOperation,proto3" json:"registered_operation,omitempty"` + // Was this operation forbidden due to lack of safelisting? + ForbiddenOperation bool `protobuf:"varint,25,opt,name=forbidden_operation,json=forbiddenOperation,proto3" json:"forbidden_operation,omitempty"` + // Some servers don't do field-level instrumentation for every request and assign + // each request a "weight" for each request that they do instrument. When this + // trace is aggregated into field usage stats, it should count as this value + // towards the estimated_execution_count rather than just 1. This value should + // typically be at least 1. + // + // 0 is treated as 1 for backwards compatibility. + FieldExecutionWeight float64 `protobuf:"fixed64,31,opt,name=field_execution_weight,json=fieldExecutionWeight,proto3" json:"field_execution_weight,omitempty"` +} + +func (x *Trace) Reset() { + *x = Trace{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Trace) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Trace) ProtoMessage() {} + +func (x *Trace) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Trace.ProtoReflect.Descriptor instead. +func (*Trace) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{0} +} + +func (x *Trace) GetStartTime() *timestamppb.Timestamp { + if x != nil { + return x.StartTime + } + return nil +} + +func (x *Trace) GetEndTime() *timestamppb.Timestamp { + if x != nil { + return x.EndTime + } + return nil +} + +func (x *Trace) GetDurationNs() uint64 { + if x != nil { + return x.DurationNs + } + return 0 +} + +func (x *Trace) GetRoot() *Trace_Node { + if x != nil { + return x.Root + } + return nil +} + +func (x *Trace) GetSignature() string { + if x != nil { + return x.Signature + } + return "" +} + +func (x *Trace) GetUnexecutedOperationBody() string { + if x != nil { + return x.UnexecutedOperationBody + } + return "" +} + +func (x *Trace) GetUnexecutedOperationName() string { + if x != nil { + return x.UnexecutedOperationName + } + return "" +} + +func (x *Trace) GetDetails() *Trace_Details { + if x != nil { + return x.Details + } + return nil +} + +func (x *Trace) GetClientName() string { + if x != nil { + return x.ClientName + } + return "" +} + +func (x *Trace) GetClientVersion() string { + if x != nil { + return x.ClientVersion + } + return "" +} + +func (x *Trace) GetHttp() *Trace_HTTP { + if x != nil { + return x.Http + } + return nil +} + +func (x *Trace) GetCachePolicy() *Trace_CachePolicy { + if x != nil { + return x.CachePolicy + } + return nil +} + +func (x *Trace) GetQueryPlan() *Trace_QueryPlanNode { + if x != nil { + return x.QueryPlan + } + return nil +} + +func (x *Trace) GetFullQueryCacheHit() bool { + if x != nil { + return x.FullQueryCacheHit + } + return false +} + +func (x *Trace) GetPersistedQueryHit() bool { + if x != nil { + return x.PersistedQueryHit + } + return false +} + +func (x *Trace) GetPersistedQueryRegister() bool { + if x != nil { + return x.PersistedQueryRegister + } + return false +} + +func (x *Trace) GetRegisteredOperation() bool { + if x != nil { + return x.RegisteredOperation + } + return false +} + +func (x *Trace) GetForbiddenOperation() bool { + if x != nil { + return x.ForbiddenOperation + } + return false +} + +func (x *Trace) GetFieldExecutionWeight() float64 { + if x != nil { + return x.FieldExecutionWeight + } + return 0 +} + +// The `service` value embedded within the header key is not guaranteed to contain an actual service, +// and, in most cases, the service information is trusted to come from upstream processing. If the +// service _is_ specified in this header, then it is checked to match the context that is reporting it. +// Otherwise, the service information is deduced from the token context of the reporter and then sent +// along via other mechanisms (in Kafka, the `ReportKafkaKey). The other information (hostname, +// agent_version, etc.) is sent by the Apollo Engine Reporting agent, but we do not currently save that +// information to any of our persistent storage. +type ReportHeader struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // eg "mygraph@myvariant" + GraphRef string `protobuf:"bytes,12,opt,name=graph_ref,json=graphRef,proto3" json:"graph_ref,omitempty"` + // eg "host-01.example.com" + Hostname string `protobuf:"bytes,5,opt,name=hostname,proto3" json:"hostname,omitempty"` + // eg "engineproxy 0.1.0" + AgentVersion string `protobuf:"bytes,6,opt,name=agent_version,json=agentVersion,proto3" json:"agent_version,omitempty"` // required + // eg "prod-4279-20160804T065423Z-5-g3cf0aa8" (taken from `git describe --tags`) + ServiceVersion string `protobuf:"bytes,7,opt,name=service_version,json=serviceVersion,proto3" json:"service_version,omitempty"` + // eg "node v4.6.0" + RuntimeVersion string `protobuf:"bytes,8,opt,name=runtime_version,json=runtimeVersion,proto3" json:"runtime_version,omitempty"` + // eg "Linux box 4.6.5-1-ec2 #1 SMP Mon Aug 1 02:31:38 PDT 2016 x86_64 GNU/Linux" + Uname string `protobuf:"bytes,9,opt,name=uname,proto3" json:"uname,omitempty"` + // An id that is used to represent the schema to Apollo Graph Manager + // Using this in place of what used to be schema_hash, since that is no longer + // attached to a schema in the backend. + ExecutableSchemaId string `protobuf:"bytes,11,opt,name=executable_schema_id,json=executableSchemaId,proto3" json:"executable_schema_id,omitempty"` +} + +func (x *ReportHeader) Reset() { + *x = ReportHeader{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReportHeader) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReportHeader) ProtoMessage() {} + +func (x *ReportHeader) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReportHeader.ProtoReflect.Descriptor instead. +func (*ReportHeader) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{1} +} + +func (x *ReportHeader) GetGraphRef() string { + if x != nil { + return x.GraphRef + } + return "" +} + +func (x *ReportHeader) GetHostname() string { + if x != nil { + return x.Hostname + } + return "" +} + +func (x *ReportHeader) GetAgentVersion() string { + if x != nil { + return x.AgentVersion + } + return "" +} + +func (x *ReportHeader) GetServiceVersion() string { + if x != nil { + return x.ServiceVersion + } + return "" +} + +func (x *ReportHeader) GetRuntimeVersion() string { + if x != nil { + return x.RuntimeVersion + } + return "" +} + +func (x *ReportHeader) GetUname() string { + if x != nil { + return x.Uname + } + return "" +} + +func (x *ReportHeader) GetExecutableSchemaId() string { + if x != nil { + return x.ExecutableSchemaId + } + return "" +} + +type PathErrorStats struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Children map[string]*PathErrorStats `protobuf:"bytes,1,rep,name=children,proto3" json:"children,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + ErrorsCount uint64 `protobuf:"varint,4,opt,name=errors_count,json=errorsCount,proto3" json:"errors_count,omitempty"` + RequestsWithErrorsCount uint64 `protobuf:"varint,5,opt,name=requests_with_errors_count,json=requestsWithErrorsCount,proto3" json:"requests_with_errors_count,omitempty"` +} + +func (x *PathErrorStats) Reset() { + *x = PathErrorStats{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PathErrorStats) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PathErrorStats) ProtoMessage() {} + +func (x *PathErrorStats) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PathErrorStats.ProtoReflect.Descriptor instead. +func (*PathErrorStats) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{2} +} + +func (x *PathErrorStats) GetChildren() map[string]*PathErrorStats { + if x != nil { + return x.Children + } + return nil +} + +func (x *PathErrorStats) GetErrorsCount() uint64 { + if x != nil { + return x.ErrorsCount + } + return 0 +} + +func (x *PathErrorStats) GetRequestsWithErrorsCount() uint64 { + if x != nil { + return x.RequestsWithErrorsCount + } + return 0 +} + +type QueryLatencyStats struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + LatencyCount []int64 `protobuf:"zigzag64,13,rep,packed,name=latency_count,json=latencyCount,proto3" json:"latency_count,omitempty"` + RequestCount uint64 `protobuf:"varint,2,opt,name=request_count,json=requestCount,proto3" json:"request_count,omitempty"` + CacheHits uint64 `protobuf:"varint,3,opt,name=cache_hits,json=cacheHits,proto3" json:"cache_hits,omitempty"` + PersistedQueryHits uint64 `protobuf:"varint,4,opt,name=persisted_query_hits,json=persistedQueryHits,proto3" json:"persisted_query_hits,omitempty"` + PersistedQueryMisses uint64 `protobuf:"varint,5,opt,name=persisted_query_misses,json=persistedQueryMisses,proto3" json:"persisted_query_misses,omitempty"` + CacheLatencyCount []int64 `protobuf:"zigzag64,14,rep,packed,name=cache_latency_count,json=cacheLatencyCount,proto3" json:"cache_latency_count,omitempty"` + RootErrorStats *PathErrorStats `protobuf:"bytes,7,opt,name=root_error_stats,json=rootErrorStats,proto3" json:"root_error_stats,omitempty"` + RequestsWithErrorsCount uint64 `protobuf:"varint,8,opt,name=requests_with_errors_count,json=requestsWithErrorsCount,proto3" json:"requests_with_errors_count,omitempty"` + PublicCacheTtlCount []int64 `protobuf:"zigzag64,15,rep,packed,name=public_cache_ttl_count,json=publicCacheTtlCount,proto3" json:"public_cache_ttl_count,omitempty"` + PrivateCacheTtlCount []int64 `protobuf:"zigzag64,16,rep,packed,name=private_cache_ttl_count,json=privateCacheTtlCount,proto3" json:"private_cache_ttl_count,omitempty"` + RegisteredOperationCount uint64 `protobuf:"varint,11,opt,name=registered_operation_count,json=registeredOperationCount,proto3" json:"registered_operation_count,omitempty"` + ForbiddenOperationCount uint64 `protobuf:"varint,12,opt,name=forbidden_operation_count,json=forbiddenOperationCount,proto3" json:"forbidden_operation_count,omitempty"` + // The number of requests that were executed without field-level + // instrumentation (and thus do not contribute to `observed_execution_count` + // fields on this message's cousin-twice-removed FieldStats). + RequestsWithoutFieldInstrumentation uint64 `protobuf:"varint,17,opt,name=requests_without_field_instrumentation,json=requestsWithoutFieldInstrumentation,proto3" json:"requests_without_field_instrumentation,omitempty"` +} + +func (x *QueryLatencyStats) Reset() { + *x = QueryLatencyStats{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *QueryLatencyStats) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryLatencyStats) ProtoMessage() {} + +func (x *QueryLatencyStats) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use QueryLatencyStats.ProtoReflect.Descriptor instead. +func (*QueryLatencyStats) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{3} +} + +func (x *QueryLatencyStats) GetLatencyCount() []int64 { + if x != nil { + return x.LatencyCount + } + return nil +} + +func (x *QueryLatencyStats) GetRequestCount() uint64 { + if x != nil { + return x.RequestCount + } + return 0 +} + +func (x *QueryLatencyStats) GetCacheHits() uint64 { + if x != nil { + return x.CacheHits + } + return 0 +} + +func (x *QueryLatencyStats) GetPersistedQueryHits() uint64 { + if x != nil { + return x.PersistedQueryHits + } + return 0 +} + +func (x *QueryLatencyStats) GetPersistedQueryMisses() uint64 { + if x != nil { + return x.PersistedQueryMisses + } + return 0 +} + +func (x *QueryLatencyStats) GetCacheLatencyCount() []int64 { + if x != nil { + return x.CacheLatencyCount + } + return nil +} + +func (x *QueryLatencyStats) GetRootErrorStats() *PathErrorStats { + if x != nil { + return x.RootErrorStats + } + return nil +} + +func (x *QueryLatencyStats) GetRequestsWithErrorsCount() uint64 { + if x != nil { + return x.RequestsWithErrorsCount + } + return 0 +} + +func (x *QueryLatencyStats) GetPublicCacheTtlCount() []int64 { + if x != nil { + return x.PublicCacheTtlCount + } + return nil +} + +func (x *QueryLatencyStats) GetPrivateCacheTtlCount() []int64 { + if x != nil { + return x.PrivateCacheTtlCount + } + return nil +} + +func (x *QueryLatencyStats) GetRegisteredOperationCount() uint64 { + if x != nil { + return x.RegisteredOperationCount + } + return 0 +} + +func (x *QueryLatencyStats) GetForbiddenOperationCount() uint64 { + if x != nil { + return x.ForbiddenOperationCount + } + return 0 +} + +func (x *QueryLatencyStats) GetRequestsWithoutFieldInstrumentation() uint64 { + if x != nil { + return x.RequestsWithoutFieldInstrumentation + } + return 0 +} + +type StatsContext struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ClientName string `protobuf:"bytes,2,opt,name=client_name,json=clientName,proto3" json:"client_name,omitempty"` + ClientVersion string `protobuf:"bytes,3,opt,name=client_version,json=clientVersion,proto3" json:"client_version,omitempty"` +} + +func (x *StatsContext) Reset() { + *x = StatsContext{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StatsContext) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StatsContext) ProtoMessage() {} + +func (x *StatsContext) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StatsContext.ProtoReflect.Descriptor instead. +func (*StatsContext) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{4} +} + +func (x *StatsContext) GetClientName() string { + if x != nil { + return x.ClientName + } + return "" +} + +func (x *StatsContext) GetClientVersion() string { + if x != nil { + return x.ClientVersion + } + return "" +} + +type ContextualizedQueryLatencyStats struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + QueryLatencyStats *QueryLatencyStats `protobuf:"bytes,1,opt,name=query_latency_stats,json=queryLatencyStats,proto3" json:"query_latency_stats,omitempty"` + Context *StatsContext `protobuf:"bytes,2,opt,name=context,proto3" json:"context,omitempty"` +} + +func (x *ContextualizedQueryLatencyStats) Reset() { + *x = ContextualizedQueryLatencyStats{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ContextualizedQueryLatencyStats) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ContextualizedQueryLatencyStats) ProtoMessage() {} + +func (x *ContextualizedQueryLatencyStats) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ContextualizedQueryLatencyStats.ProtoReflect.Descriptor instead. +func (*ContextualizedQueryLatencyStats) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{5} +} + +func (x *ContextualizedQueryLatencyStats) GetQueryLatencyStats() *QueryLatencyStats { + if x != nil { + return x.QueryLatencyStats + } + return nil +} + +func (x *ContextualizedQueryLatencyStats) GetContext() *StatsContext { + if x != nil { + return x.Context + } + return nil +} + +type ContextualizedTypeStats struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Context *StatsContext `protobuf:"bytes,1,opt,name=context,proto3" json:"context,omitempty"` + PerTypeStat map[string]*TypeStat `protobuf:"bytes,2,rep,name=per_type_stat,json=perTypeStat,proto3" json:"per_type_stat,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *ContextualizedTypeStats) Reset() { + *x = ContextualizedTypeStats{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ContextualizedTypeStats) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ContextualizedTypeStats) ProtoMessage() {} + +func (x *ContextualizedTypeStats) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ContextualizedTypeStats.ProtoReflect.Descriptor instead. +func (*ContextualizedTypeStats) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{6} +} + +func (x *ContextualizedTypeStats) GetContext() *StatsContext { + if x != nil { + return x.Context + } + return nil +} + +func (x *ContextualizedTypeStats) GetPerTypeStat() map[string]*TypeStat { + if x != nil { + return x.PerTypeStat + } + return nil +} + +type FieldStat struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ReturnType string `protobuf:"bytes,3,opt,name=return_type,json=returnType,proto3" json:"return_type,omitempty"` // required; eg "String!" for User.email:String! + // Number of errors whose path is this field. Note that we assume that error + // tracking does *not* require field-level instrumentation so this *will* + // include errors from requests that don't contribute to the + // `observed_execution_count` field (and does not need to be scaled by + // field_execution_weight). + ErrorsCount uint64 `protobuf:"varint,4,opt,name=errors_count,json=errorsCount,proto3" json:"errors_count,omitempty"` + // Number of times that the resolver for this field is directly observed being + // executed. + ObservedExecutionCount uint64 `protobuf:"varint,5,opt,name=observed_execution_count,json=observedExecutionCount,proto3" json:"observed_execution_count,omitempty"` + // Same as `count` but potentially scaled upwards if the server was only + // performing field-level instrumentation on a sampling of operations. For + // example, if the server randomly instruments 1% of requests for this + // operation, this number will be 100 times greater than + // `observed_execution_count`. (When aggregating a Trace into FieldStats, + // this number goes up by the trace's `field_execution_weight` for each + // observed field execution, while `observed_execution_count` above goes + // up by 1.) + EstimatedExecutionCount uint64 `protobuf:"varint,10,opt,name=estimated_execution_count,json=estimatedExecutionCount,proto3" json:"estimated_execution_count,omitempty"` + // Number of times the resolver for this field is executed that resulted in + // at least one error. "Request" is a misnomer here as this corresponds to + // resolver calls, not overall operations. Like `errors_count` above, this + // includes all requests rather than just requests with field-level + // instrumentation. + RequestsWithErrorsCount uint64 `protobuf:"varint,6,opt,name=requests_with_errors_count,json=requestsWithErrorsCount,proto3" json:"requests_with_errors_count,omitempty"` + // Duration histogram for the latency of this field. Note that it is scaled in + // the same way as estimated_execution_count so its "total count" might be + // greater than `observed_execution_count` and may not exactly equal + // `estimated_execution_count` due to rounding. + LatencyCount []int64 `protobuf:"zigzag64,9,rep,packed,name=latency_count,json=latencyCount,proto3" json:"latency_count,omitempty"` +} + +func (x *FieldStat) Reset() { + *x = FieldStat{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FieldStat) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FieldStat) ProtoMessage() {} + +func (x *FieldStat) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FieldStat.ProtoReflect.Descriptor instead. +func (*FieldStat) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{7} +} + +func (x *FieldStat) GetReturnType() string { + if x != nil { + return x.ReturnType + } + return "" +} + +func (x *FieldStat) GetErrorsCount() uint64 { + if x != nil { + return x.ErrorsCount + } + return 0 +} + +func (x *FieldStat) GetObservedExecutionCount() uint64 { + if x != nil { + return x.ObservedExecutionCount + } + return 0 +} + +func (x *FieldStat) GetEstimatedExecutionCount() uint64 { + if x != nil { + return x.EstimatedExecutionCount + } + return 0 +} + +func (x *FieldStat) GetRequestsWithErrorsCount() uint64 { + if x != nil { + return x.RequestsWithErrorsCount + } + return 0 +} + +func (x *FieldStat) GetLatencyCount() []int64 { + if x != nil { + return x.LatencyCount + } + return nil +} + +type TypeStat struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Key is (eg) "email" for User.email:String! + PerFieldStat map[string]*FieldStat `protobuf:"bytes,3,rep,name=per_field_stat,json=perFieldStat,proto3" json:"per_field_stat,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *TypeStat) Reset() { + *x = TypeStat{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TypeStat) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TypeStat) ProtoMessage() {} + +func (x *TypeStat) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TypeStat.ProtoReflect.Descriptor instead. +func (*TypeStat) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{8} +} + +func (x *TypeStat) GetPerFieldStat() map[string]*FieldStat { + if x != nil { + return x.PerFieldStat + } + return nil +} + +type ReferencedFieldsForType struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Contains (eg) "email" for User.email:String! + FieldNames []string `protobuf:"bytes,1,rep,name=field_names,json=fieldNames,proto3" json:"field_names,omitempty"` + // True if this type is an interface. + IsInterface bool `protobuf:"varint,2,opt,name=is_interface,json=isInterface,proto3" json:"is_interface,omitempty"` +} + +func (x *ReferencedFieldsForType) Reset() { + *x = ReferencedFieldsForType{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReferencedFieldsForType) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReferencedFieldsForType) ProtoMessage() {} + +func (x *ReferencedFieldsForType) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReferencedFieldsForType.ProtoReflect.Descriptor instead. +func (*ReferencedFieldsForType) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{9} +} + +func (x *ReferencedFieldsForType) GetFieldNames() []string { + if x != nil { + return x.FieldNames + } + return nil +} + +func (x *ReferencedFieldsForType) GetIsInterface() bool { + if x != nil { + return x.IsInterface + } + return false +} + +// This is the top-level message used by the new traces ingress. This +// is designed for the apollo-engine-reporting TypeScript agent and will +// eventually be documented as a public ingress API. This message consists +// solely of traces; the equivalent of the StatsReport is automatically +// generated server-side from this message. Agent should either send a trace or include it in the stats +// for every request in this report. Generally, buffering up until a large +// size has been reached (say, 4MB) or 5-10 seconds has passed is appropriate. +// This message used to be know as FullTracesReport, but got renamed since it isn't just for traces anymore +type Report struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Header *ReportHeader `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` + // key is statsReportKey (# operationName\nsignature) Note that the nested + // traces will *not* have a signature or details.operationName (because the + // key is adequate). + // + // We also assume that traces don't have + // legacy_per_query_implicit_operation_name, and we don't require them to have + // details.raw_query (which would consume a lot of space and has privacy/data + // access issues, and isn't currently exposed by our app anyway). + TracesPerQuery map[string]*TracesAndStats `protobuf:"bytes,5,rep,name=traces_per_query,json=tracesPerQuery,proto3" json:"traces_per_query,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // This is the time that the requests in this trace are considered to have taken place + // If this field is not present the max of the end_time of each trace will be used instead. + // If there are no traces and no end_time present the report will not be able to be processed. + // Note: This will override the end_time from traces. + EndTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=end_time,json=endTime,proto3" json:"end_time,omitempty"` // required if no traces in this message + // Total number of operations processed during this period. + OperationCount uint64 `protobuf:"varint,6,opt,name=operation_count,json=operationCount,proto3" json:"operation_count,omitempty"` +} + +func (x *Report) Reset() { + *x = Report{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Report) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Report) ProtoMessage() {} + +func (x *Report) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Report.ProtoReflect.Descriptor instead. +func (*Report) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{10} +} + +func (x *Report) GetHeader() *ReportHeader { + if x != nil { + return x.Header + } + return nil +} + +func (x *Report) GetTracesPerQuery() map[string]*TracesAndStats { + if x != nil { + return x.TracesPerQuery + } + return nil +} + +func (x *Report) GetEndTime() *timestamppb.Timestamp { + if x != nil { + return x.EndTime + } + return nil +} + +func (x *Report) GetOperationCount() uint64 { + if x != nil { + return x.OperationCount + } + return 0 +} + +type ContextualizedStats struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Context *StatsContext `protobuf:"bytes,1,opt,name=context,proto3" json:"context,omitempty"` + QueryLatencyStats *QueryLatencyStats `protobuf:"bytes,2,opt,name=query_latency_stats,json=queryLatencyStats,proto3" json:"query_latency_stats,omitempty"` + // Key is type name. This structure provides data for the count and latency of individual + // field executions and thus only reflects operations for which field-level tracing occurred. + PerTypeStat map[string]*TypeStat `protobuf:"bytes,3,rep,name=per_type_stat,json=perTypeStat,proto3" json:"per_type_stat,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *ContextualizedStats) Reset() { + *x = ContextualizedStats{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ContextualizedStats) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ContextualizedStats) ProtoMessage() {} + +func (x *ContextualizedStats) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ContextualizedStats.ProtoReflect.Descriptor instead. +func (*ContextualizedStats) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{11} +} + +func (x *ContextualizedStats) GetContext() *StatsContext { + if x != nil { + return x.Context + } + return nil +} + +func (x *ContextualizedStats) GetQueryLatencyStats() *QueryLatencyStats { + if x != nil { + return x.QueryLatencyStats + } + return nil +} + +func (x *ContextualizedStats) GetPerTypeStat() map[string]*TypeStat { + if x != nil { + return x.PerTypeStat + } + return nil +} + +// A sequence of traces and stats. An individual operation should either be described as a trace +// or as part of stats, but not both. +type TracesAndStats struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Trace []*Trace `protobuf:"bytes,1,rep,name=trace,proto3" json:"trace,omitempty"` + StatsWithContext []*ContextualizedStats `protobuf:"bytes,2,rep,name=stats_with_context,json=statsWithContext,proto3" json:"stats_with_context,omitempty"` + // This describes the fields referenced in the operation. Note that this may + // include fields that don't show up in FieldStats (due to being interface fields, + // being nested under null fields or empty lists or non-matching fragments or + // `@include` or `@skip`, etc). It also may be missing fields that show up in FieldStats + // (as FieldStats will include the concrete object type for fields referenced + // via an interface type). + ReferencedFieldsByType map[string]*ReferencedFieldsForType `protobuf:"bytes,4,rep,name=referenced_fields_by_type,json=referencedFieldsByType,proto3" json:"referenced_fields_by_type,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // This field is used to validate that the algorithm used to construct `stats_with_context` + // matches similar algorithms in Apollo's servers. It is otherwise ignored and should not + // be included in reports. + InternalTracesContributingToStats []*Trace `protobuf:"bytes,3,rep,name=internal_traces_contributing_to_stats,json=internalTracesContributingToStats,proto3" json:"internal_traces_contributing_to_stats,omitempty"` +} + +func (x *TracesAndStats) Reset() { + *x = TracesAndStats{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TracesAndStats) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TracesAndStats) ProtoMessage() {} + +func (x *TracesAndStats) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TracesAndStats.ProtoReflect.Descriptor instead. +func (*TracesAndStats) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{12} +} + +func (x *TracesAndStats) GetTrace() []*Trace { + if x != nil { + return x.Trace + } + return nil +} + +func (x *TracesAndStats) GetStatsWithContext() []*ContextualizedStats { + if x != nil { + return x.StatsWithContext + } + return nil +} + +func (x *TracesAndStats) GetReferencedFieldsByType() map[string]*ReferencedFieldsForType { + if x != nil { + return x.ReferencedFieldsByType + } + return nil +} + +func (x *TracesAndStats) GetInternalTracesContributingToStats() []*Trace { + if x != nil { + return x.InternalTracesContributingToStats + } + return nil +} + +type Trace_CachePolicy struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Scope Trace_CachePolicy_Scope `protobuf:"varint,1,opt,name=scope,proto3,enum=Trace_CachePolicy_Scope" json:"scope,omitempty"` + MaxAgeNs int64 `protobuf:"varint,2,opt,name=max_age_ns,json=maxAgeNs,proto3" json:"max_age_ns,omitempty"` // use 0 for absent, -1 for 0 +} + +func (x *Trace_CachePolicy) Reset() { + *x = Trace_CachePolicy{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Trace_CachePolicy) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Trace_CachePolicy) ProtoMessage() {} + +func (x *Trace_CachePolicy) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Trace_CachePolicy.ProtoReflect.Descriptor instead. +func (*Trace_CachePolicy) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{0, 0} +} + +func (x *Trace_CachePolicy) GetScope() Trace_CachePolicy_Scope { + if x != nil { + return x.Scope + } + return Trace_CachePolicy_UNKNOWN +} + +func (x *Trace_CachePolicy) GetMaxAgeNs() int64 { + if x != nil { + return x.MaxAgeNs + } + return 0 +} + +type Trace_Details struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The variables associated with this query (unless the reporting agent is + // configured to keep them all private). Values are JSON: ie, strings are + // enclosed in double quotes, etc. The value of a private variable is + // the empty string. + VariablesJson map[string]string `protobuf:"bytes,4,rep,name=variables_json,json=variablesJson,proto3" json:"variables_json,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // This is deprecated and only used for legacy applications + // don't include this in traces inside a FullTracesReport; the operation + // name for these traces comes from the key of the traces_per_query map. + OperationName string `protobuf:"bytes,3,opt,name=operation_name,json=operationName,proto3" json:"operation_name,omitempty"` +} + +func (x *Trace_Details) Reset() { + *x = Trace_Details{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Trace_Details) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Trace_Details) ProtoMessage() {} + +func (x *Trace_Details) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[14] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Trace_Details.ProtoReflect.Descriptor instead. +func (*Trace_Details) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{0, 1} +} + +func (x *Trace_Details) GetVariablesJson() map[string]string { + if x != nil { + return x.VariablesJson + } + return nil +} + +func (x *Trace_Details) GetOperationName() string { + if x != nil { + return x.OperationName + } + return "" +} + +type Trace_Error struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` // required + Location []*Trace_Location `protobuf:"bytes,2,rep,name=location,proto3" json:"location,omitempty"` + TimeNs uint64 `protobuf:"varint,3,opt,name=time_ns,json=timeNs,proto3" json:"time_ns,omitempty"` + Json string `protobuf:"bytes,4,opt,name=json,proto3" json:"json,omitempty"` +} + +func (x *Trace_Error) Reset() { + *x = Trace_Error{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Trace_Error) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Trace_Error) ProtoMessage() {} + +func (x *Trace_Error) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Trace_Error.ProtoReflect.Descriptor instead. +func (*Trace_Error) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{0, 2} +} + +func (x *Trace_Error) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +func (x *Trace_Error) GetLocation() []*Trace_Location { + if x != nil { + return x.Location + } + return nil +} + +func (x *Trace_Error) GetTimeNs() uint64 { + if x != nil { + return x.TimeNs + } + return 0 +} + +func (x *Trace_Error) GetJson() string { + if x != nil { + return x.Json + } + return "" +} + +type Trace_HTTP struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Method Trace_HTTP_Method `protobuf:"varint,1,opt,name=method,proto3,enum=Trace_HTTP_Method" json:"method,omitempty"` + Host string `protobuf:"bytes,2,opt,name=host,proto3" json:"host,omitempty"` + Path string `protobuf:"bytes,3,opt,name=path,proto3" json:"path,omitempty"` + // Should exclude manual blacklist ("Auth" by default) + RequestHeaders map[string]*Trace_HTTP_Values `protobuf:"bytes,4,rep,name=request_headers,json=requestHeaders,proto3" json:"request_headers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + ResponseHeaders map[string]*Trace_HTTP_Values `protobuf:"bytes,5,rep,name=response_headers,json=responseHeaders,proto3" json:"response_headers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + StatusCode uint32 `protobuf:"varint,6,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` + Secure bool `protobuf:"varint,8,opt,name=secure,proto3" json:"secure,omitempty"` // TLS was used + Protocol string `protobuf:"bytes,9,opt,name=protocol,proto3" json:"protocol,omitempty"` // by convention "HTTP/1.0", "HTTP/1.1", "HTTP/2" or "h2" +} + +func (x *Trace_HTTP) Reset() { + *x = Trace_HTTP{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Trace_HTTP) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Trace_HTTP) ProtoMessage() {} + +func (x *Trace_HTTP) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[16] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Trace_HTTP.ProtoReflect.Descriptor instead. +func (*Trace_HTTP) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{0, 3} +} + +func (x *Trace_HTTP) GetMethod() Trace_HTTP_Method { + if x != nil { + return x.Method + } + return Trace_HTTP_UNKNOWN +} + +func (x *Trace_HTTP) GetHost() string { + if x != nil { + return x.Host + } + return "" +} + +func (x *Trace_HTTP) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +func (x *Trace_HTTP) GetRequestHeaders() map[string]*Trace_HTTP_Values { + if x != nil { + return x.RequestHeaders + } + return nil +} + +func (x *Trace_HTTP) GetResponseHeaders() map[string]*Trace_HTTP_Values { + if x != nil { + return x.ResponseHeaders + } + return nil +} + +func (x *Trace_HTTP) GetStatusCode() uint32 { + if x != nil { + return x.StatusCode + } + return 0 +} + +func (x *Trace_HTTP) GetSecure() bool { + if x != nil { + return x.Secure + } + return false +} + +func (x *Trace_HTTP) GetProtocol() string { + if x != nil { + return x.Protocol + } + return "" +} + +type Trace_Location struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Line uint32 `protobuf:"varint,1,opt,name=line,proto3" json:"line,omitempty"` + Column uint32 `protobuf:"varint,2,opt,name=column,proto3" json:"column,omitempty"` +} + +func (x *Trace_Location) Reset() { + *x = Trace_Location{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Trace_Location) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Trace_Location) ProtoMessage() {} + +func (x *Trace_Location) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[17] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Trace_Location.ProtoReflect.Descriptor instead. +func (*Trace_Location) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{0, 4} +} + +func (x *Trace_Location) GetLine() uint32 { + if x != nil { + return x.Line + } + return 0 +} + +func (x *Trace_Location) GetColumn() uint32 { + if x != nil { + return x.Column + } + return 0 +} + +// We store information on each resolver execution as a Node on a tree. +// The structure of the tree corresponds to the structure of the GraphQL +// response; it does not indicate the order in which resolvers were +// invoked. Note that nodes representing indexes (and the root node) +// don't contain all Node fields (eg types and times). +type Trace_Node struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The name of the field (for Nodes representing a resolver call) or the + // index in a list (for intermediate Nodes representing elements of a list). + // field_name is the name of the field as it appears in the GraphQL + // response: ie, it may be an alias. (In that case, the original_field_name + // field holds the actual field name from the schema.) In any context where + // we're building up a path, we use the response_name rather than the + // original_field_name. + // + // Types that are assignable to Id: + // *Trace_Node_ResponseName + // *Trace_Node_Index + Id isTrace_Node_Id `protobuf_oneof:"id"` + OriginalFieldName string `protobuf:"bytes,14,opt,name=original_field_name,json=originalFieldName,proto3" json:"original_field_name,omitempty"` + // The field's return type; e.g. "String!" for User.email:String! + Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"` + // The field's parent type; e.g. "User" for User.email:String! + ParentType string `protobuf:"bytes,13,opt,name=parent_type,json=parentType,proto3" json:"parent_type,omitempty"` + CachePolicy *Trace_CachePolicy `protobuf:"bytes,5,opt,name=cache_policy,json=cachePolicy,proto3" json:"cache_policy,omitempty"` + // relative to the trace's start_time, in ns + StartTime uint64 `protobuf:"varint,8,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"` + // relative to the trace's start_time, in ns + EndTime uint64 `protobuf:"varint,9,opt,name=end_time,json=endTime,proto3" json:"end_time,omitempty"` + Error []*Trace_Error `protobuf:"bytes,11,rep,name=error,proto3" json:"error,omitempty"` + Child []*Trace_Node `protobuf:"bytes,12,rep,name=child,proto3" json:"child,omitempty"` +} + +func (x *Trace_Node) Reset() { + *x = Trace_Node{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Trace_Node) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Trace_Node) ProtoMessage() {} + +func (x *Trace_Node) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[18] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Trace_Node.ProtoReflect.Descriptor instead. +func (*Trace_Node) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{0, 5} +} + +func (m *Trace_Node) GetId() isTrace_Node_Id { + if m != nil { + return m.Id + } + return nil +} + +func (x *Trace_Node) GetResponseName() string { + if x, ok := x.GetId().(*Trace_Node_ResponseName); ok { + return x.ResponseName + } + return "" +} + +func (x *Trace_Node) GetIndex() uint32 { + if x, ok := x.GetId().(*Trace_Node_Index); ok { + return x.Index + } + return 0 +} + +func (x *Trace_Node) GetOriginalFieldName() string { + if x != nil { + return x.OriginalFieldName + } + return "" +} + +func (x *Trace_Node) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *Trace_Node) GetParentType() string { + if x != nil { + return x.ParentType + } + return "" +} + +func (x *Trace_Node) GetCachePolicy() *Trace_CachePolicy { + if x != nil { + return x.CachePolicy + } + return nil +} + +func (x *Trace_Node) GetStartTime() uint64 { + if x != nil { + return x.StartTime + } + return 0 +} + +func (x *Trace_Node) GetEndTime() uint64 { + if x != nil { + return x.EndTime + } + return 0 +} + +func (x *Trace_Node) GetError() []*Trace_Error { + if x != nil { + return x.Error + } + return nil +} + +func (x *Trace_Node) GetChild() []*Trace_Node { + if x != nil { + return x.Child + } + return nil +} + +type isTrace_Node_Id interface { + isTrace_Node_Id() +} + +type Trace_Node_ResponseName struct { + ResponseName string `protobuf:"bytes,1,opt,name=response_name,json=responseName,proto3,oneof"` +} + +type Trace_Node_Index struct { + Index uint32 `protobuf:"varint,2,opt,name=index,proto3,oneof"` +} + +func (*Trace_Node_ResponseName) isTrace_Node_Id() {} + +func (*Trace_Node_Index) isTrace_Node_Id() {} + +// represents a node in the query plan, under which there is a trace tree for that service fetch. +// In particular, each fetch node represents a call to an implementing service, and calls to implementing +// services may not be unique. See https://github.com/apollographql/apollo-server/blob/main/packages/apollo-gateway/src/QueryPlan.ts +// for more information and details. +type Trace_QueryPlanNode struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Node: + // *Trace_QueryPlanNode_Sequence + // *Trace_QueryPlanNode_Parallel + // *Trace_QueryPlanNode_Fetch + // *Trace_QueryPlanNode_Flatten + Node isTrace_QueryPlanNode_Node `protobuf_oneof:"node"` +} + +func (x *Trace_QueryPlanNode) Reset() { + *x = Trace_QueryPlanNode{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Trace_QueryPlanNode) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Trace_QueryPlanNode) ProtoMessage() {} + +func (x *Trace_QueryPlanNode) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[19] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Trace_QueryPlanNode.ProtoReflect.Descriptor instead. +func (*Trace_QueryPlanNode) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{0, 6} +} + +func (m *Trace_QueryPlanNode) GetNode() isTrace_QueryPlanNode_Node { + if m != nil { + return m.Node + } + return nil +} + +func (x *Trace_QueryPlanNode) GetSequence() *Trace_QueryPlanNode_SequenceNode { + if x, ok := x.GetNode().(*Trace_QueryPlanNode_Sequence); ok { + return x.Sequence + } + return nil +} + +func (x *Trace_QueryPlanNode) GetParallel() *Trace_QueryPlanNode_ParallelNode { + if x, ok := x.GetNode().(*Trace_QueryPlanNode_Parallel); ok { + return x.Parallel + } + return nil +} + +func (x *Trace_QueryPlanNode) GetFetch() *Trace_QueryPlanNode_FetchNode { + if x, ok := x.GetNode().(*Trace_QueryPlanNode_Fetch); ok { + return x.Fetch + } + return nil +} + +func (x *Trace_QueryPlanNode) GetFlatten() *Trace_QueryPlanNode_FlattenNode { + if x, ok := x.GetNode().(*Trace_QueryPlanNode_Flatten); ok { + return x.Flatten + } + return nil +} + +type isTrace_QueryPlanNode_Node interface { + isTrace_QueryPlanNode_Node() +} + +type Trace_QueryPlanNode_Sequence struct { + Sequence *Trace_QueryPlanNode_SequenceNode `protobuf:"bytes,1,opt,name=sequence,proto3,oneof"` +} + +type Trace_QueryPlanNode_Parallel struct { + Parallel *Trace_QueryPlanNode_ParallelNode `protobuf:"bytes,2,opt,name=parallel,proto3,oneof"` +} + +type Trace_QueryPlanNode_Fetch struct { + Fetch *Trace_QueryPlanNode_FetchNode `protobuf:"bytes,3,opt,name=fetch,proto3,oneof"` +} + +type Trace_QueryPlanNode_Flatten struct { + Flatten *Trace_QueryPlanNode_FlattenNode `protobuf:"bytes,4,opt,name=flatten,proto3,oneof"` +} + +func (*Trace_QueryPlanNode_Sequence) isTrace_QueryPlanNode_Node() {} + +func (*Trace_QueryPlanNode_Parallel) isTrace_QueryPlanNode_Node() {} + +func (*Trace_QueryPlanNode_Fetch) isTrace_QueryPlanNode_Node() {} + +func (*Trace_QueryPlanNode_Flatten) isTrace_QueryPlanNode_Node() {} + +type Trace_HTTP_Values struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Value []string `protobuf:"bytes,1,rep,name=value,proto3" json:"value,omitempty"` +} + +func (x *Trace_HTTP_Values) Reset() { + *x = Trace_HTTP_Values{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Trace_HTTP_Values) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Trace_HTTP_Values) ProtoMessage() {} + +func (x *Trace_HTTP_Values) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[21] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Trace_HTTP_Values.ProtoReflect.Descriptor instead. +func (*Trace_HTTP_Values) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{0, 3, 0} +} + +func (x *Trace_HTTP_Values) GetValue() []string { + if x != nil { + return x.Value + } + return nil +} + +// This represents a set of nodes to be executed sequentially by the Gateway executor +type Trace_QueryPlanNode_SequenceNode struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Nodes []*Trace_QueryPlanNode `protobuf:"bytes,1,rep,name=nodes,proto3" json:"nodes,omitempty"` +} + +func (x *Trace_QueryPlanNode_SequenceNode) Reset() { + *x = Trace_QueryPlanNode_SequenceNode{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[24] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Trace_QueryPlanNode_SequenceNode) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Trace_QueryPlanNode_SequenceNode) ProtoMessage() {} + +func (x *Trace_QueryPlanNode_SequenceNode) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[24] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Trace_QueryPlanNode_SequenceNode.ProtoReflect.Descriptor instead. +func (*Trace_QueryPlanNode_SequenceNode) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{0, 6, 0} +} + +func (x *Trace_QueryPlanNode_SequenceNode) GetNodes() []*Trace_QueryPlanNode { + if x != nil { + return x.Nodes + } + return nil +} + +// This represents a set of nodes to be executed in parallel by the Gateway executor +type Trace_QueryPlanNode_ParallelNode struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Nodes []*Trace_QueryPlanNode `protobuf:"bytes,1,rep,name=nodes,proto3" json:"nodes,omitempty"` +} + +func (x *Trace_QueryPlanNode_ParallelNode) Reset() { + *x = Trace_QueryPlanNode_ParallelNode{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[25] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Trace_QueryPlanNode_ParallelNode) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Trace_QueryPlanNode_ParallelNode) ProtoMessage() {} + +func (x *Trace_QueryPlanNode_ParallelNode) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[25] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Trace_QueryPlanNode_ParallelNode.ProtoReflect.Descriptor instead. +func (*Trace_QueryPlanNode_ParallelNode) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{0, 6, 1} +} + +func (x *Trace_QueryPlanNode_ParallelNode) GetNodes() []*Trace_QueryPlanNode { + if x != nil { + return x.Nodes + } + return nil +} + +// This represents a node to send an operation to an implementing service +type Trace_QueryPlanNode_FetchNode struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // XXX When we want to include more details about the sub-operation that was + // executed against this service, we should include that here in each fetch node. + // This might include an operation signature, requires directive, reference resolutions, etc. + ServiceName string `protobuf:"bytes,1,opt,name=service_name,json=serviceName,proto3" json:"service_name,omitempty"` + TraceParsingFailed bool `protobuf:"varint,2,opt,name=trace_parsing_failed,json=traceParsingFailed,proto3" json:"trace_parsing_failed,omitempty"` + // This Trace only contains start_time, end_time, duration_ns, and root; + // all timings were calculated **on the federated service**, and clock skew + // will be handled by the ingress server. + Trace *Trace `protobuf:"bytes,3,opt,name=trace,proto3" json:"trace,omitempty"` + // relative to the outer trace's start_time, in ns, measured in the gateway. + SentTimeOffset uint64 `protobuf:"varint,4,opt,name=sent_time_offset,json=sentTimeOffset,proto3" json:"sent_time_offset,omitempty"` + // Wallclock times measured in the gateway for when this operation was + // sent and received. + SentTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=sent_time,json=sentTime,proto3" json:"sent_time,omitempty"` + ReceivedTime *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=received_time,json=receivedTime,proto3" json:"received_time,omitempty"` +} + +func (x *Trace_QueryPlanNode_FetchNode) Reset() { + *x = Trace_QueryPlanNode_FetchNode{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[26] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Trace_QueryPlanNode_FetchNode) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Trace_QueryPlanNode_FetchNode) ProtoMessage() {} + +func (x *Trace_QueryPlanNode_FetchNode) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[26] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Trace_QueryPlanNode_FetchNode.ProtoReflect.Descriptor instead. +func (*Trace_QueryPlanNode_FetchNode) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{0, 6, 2} +} + +func (x *Trace_QueryPlanNode_FetchNode) GetServiceName() string { + if x != nil { + return x.ServiceName + } + return "" +} + +func (x *Trace_QueryPlanNode_FetchNode) GetTraceParsingFailed() bool { + if x != nil { + return x.TraceParsingFailed + } + return false +} + +func (x *Trace_QueryPlanNode_FetchNode) GetTrace() *Trace { + if x != nil { + return x.Trace + } + return nil +} + +func (x *Trace_QueryPlanNode_FetchNode) GetSentTimeOffset() uint64 { + if x != nil { + return x.SentTimeOffset + } + return 0 +} + +func (x *Trace_QueryPlanNode_FetchNode) GetSentTime() *timestamppb.Timestamp { + if x != nil { + return x.SentTime + } + return nil +} + +func (x *Trace_QueryPlanNode_FetchNode) GetReceivedTime() *timestamppb.Timestamp { + if x != nil { + return x.ReceivedTime + } + return nil +} + +// This node represents a way to reach into the response path and attach related entities. +// XXX Flatten is really not the right name and this node may be renamed in the query planner. +type Trace_QueryPlanNode_FlattenNode struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ResponsePath []*Trace_QueryPlanNode_ResponsePathElement `protobuf:"bytes,1,rep,name=response_path,json=responsePath,proto3" json:"response_path,omitempty"` + Node *Trace_QueryPlanNode `protobuf:"bytes,2,opt,name=node,proto3" json:"node,omitempty"` +} + +func (x *Trace_QueryPlanNode_FlattenNode) Reset() { + *x = Trace_QueryPlanNode_FlattenNode{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[27] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Trace_QueryPlanNode_FlattenNode) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Trace_QueryPlanNode_FlattenNode) ProtoMessage() {} + +func (x *Trace_QueryPlanNode_FlattenNode) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[27] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Trace_QueryPlanNode_FlattenNode.ProtoReflect.Descriptor instead. +func (*Trace_QueryPlanNode_FlattenNode) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{0, 6, 3} +} + +func (x *Trace_QueryPlanNode_FlattenNode) GetResponsePath() []*Trace_QueryPlanNode_ResponsePathElement { + if x != nil { + return x.ResponsePath + } + return nil +} + +func (x *Trace_QueryPlanNode_FlattenNode) GetNode() *Trace_QueryPlanNode { + if x != nil { + return x.Node + } + return nil +} + +type Trace_QueryPlanNode_ResponsePathElement struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Id: + // *Trace_QueryPlanNode_ResponsePathElement_FieldName + // *Trace_QueryPlanNode_ResponsePathElement_Index + Id isTrace_QueryPlanNode_ResponsePathElement_Id `protobuf_oneof:"id"` +} + +func (x *Trace_QueryPlanNode_ResponsePathElement) Reset() { + *x = Trace_QueryPlanNode_ResponsePathElement{} + if protoimpl.UnsafeEnabled { + mi := &file_apollo_trace_proto_msgTypes[28] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Trace_QueryPlanNode_ResponsePathElement) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Trace_QueryPlanNode_ResponsePathElement) ProtoMessage() {} + +func (x *Trace_QueryPlanNode_ResponsePathElement) ProtoReflect() protoreflect.Message { + mi := &file_apollo_trace_proto_msgTypes[28] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Trace_QueryPlanNode_ResponsePathElement.ProtoReflect.Descriptor instead. +func (*Trace_QueryPlanNode_ResponsePathElement) Descriptor() ([]byte, []int) { + return file_apollo_trace_proto_rawDescGZIP(), []int{0, 6, 4} +} + +func (m *Trace_QueryPlanNode_ResponsePathElement) GetId() isTrace_QueryPlanNode_ResponsePathElement_Id { + if m != nil { + return m.Id + } + return nil +} + +func (x *Trace_QueryPlanNode_ResponsePathElement) GetFieldName() string { + if x, ok := x.GetId().(*Trace_QueryPlanNode_ResponsePathElement_FieldName); ok { + return x.FieldName + } + return "" +} + +func (x *Trace_QueryPlanNode_ResponsePathElement) GetIndex() uint32 { + if x, ok := x.GetId().(*Trace_QueryPlanNode_ResponsePathElement_Index); ok { + return x.Index + } + return 0 +} + +type isTrace_QueryPlanNode_ResponsePathElement_Id interface { + isTrace_QueryPlanNode_ResponsePathElement_Id() +} + +type Trace_QueryPlanNode_ResponsePathElement_FieldName struct { + FieldName string `protobuf:"bytes,1,opt,name=field_name,json=fieldName,proto3,oneof"` +} + +type Trace_QueryPlanNode_ResponsePathElement_Index struct { + Index uint32 `protobuf:"varint,2,opt,name=index,proto3,oneof"` +} + +func (*Trace_QueryPlanNode_ResponsePathElement_FieldName) isTrace_QueryPlanNode_ResponsePathElement_Id() { +} + +func (*Trace_QueryPlanNode_ResponsePathElement_Index) isTrace_QueryPlanNode_ResponsePathElement_Id() { +} + +var File_apollo_trace_proto protoreflect.FileDescriptor + +var file_apollo_trace_proto_rawDesc = []byte{ + 0x0a, 0x12, 0x61, 0x70, 0x6f, 0x6c, 0x6c, 0x6f, 0x5f, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb6, 0x1a, 0x0a, 0x05, 0x54, 0x72, 0x61, 0x63, 0x65, 0x12, + 0x39, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, + 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x35, 0x0a, 0x08, 0x65, 0x6e, + 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x07, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, + 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x73, + 0x18, 0x0b, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x4e, 0x73, 0x12, 0x1f, 0x0a, 0x04, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0b, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x72, + 0x6f, 0x6f, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, + 0x18, 0x13, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, + 0x65, 0x12, 0x38, 0x0a, 0x17, 0x75, 0x6e, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x64, 0x4f, + 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x6f, 0x64, 0x79, 0x18, 0x1b, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x17, 0x75, 0x6e, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x64, 0x4f, 0x70, + 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x38, 0x0a, 0x17, 0x75, + 0x6e, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x1c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x17, 0x75, 0x6e, + 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x07, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x44, + 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x52, 0x07, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, + 0x1f, 0x0a, 0x0b, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, + 0x12, 0x25, 0x0a, 0x0e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x04, 0x68, 0x74, 0x74, 0x70, 0x18, + 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x48, 0x54, + 0x54, 0x50, 0x52, 0x04, 0x68, 0x74, 0x74, 0x70, 0x12, 0x35, 0x0a, 0x0c, 0x63, 0x61, 0x63, 0x68, + 0x65, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x12, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, + 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, + 0x63, 0x79, 0x52, 0x0b, 0x63, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, + 0x33, 0x0a, 0x0a, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x70, 0x6c, 0x61, 0x6e, 0x18, 0x1a, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x50, 0x6c, 0x61, 0x6e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x09, 0x71, 0x75, 0x65, 0x72, 0x79, + 0x50, 0x6c, 0x61, 0x6e, 0x12, 0x2f, 0x0a, 0x14, 0x66, 0x75, 0x6c, 0x6c, 0x5f, 0x71, 0x75, 0x65, + 0x72, 0x79, 0x5f, 0x63, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x68, 0x69, 0x74, 0x18, 0x14, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x11, 0x66, 0x75, 0x6c, 0x6c, 0x51, 0x75, 0x65, 0x72, 0x79, 0x43, 0x61, 0x63, + 0x68, 0x65, 0x48, 0x69, 0x74, 0x12, 0x2e, 0x0a, 0x13, 0x70, 0x65, 0x72, 0x73, 0x69, 0x73, 0x74, + 0x65, 0x64, 0x5f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x68, 0x69, 0x74, 0x18, 0x15, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x11, 0x70, 0x65, 0x72, 0x73, 0x69, 0x73, 0x74, 0x65, 0x64, 0x51, 0x75, 0x65, + 0x72, 0x79, 0x48, 0x69, 0x74, 0x12, 0x38, 0x0a, 0x18, 0x70, 0x65, 0x72, 0x73, 0x69, 0x73, 0x74, + 0x65, 0x64, 0x5f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, + 0x72, 0x18, 0x16, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, 0x70, 0x65, 0x72, 0x73, 0x69, 0x73, 0x74, + 0x65, 0x64, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, + 0x31, 0x0a, 0x14, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x65, 0x64, 0x5f, 0x6f, 0x70, + 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x18, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x72, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x65, 0x64, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x2f, 0x0a, 0x13, 0x66, 0x6f, 0x72, 0x62, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x5f, + 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x19, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x12, 0x66, 0x6f, 0x72, 0x62, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x34, 0x0a, 0x16, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x65, 0x78, 0x65, + 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x1f, 0x20, + 0x01, 0x28, 0x01, 0x52, 0x14, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, + 0x69, 0x6f, 0x6e, 0x57, 0x65, 0x69, 0x67, 0x68, 0x74, 0x1a, 0x8a, 0x01, 0x0a, 0x0b, 0x43, 0x61, + 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x2e, 0x0a, 0x05, 0x73, 0x63, 0x6f, + 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, + 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x53, 0x63, 0x6f, + 0x70, 0x65, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x12, 0x1c, 0x0a, 0x0a, 0x6d, 0x61, 0x78, + 0x5f, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x6d, + 0x61, 0x78, 0x41, 0x67, 0x65, 0x4e, 0x73, 0x22, 0x2d, 0x0a, 0x05, 0x53, 0x63, 0x6f, 0x70, 0x65, + 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0a, 0x0a, + 0x06, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x52, 0x49, + 0x56, 0x41, 0x54, 0x45, 0x10, 0x02, 0x1a, 0xbc, 0x01, 0x0a, 0x07, 0x44, 0x65, 0x74, 0x61, 0x69, + 0x6c, 0x73, 0x12, 0x48, 0x0a, 0x0e, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x5f, + 0x6a, 0x73, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x54, 0x72, 0x61, + 0x63, 0x65, 0x2e, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x2e, 0x56, 0x61, 0x72, 0x69, 0x61, + 0x62, 0x6c, 0x65, 0x73, 0x4a, 0x73, 0x6f, 0x6e, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0d, 0x76, + 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x4a, 0x73, 0x6f, 0x6e, 0x12, 0x25, 0x0a, 0x0e, + 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4e, + 0x61, 0x6d, 0x65, 0x1a, 0x40, 0x0a, 0x12, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x73, + 0x4a, 0x73, 0x6f, 0x6e, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x7b, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x18, + 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x2b, 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x54, 0x72, 0x61, + 0x63, 0x65, 0x2e, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x6c, 0x6f, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6e, 0x73, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x74, 0x69, 0x6d, 0x65, 0x4e, 0x73, 0x12, 0x12, + 0x0a, 0x04, 0x6a, 0x73, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6a, 0x73, + 0x6f, 0x6e, 0x1a, 0x8e, 0x05, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x12, 0x2a, 0x0a, 0x06, 0x6d, + 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x54, 0x72, + 0x61, 0x63, 0x65, 0x2e, 0x48, 0x54, 0x54, 0x50, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, + 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, + 0x61, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, + 0x48, 0x0a, 0x0f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, + 0x2e, 0x48, 0x54, 0x54, 0x50, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x65, 0x61, + 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0e, 0x72, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x4b, 0x0a, 0x10, 0x72, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x48, 0x54, 0x54, 0x50, + 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x63, 0x75, 0x72, + 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x12, + 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x09, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x1a, 0x1e, 0x0a, 0x06, 0x56, + 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x55, 0x0a, 0x13, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, + 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x6b, 0x65, 0x79, 0x12, 0x28, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x48, 0x54, 0x54, 0x50, + 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, + 0x38, 0x01, 0x1a, 0x56, 0x0a, 0x14, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x65, + 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x28, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x54, 0x72, + 0x61, 0x63, 0x65, 0x2e, 0x48, 0x54, 0x54, 0x50, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x52, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x77, 0x0a, 0x06, 0x4d, 0x65, + 0x74, 0x68, 0x6f, 0x64, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, + 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x53, 0x10, 0x01, 0x12, 0x07, + 0x0a, 0x03, 0x47, 0x45, 0x54, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x45, 0x41, 0x44, 0x10, + 0x03, 0x12, 0x08, 0x0a, 0x04, 0x50, 0x4f, 0x53, 0x54, 0x10, 0x04, 0x12, 0x07, 0x0a, 0x03, 0x50, + 0x55, 0x54, 0x10, 0x05, 0x12, 0x0a, 0x0a, 0x06, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x06, + 0x12, 0x09, 0x0a, 0x05, 0x54, 0x52, 0x41, 0x43, 0x45, 0x10, 0x07, 0x12, 0x0b, 0x0a, 0x07, 0x43, + 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x10, 0x08, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x41, 0x54, 0x43, + 0x48, 0x10, 0x09, 0x1a, 0x36, 0x0a, 0x08, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x6c, + 0x69, 0x6e, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x1a, 0xee, 0x02, 0x0a, 0x04, + 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x25, 0x0a, 0x0d, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0c, 0x72, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x05, 0x69, + 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x48, 0x00, 0x52, 0x05, 0x69, 0x6e, + 0x64, 0x65, 0x78, 0x12, 0x2e, 0x0a, 0x13, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x5f, + 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x11, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4e, + 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x61, 0x72, 0x65, 0x6e, + 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x61, + 0x72, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x35, 0x0a, 0x0c, 0x63, 0x61, 0x63, 0x68, + 0x65, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, + 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, + 0x63, 0x79, 0x52, 0x0b, 0x63, 0x61, 0x63, 0x68, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, + 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x19, + 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x07, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x05, 0x65, 0x72, 0x72, + 0x6f, 0x72, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, + 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x21, 0x0a, + 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x54, + 0x72, 0x61, 0x63, 0x65, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, + 0x42, 0x04, 0x0a, 0x02, 0x69, 0x64, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x1a, 0x8b, 0x07, 0x0a, + 0x0d, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x6c, 0x61, 0x6e, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x3f, + 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x21, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x6c, + 0x61, 0x6e, 0x4e, 0x6f, 0x64, 0x65, 0x2e, 0x53, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x4e, + 0x6f, 0x64, 0x65, 0x48, 0x00, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x12, + 0x3f, 0x0a, 0x08, 0x70, 0x61, 0x72, 0x61, 0x6c, 0x6c, 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x21, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, + 0x6c, 0x61, 0x6e, 0x4e, 0x6f, 0x64, 0x65, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6c, 0x6c, 0x65, 0x6c, + 0x4e, 0x6f, 0x64, 0x65, 0x48, 0x00, 0x52, 0x08, 0x70, 0x61, 0x72, 0x61, 0x6c, 0x6c, 0x65, 0x6c, + 0x12, 0x36, 0x0a, 0x05, 0x66, 0x65, 0x74, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1e, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x6c, 0x61, + 0x6e, 0x4e, 0x6f, 0x64, 0x65, 0x2e, 0x46, 0x65, 0x74, 0x63, 0x68, 0x4e, 0x6f, 0x64, 0x65, 0x48, + 0x00, 0x52, 0x05, 0x66, 0x65, 0x74, 0x63, 0x68, 0x12, 0x3c, 0x0a, 0x07, 0x66, 0x6c, 0x61, 0x74, + 0x74, 0x65, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x54, 0x72, 0x61, 0x63, + 0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x6c, 0x61, 0x6e, 0x4e, 0x6f, 0x64, 0x65, 0x2e, + 0x46, 0x6c, 0x61, 0x74, 0x74, 0x65, 0x6e, 0x4e, 0x6f, 0x64, 0x65, 0x48, 0x00, 0x52, 0x07, 0x66, + 0x6c, 0x61, 0x74, 0x74, 0x65, 0x6e, 0x1a, 0x3a, 0x0a, 0x0c, 0x53, 0x65, 0x71, 0x75, 0x65, 0x6e, + 0x63, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x2a, 0x0a, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x51, 0x75, + 0x65, 0x72, 0x79, 0x50, 0x6c, 0x61, 0x6e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x05, 0x6e, 0x6f, 0x64, + 0x65, 0x73, 0x1a, 0x3a, 0x0a, 0x0c, 0x50, 0x61, 0x72, 0x61, 0x6c, 0x6c, 0x65, 0x6c, 0x4e, 0x6f, + 0x64, 0x65, 0x12, 0x2a, 0x0a, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x14, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, + 0x6c, 0x61, 0x6e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x1a, 0xa2, + 0x02, 0x0a, 0x09, 0x46, 0x65, 0x74, 0x63, 0x68, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x21, 0x0a, 0x0c, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, + 0x30, 0x0a, 0x14, 0x74, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x70, 0x61, 0x72, 0x73, 0x69, 0x6e, 0x67, + 0x5f, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x74, + 0x72, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72, 0x73, 0x69, 0x6e, 0x67, 0x46, 0x61, 0x69, 0x6c, 0x65, + 0x64, 0x12, 0x1c, 0x0a, 0x05, 0x74, 0x72, 0x61, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x06, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x52, 0x05, 0x74, 0x72, 0x61, 0x63, 0x65, 0x12, + 0x28, 0x0a, 0x10, 0x73, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6f, 0x66, 0x66, + 0x73, 0x65, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0e, 0x73, 0x65, 0x6e, 0x74, 0x54, + 0x69, 0x6d, 0x65, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x37, 0x0a, 0x09, 0x73, 0x65, 0x6e, + 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x08, 0x73, 0x65, 0x6e, 0x74, 0x54, 0x69, + 0x6d, 0x65, 0x12, 0x3f, 0x0a, 0x0d, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x5f, 0x74, + 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0c, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x54, + 0x69, 0x6d, 0x65, 0x1a, 0x86, 0x01, 0x0a, 0x0b, 0x46, 0x6c, 0x61, 0x74, 0x74, 0x65, 0x6e, 0x4e, + 0x6f, 0x64, 0x65, 0x12, 0x4d, 0x0a, 0x0d, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, + 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x54, 0x72, 0x61, + 0x63, 0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x6c, 0x61, 0x6e, 0x4e, 0x6f, 0x64, 0x65, + 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x50, 0x61, 0x74, 0x68, 0x45, 0x6c, 0x65, + 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x0c, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x50, 0x61, + 0x74, 0x68, 0x12, 0x28, 0x0a, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x14, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x6c, + 0x61, 0x6e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x1a, 0x54, 0x0a, 0x13, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x50, 0x61, 0x74, 0x68, 0x45, 0x6c, 0x65, 0x6d, + 0x65, 0x6e, 0x74, 0x12, 0x1f, 0x0a, 0x0a, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x09, 0x66, 0x69, 0x65, 0x6c, 0x64, + 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0d, 0x48, 0x00, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x42, 0x04, 0x0a, 0x02, + 0x69, 0x64, 0x42, 0x06, 0x0a, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, + 0x4a, 0x04, 0x08, 0x02, 0x10, 0x03, 0x4a, 0x04, 0x08, 0x09, 0x10, 0x0a, 0x4a, 0x04, 0x08, 0x0c, + 0x10, 0x0d, 0x4a, 0x04, 0x08, 0x0d, 0x10, 0x0e, 0x4a, 0x04, 0x08, 0x17, 0x10, 0x18, 0x22, 0x8c, + 0x02, 0x0a, 0x0c, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, + 0x1b, 0x0a, 0x09, 0x67, 0x72, 0x61, 0x70, 0x68, 0x5f, 0x72, 0x65, 0x66, 0x18, 0x0c, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x08, 0x67, 0x72, 0x61, 0x70, 0x68, 0x52, 0x65, 0x66, 0x12, 0x1a, 0x0a, 0x08, + 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x61, 0x67, 0x65, 0x6e, + 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0c, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x27, 0x0a, + 0x0f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x27, 0x0a, 0x0f, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, + 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, + 0x14, 0x0a, 0x05, 0x75, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x75, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x30, 0x0a, 0x14, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x61, + 0x62, 0x6c, 0x65, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x0b, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x12, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x53, + 0x63, 0x68, 0x65, 0x6d, 0x61, 0x49, 0x64, 0x4a, 0x04, 0x08, 0x03, 0x10, 0x04, 0x22, 0xf9, 0x01, + 0x0a, 0x0e, 0x50, 0x61, 0x74, 0x68, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x74, 0x73, + 0x12, 0x39, 0x0a, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x50, 0x61, 0x74, 0x68, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x53, 0x74, + 0x61, 0x74, 0x73, 0x2e, 0x43, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x52, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x65, + 0x72, 0x72, 0x6f, 0x72, 0x73, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x0b, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x3b, + 0x0a, 0x1a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x5f, + 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x17, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x57, 0x69, 0x74, 0x68, + 0x45, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x1a, 0x4c, 0x0a, 0x0d, 0x43, + 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, + 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x25, + 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, + 0x50, 0x61, 0x74, 0x68, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xdf, 0x05, 0x0a, 0x11, 0x51, 0x75, + 0x65, 0x72, 0x79, 0x4c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, + 0x23, 0x0a, 0x0d, 0x6c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x18, 0x0d, 0x20, 0x03, 0x28, 0x12, 0x52, 0x0c, 0x6c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x43, + 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0c, 0x72, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x61, 0x63, + 0x68, 0x65, 0x5f, 0x68, 0x69, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x63, + 0x61, 0x63, 0x68, 0x65, 0x48, 0x69, 0x74, 0x73, 0x12, 0x30, 0x0a, 0x14, 0x70, 0x65, 0x72, 0x73, + 0x69, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x68, 0x69, 0x74, 0x73, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x12, 0x70, 0x65, 0x72, 0x73, 0x69, 0x73, 0x74, 0x65, + 0x64, 0x51, 0x75, 0x65, 0x72, 0x79, 0x48, 0x69, 0x74, 0x73, 0x12, 0x34, 0x0a, 0x16, 0x70, 0x65, + 0x72, 0x73, 0x69, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x6d, 0x69, + 0x73, 0x73, 0x65, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x14, 0x70, 0x65, 0x72, 0x73, + 0x69, 0x73, 0x74, 0x65, 0x64, 0x51, 0x75, 0x65, 0x72, 0x79, 0x4d, 0x69, 0x73, 0x73, 0x65, 0x73, + 0x12, 0x2e, 0x0a, 0x13, 0x63, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x6c, 0x61, 0x74, 0x65, 0x6e, 0x63, + 0x79, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x12, 0x52, 0x11, 0x63, + 0x61, 0x63, 0x68, 0x65, 0x4c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x43, 0x6f, 0x75, 0x6e, 0x74, + 0x12, 0x39, 0x0a, 0x10, 0x72, 0x6f, 0x6f, 0x74, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x73, + 0x74, 0x61, 0x74, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x50, 0x61, 0x74, + 0x68, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x0e, 0x72, 0x6f, 0x6f, + 0x74, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x3b, 0x0a, 0x1a, 0x72, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x5f, 0x65, 0x72, 0x72, + 0x6f, 0x72, 0x73, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x17, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x57, 0x69, 0x74, 0x68, 0x45, 0x72, 0x72, + 0x6f, 0x72, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x33, 0x0a, 0x16, 0x70, 0x75, 0x62, 0x6c, + 0x69, 0x63, 0x5f, 0x63, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x74, 0x74, 0x6c, 0x5f, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x12, 0x52, 0x13, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, + 0x43, 0x61, 0x63, 0x68, 0x65, 0x54, 0x74, 0x6c, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x35, 0x0a, + 0x17, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x5f, 0x63, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x74, + 0x74, 0x6c, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x10, 0x20, 0x03, 0x28, 0x12, 0x52, 0x14, + 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x54, 0x74, 0x6c, 0x43, + 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x3c, 0x0a, 0x1a, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, + 0x65, 0x64, 0x5f, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x04, 0x52, 0x18, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x65, 0x72, 0x65, 0x64, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x75, + 0x6e, 0x74, 0x12, 0x3a, 0x0a, 0x19, 0x66, 0x6f, 0x72, 0x62, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x5f, + 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, + 0x0c, 0x20, 0x01, 0x28, 0x04, 0x52, 0x17, 0x66, 0x6f, 0x72, 0x62, 0x69, 0x64, 0x64, 0x65, 0x6e, + 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x53, + 0x0a, 0x26, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x6f, + 0x75, 0x74, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x69, 0x6e, 0x73, 0x74, 0x72, 0x75, 0x6d, + 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x11, 0x20, 0x01, 0x28, 0x04, 0x52, 0x23, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x57, 0x69, 0x74, 0x68, 0x6f, 0x75, 0x74, 0x46, + 0x69, 0x65, 0x6c, 0x64, 0x49, 0x6e, 0x73, 0x74, 0x72, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x4a, 0x04, 0x08, 0x06, 0x10, 0x07, 0x4a, + 0x04, 0x08, 0x09, 0x10, 0x0a, 0x4a, 0x04, 0x08, 0x0a, 0x10, 0x0b, 0x22, 0x5c, 0x0a, 0x0c, 0x53, + 0x74, 0x61, 0x74, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x63, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0a, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x25, 0x0a, 0x0e, + 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x22, 0x8e, 0x01, 0x0a, 0x1f, 0x43, 0x6f, + 0x6e, 0x74, 0x65, 0x78, 0x74, 0x75, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x4c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x42, 0x0a, + 0x13, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x6c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x5f, 0x73, + 0x74, 0x61, 0x74, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x51, 0x75, 0x65, + 0x72, 0x79, 0x4c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x11, + 0x71, 0x75, 0x65, 0x72, 0x79, 0x4c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x53, 0x74, 0x61, 0x74, + 0x73, 0x12, 0x27, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, + 0x74, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0xdc, 0x01, 0x0a, 0x17, 0x43, + 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x75, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x54, 0x79, 0x70, + 0x65, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x27, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x73, 0x43, + 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, + 0x4d, 0x0a, 0x0d, 0x70, 0x65, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x73, 0x74, 0x61, 0x74, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, + 0x75, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x54, 0x79, 0x70, 0x65, 0x53, 0x74, 0x61, 0x74, 0x73, + 0x2e, 0x50, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x53, 0x74, 0x61, 0x74, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x52, 0x0b, 0x70, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x53, 0x74, 0x61, 0x74, 0x1a, 0x49, + 0x0a, 0x10, 0x50, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x53, 0x74, 0x61, 0x74, 0x45, 0x6e, 0x74, + 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x53, 0x74, 0x61, 0x74, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xbf, 0x02, 0x0a, 0x09, 0x46, 0x69, + 0x65, 0x6c, 0x64, 0x53, 0x74, 0x61, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x74, 0x75, 0x72, + 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, + 0x74, 0x75, 0x72, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x65, 0x72, 0x72, 0x6f, + 0x72, 0x73, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, + 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x38, 0x0a, 0x18, 0x6f, + 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x5f, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, + 0x6e, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x16, 0x6f, + 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, + 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x3a, 0x0a, 0x19, 0x65, 0x73, 0x74, 0x69, 0x6d, 0x61, 0x74, + 0x65, 0x64, 0x5f, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x04, 0x52, 0x17, 0x65, 0x73, 0x74, 0x69, 0x6d, 0x61, + 0x74, 0x65, 0x64, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x75, 0x6e, + 0x74, 0x12, 0x3b, 0x0a, 0x1a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x5f, 0x77, 0x69, + 0x74, 0x68, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x17, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x57, + 0x69, 0x74, 0x68, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x23, + 0x0a, 0x0d, 0x6c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, + 0x09, 0x20, 0x03, 0x28, 0x12, 0x52, 0x0c, 0x6c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x43, 0x6f, + 0x75, 0x6e, 0x74, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x4a, 0x04, 0x08, 0x02, 0x10, 0x03, 0x4a, + 0x04, 0x08, 0x07, 0x10, 0x08, 0x4a, 0x04, 0x08, 0x08, 0x10, 0x09, 0x22, 0xa6, 0x01, 0x0a, 0x08, + 0x54, 0x79, 0x70, 0x65, 0x53, 0x74, 0x61, 0x74, 0x12, 0x41, 0x0a, 0x0e, 0x70, 0x65, 0x72, 0x5f, + 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x1b, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x53, 0x74, 0x61, 0x74, 0x2e, 0x50, 0x65, 0x72, 0x46, + 0x69, 0x65, 0x6c, 0x64, 0x53, 0x74, 0x61, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0c, 0x70, + 0x65, 0x72, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x53, 0x74, 0x61, 0x74, 0x1a, 0x4b, 0x0a, 0x11, 0x50, + 0x65, 0x72, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x53, 0x74, 0x61, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, + 0x65, 0x79, 0x12, 0x20, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0a, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x53, 0x74, 0x61, 0x74, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x4a, 0x04, + 0x08, 0x02, 0x10, 0x03, 0x22, 0x5d, 0x0a, 0x17, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, + 0x65, 0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x46, 0x6f, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, + 0x1f, 0x0a, 0x0b, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x73, + 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x73, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x73, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, + 0x61, 0x63, 0x65, 0x22, 0xaa, 0x02, 0x0a, 0x06, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x25, + 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, + 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x06, 0x68, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x45, 0x0a, 0x10, 0x74, 0x72, 0x61, 0x63, 0x65, 0x73, 0x5f, + 0x70, 0x65, 0x72, 0x5f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x1b, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x73, 0x50, + 0x65, 0x72, 0x51, 0x75, 0x65, 0x72, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0e, 0x74, 0x72, + 0x61, 0x63, 0x65, 0x73, 0x50, 0x65, 0x72, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x35, 0x0a, 0x08, + 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x07, 0x65, 0x6e, 0x64, 0x54, + 0x69, 0x6d, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0e, 0x6f, 0x70, + 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x1a, 0x52, 0x0a, 0x13, + 0x54, 0x72, 0x61, 0x63, 0x65, 0x73, 0x50, 0x65, 0x72, 0x51, 0x75, 0x65, 0x72, 0x79, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x25, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x73, 0x41, 0x6e, 0x64, + 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, + 0x22, 0x98, 0x02, 0x0a, 0x13, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x75, 0x61, 0x6c, 0x69, + 0x7a, 0x65, 0x64, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x27, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, + 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x53, 0x74, 0x61, 0x74, + 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, + 0x74, 0x12, 0x42, 0x0a, 0x13, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x6c, 0x61, 0x74, 0x65, 0x6e, + 0x63, 0x79, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, + 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x4c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x53, 0x74, 0x61, + 0x74, 0x73, 0x52, 0x11, 0x71, 0x75, 0x65, 0x72, 0x79, 0x4c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, + 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x49, 0x0a, 0x0d, 0x70, 0x65, 0x72, 0x5f, 0x74, 0x79, 0x70, + 0x65, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x43, + 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x75, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x53, 0x74, 0x61, + 0x74, 0x73, 0x2e, 0x50, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x53, 0x74, 0x61, 0x74, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x52, 0x0b, 0x70, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x53, 0x74, 0x61, 0x74, + 0x1a, 0x49, 0x0a, 0x10, 0x50, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x53, 0x74, 0x61, 0x74, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x53, 0x74, 0x61, 0x74, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x99, 0x03, 0x0a, 0x0e, + 0x54, 0x72, 0x61, 0x63, 0x65, 0x73, 0x41, 0x6e, 0x64, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x1c, + 0x0a, 0x05, 0x74, 0x72, 0x61, 0x63, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x06, 0x2e, + 0x54, 0x72, 0x61, 0x63, 0x65, 0x52, 0x05, 0x74, 0x72, 0x61, 0x63, 0x65, 0x12, 0x42, 0x0a, 0x12, + 0x73, 0x74, 0x61, 0x74, 0x73, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, + 0x78, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, + 0x78, 0x74, 0x75, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x10, + 0x73, 0x74, 0x61, 0x74, 0x73, 0x57, 0x69, 0x74, 0x68, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, + 0x12, 0x66, 0x0a, 0x19, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x64, 0x5f, 0x66, + 0x69, 0x65, 0x6c, 0x64, 0x73, 0x5f, 0x62, 0x79, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x73, 0x41, 0x6e, 0x64, 0x53, + 0x74, 0x61, 0x74, 0x73, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x64, 0x46, + 0x69, 0x65, 0x6c, 0x64, 0x73, 0x42, 0x79, 0x54, 0x79, 0x70, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x52, 0x16, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x64, 0x46, 0x69, 0x65, 0x6c, + 0x64, 0x73, 0x42, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x58, 0x0a, 0x25, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x74, 0x72, 0x61, 0x63, 0x65, 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x74, + 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x74, 0x6f, 0x5f, 0x73, 0x74, 0x61, 0x74, + 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x06, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x52, + 0x21, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x54, 0x72, 0x61, 0x63, 0x65, 0x73, 0x43, + 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x54, 0x6f, 0x53, 0x74, 0x61, + 0x74, 0x73, 0x1a, 0x63, 0x0a, 0x1b, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x64, + 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x42, 0x79, 0x54, 0x79, 0x70, 0x65, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x6b, 0x65, 0x79, 0x12, 0x2e, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x64, 0x46, + 0x69, 0x65, 0x6c, 0x64, 0x73, 0x46, 0x6f, 0x72, 0x54, 0x79, 0x70, 0x65, 0x52, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x16, 0x5a, 0x14, 0x2e, 0x2f, 0x61, 0x70, 0x6f, + 0x6c, 0x6c, 0x6f, 0x74, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x5f, 0x66, 0x74, 0x76, 0x31, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_apollo_trace_proto_rawDescOnce sync.Once + file_apollo_trace_proto_rawDescData = file_apollo_trace_proto_rawDesc +) + +func file_apollo_trace_proto_rawDescGZIP() []byte { + file_apollo_trace_proto_rawDescOnce.Do(func() { + file_apollo_trace_proto_rawDescData = protoimpl.X.CompressGZIP(file_apollo_trace_proto_rawDescData) + }) + return file_apollo_trace_proto_rawDescData +} + +var file_apollo_trace_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_apollo_trace_proto_msgTypes = make([]protoimpl.MessageInfo, 35) +var file_apollo_trace_proto_goTypes = []interface{}{ + (Trace_CachePolicy_Scope)(0), // 0: Trace.CachePolicy.Scope + (Trace_HTTP_Method)(0), // 1: Trace.HTTP.Method + (*Trace)(nil), // 2: Trace + (*ReportHeader)(nil), // 3: ReportHeader + (*PathErrorStats)(nil), // 4: PathErrorStats + (*QueryLatencyStats)(nil), // 5: QueryLatencyStats + (*StatsContext)(nil), // 6: StatsContext + (*ContextualizedQueryLatencyStats)(nil), // 7: ContextualizedQueryLatencyStats + (*ContextualizedTypeStats)(nil), // 8: ContextualizedTypeStats + (*FieldStat)(nil), // 9: FieldStat + (*TypeStat)(nil), // 10: TypeStat + (*ReferencedFieldsForType)(nil), // 11: ReferencedFieldsForType + (*Report)(nil), // 12: Report + (*ContextualizedStats)(nil), // 13: ContextualizedStats + (*TracesAndStats)(nil), // 14: TracesAndStats + (*Trace_CachePolicy)(nil), // 15: Trace.CachePolicy + (*Trace_Details)(nil), // 16: Trace.Details + (*Trace_Error)(nil), // 17: Trace.Error + (*Trace_HTTP)(nil), // 18: Trace.HTTP + (*Trace_Location)(nil), // 19: Trace.Location + (*Trace_Node)(nil), // 20: Trace.Node + (*Trace_QueryPlanNode)(nil), // 21: Trace.QueryPlanNode + nil, // 22: Trace.Details.VariablesJsonEntry + (*Trace_HTTP_Values)(nil), // 23: Trace.HTTP.Values + nil, // 24: Trace.HTTP.RequestHeadersEntry + nil, // 25: Trace.HTTP.ResponseHeadersEntry + (*Trace_QueryPlanNode_SequenceNode)(nil), // 26: Trace.QueryPlanNode.SequenceNode + (*Trace_QueryPlanNode_ParallelNode)(nil), // 27: Trace.QueryPlanNode.ParallelNode + (*Trace_QueryPlanNode_FetchNode)(nil), // 28: Trace.QueryPlanNode.FetchNode + (*Trace_QueryPlanNode_FlattenNode)(nil), // 29: Trace.QueryPlanNode.FlattenNode + (*Trace_QueryPlanNode_ResponsePathElement)(nil), // 30: Trace.QueryPlanNode.ResponsePathElement + nil, // 31: PathErrorStats.ChildrenEntry + nil, // 32: ContextualizedTypeStats.PerTypeStatEntry + nil, // 33: TypeStat.PerFieldStatEntry + nil, // 34: Report.TracesPerQueryEntry + nil, // 35: ContextualizedStats.PerTypeStatEntry + nil, // 36: TracesAndStats.ReferencedFieldsByTypeEntry + (*timestamppb.Timestamp)(nil), // 37: google.protobuf.Timestamp +} +var file_apollo_trace_proto_depIdxs = []int32{ + 37, // 0: Trace.start_time:type_name -> google.protobuf.Timestamp + 37, // 1: Trace.end_time:type_name -> google.protobuf.Timestamp + 20, // 2: Trace.root:type_name -> Trace.Node + 16, // 3: Trace.details:type_name -> Trace.Details + 18, // 4: Trace.http:type_name -> Trace.HTTP + 15, // 5: Trace.cache_policy:type_name -> Trace.CachePolicy + 21, // 6: Trace.query_plan:type_name -> Trace.QueryPlanNode + 31, // 7: PathErrorStats.children:type_name -> PathErrorStats.ChildrenEntry + 4, // 8: QueryLatencyStats.root_error_stats:type_name -> PathErrorStats + 5, // 9: ContextualizedQueryLatencyStats.query_latency_stats:type_name -> QueryLatencyStats + 6, // 10: ContextualizedQueryLatencyStats.context:type_name -> StatsContext + 6, // 11: ContextualizedTypeStats.context:type_name -> StatsContext + 32, // 12: ContextualizedTypeStats.per_type_stat:type_name -> ContextualizedTypeStats.PerTypeStatEntry + 33, // 13: TypeStat.per_field_stat:type_name -> TypeStat.PerFieldStatEntry + 3, // 14: Report.header:type_name -> ReportHeader + 34, // 15: Report.traces_per_query:type_name -> Report.TracesPerQueryEntry + 37, // 16: Report.end_time:type_name -> google.protobuf.Timestamp + 6, // 17: ContextualizedStats.context:type_name -> StatsContext + 5, // 18: ContextualizedStats.query_latency_stats:type_name -> QueryLatencyStats + 35, // 19: ContextualizedStats.per_type_stat:type_name -> ContextualizedStats.PerTypeStatEntry + 2, // 20: TracesAndStats.trace:type_name -> Trace + 13, // 21: TracesAndStats.stats_with_context:type_name -> ContextualizedStats + 36, // 22: TracesAndStats.referenced_fields_by_type:type_name -> TracesAndStats.ReferencedFieldsByTypeEntry + 2, // 23: TracesAndStats.internal_traces_contributing_to_stats:type_name -> Trace + 0, // 24: Trace.CachePolicy.scope:type_name -> Trace.CachePolicy.Scope + 22, // 25: Trace.Details.variables_json:type_name -> Trace.Details.VariablesJsonEntry + 19, // 26: Trace.Error.location:type_name -> Trace.Location + 1, // 27: Trace.HTTP.method:type_name -> Trace.HTTP.Method + 24, // 28: Trace.HTTP.request_headers:type_name -> Trace.HTTP.RequestHeadersEntry + 25, // 29: Trace.HTTP.response_headers:type_name -> Trace.HTTP.ResponseHeadersEntry + 15, // 30: Trace.Node.cache_policy:type_name -> Trace.CachePolicy + 17, // 31: Trace.Node.error:type_name -> Trace.Error + 20, // 32: Trace.Node.child:type_name -> Trace.Node + 26, // 33: Trace.QueryPlanNode.sequence:type_name -> Trace.QueryPlanNode.SequenceNode + 27, // 34: Trace.QueryPlanNode.parallel:type_name -> Trace.QueryPlanNode.ParallelNode + 28, // 35: Trace.QueryPlanNode.fetch:type_name -> Trace.QueryPlanNode.FetchNode + 29, // 36: Trace.QueryPlanNode.flatten:type_name -> Trace.QueryPlanNode.FlattenNode + 23, // 37: Trace.HTTP.RequestHeadersEntry.value:type_name -> Trace.HTTP.Values + 23, // 38: Trace.HTTP.ResponseHeadersEntry.value:type_name -> Trace.HTTP.Values + 21, // 39: Trace.QueryPlanNode.SequenceNode.nodes:type_name -> Trace.QueryPlanNode + 21, // 40: Trace.QueryPlanNode.ParallelNode.nodes:type_name -> Trace.QueryPlanNode + 2, // 41: Trace.QueryPlanNode.FetchNode.trace:type_name -> Trace + 37, // 42: Trace.QueryPlanNode.FetchNode.sent_time:type_name -> google.protobuf.Timestamp + 37, // 43: Trace.QueryPlanNode.FetchNode.received_time:type_name -> google.protobuf.Timestamp + 30, // 44: Trace.QueryPlanNode.FlattenNode.response_path:type_name -> Trace.QueryPlanNode.ResponsePathElement + 21, // 45: Trace.QueryPlanNode.FlattenNode.node:type_name -> Trace.QueryPlanNode + 4, // 46: PathErrorStats.ChildrenEntry.value:type_name -> PathErrorStats + 10, // 47: ContextualizedTypeStats.PerTypeStatEntry.value:type_name -> TypeStat + 9, // 48: TypeStat.PerFieldStatEntry.value:type_name -> FieldStat + 14, // 49: Report.TracesPerQueryEntry.value:type_name -> TracesAndStats + 10, // 50: ContextualizedStats.PerTypeStatEntry.value:type_name -> TypeStat + 11, // 51: TracesAndStats.ReferencedFieldsByTypeEntry.value:type_name -> ReferencedFieldsForType + 52, // [52:52] is the sub-list for method output_type + 52, // [52:52] is the sub-list for method input_type + 52, // [52:52] is the sub-list for extension type_name + 52, // [52:52] is the sub-list for extension extendee + 0, // [0:52] is the sub-list for field type_name +} + +func init() { file_apollo_trace_proto_init() } +func file_apollo_trace_proto_init() { + if File_apollo_trace_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_apollo_trace_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Trace); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReportHeader); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PathErrorStats); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*QueryLatencyStats); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StatsContext); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ContextualizedQueryLatencyStats); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ContextualizedTypeStats); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FieldStat); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TypeStat); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReferencedFieldsForType); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Report); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ContextualizedStats); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TracesAndStats); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Trace_CachePolicy); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Trace_Details); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Trace_Error); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Trace_HTTP); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Trace_Location); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Trace_Node); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Trace_QueryPlanNode); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Trace_HTTP_Values); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Trace_QueryPlanNode_SequenceNode); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Trace_QueryPlanNode_ParallelNode); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Trace_QueryPlanNode_FetchNode); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Trace_QueryPlanNode_FlattenNode); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apollo_trace_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Trace_QueryPlanNode_ResponsePathElement); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_apollo_trace_proto_msgTypes[18].OneofWrappers = []interface{}{ + (*Trace_Node_ResponseName)(nil), + (*Trace_Node_Index)(nil), + } + file_apollo_trace_proto_msgTypes[19].OneofWrappers = []interface{}{ + (*Trace_QueryPlanNode_Sequence)(nil), + (*Trace_QueryPlanNode_Parallel)(nil), + (*Trace_QueryPlanNode_Fetch)(nil), + (*Trace_QueryPlanNode_Flatten)(nil), + } + file_apollo_trace_proto_msgTypes[28].OneofWrappers = []interface{}{ + (*Trace_QueryPlanNode_ResponsePathElement_FieldName)(nil), + (*Trace_QueryPlanNode_ResponsePathElement_Index)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_apollo_trace_proto_rawDesc, + NumEnums: 2, + NumMessages: 35, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_apollo_trace_proto_goTypes, + DependencyIndexes: file_apollo_trace_proto_depIdxs, + EnumInfos: file_apollo_trace_proto_enumTypes, + MessageInfos: file_apollo_trace_proto_msgTypes, + }.Build() + File_apollo_trace_proto = out.File + file_apollo_trace_proto_rawDesc = nil + file_apollo_trace_proto_goTypes = nil + file_apollo_trace_proto_depIdxs = nil +} diff --git a/graphql/handler/apollofederatedtracingv1/generated/apollo_trace.proto b/graphql/handler/apollofederatedtracingv1/generated/apollo_trace.proto new file mode 100644 index 0000000..a494538 --- /dev/null +++ b/graphql/handler/apollofederatedtracingv1/generated/apollo_trace.proto @@ -0,0 +1,431 @@ +syntax = "proto3"; +option go_package = "./generated"; + +import "google/protobuf/timestamp.proto"; + +message Trace { + message CachePolicy { + enum Scope { + UNKNOWN = 0; + PUBLIC = 1; + PRIVATE = 2; + } + + Scope scope = 1; + int64 max_age_ns = 2; // use 0 for absent, -1 for 0 + } + + message Details { + // The variables associated with this query (unless the reporting agent is + // configured to keep them all private). Values are JSON: ie, strings are + // enclosed in double quotes, etc. The value of a private variable is + // the empty string. + map variables_json = 4; + + + // This is deprecated and only used for legacy applications + // don't include this in traces inside a FullTracesReport; the operation + // name for these traces comes from the key of the traces_per_query map. + string operation_name = 3; + } + + message Error { + string message = 1; // required + repeated Location location = 2; + uint64 time_ns = 3; + string json = 4; + } + + message HTTP { + message Values { + repeated string value = 1; + } + + enum Method { + UNKNOWN = 0; + OPTIONS = 1; + GET = 2; + HEAD = 3; + POST = 4; + PUT = 5; + DELETE = 6; + TRACE = 7; + CONNECT = 8; + PATCH = 9; + } + Method method = 1; + string host = 2; + string path = 3; + + // Should exclude manual blacklist ("Auth" by default) + map request_headers = 4; + map response_headers = 5; + + uint32 status_code = 6; + + bool secure = 8; // TLS was used + string protocol = 9; // by convention "HTTP/1.0", "HTTP/1.1", "HTTP/2" or "h2" + } + + message Location { + uint32 line = 1; + uint32 column = 2; + } + + // We store information on each resolver execution as a Node on a tree. + // The structure of the tree corresponds to the structure of the GraphQL + // response; it does not indicate the order in which resolvers were + // invoked. Note that nodes representing indexes (and the root node) + // don't contain all Node fields (eg types and times). + message Node { + // The name of the field (for Nodes representing a resolver call) or the + // index in a list (for intermediate Nodes representing elements of a list). + // field_name is the name of the field as it appears in the GraphQL + // response: ie, it may be an alias. (In that case, the original_field_name + // field holds the actual field name from the schema.) In any context where + // we're building up a path, we use the response_name rather than the + // original_field_name. + oneof id { + string response_name = 1; + uint32 index = 2; + } + + string original_field_name = 14; + + // The field's return type; e.g. "String!" for User.email:String! + string type = 3; + + // The field's parent type; e.g. "User" for User.email:String! + string parent_type = 13; + + CachePolicy cache_policy = 5; + + // relative to the trace's start_time, in ns + uint64 start_time = 8; + // relative to the trace's start_time, in ns + uint64 end_time = 9; + + repeated Error error = 11; + repeated Node child = 12; + + reserved 4; + } + + // represents a node in the query plan, under which there is a trace tree for that service fetch. + // In particular, each fetch node represents a call to an implementing service, and calls to implementing + // services may not be unique. See https://github.com/apollographql/apollo-server/blob/main/packages/apollo-gateway/src/QueryPlan.ts + // for more information and details. + message QueryPlanNode { + // This represents a set of nodes to be executed sequentially by the Gateway executor + message SequenceNode { + repeated QueryPlanNode nodes = 1; + } + // This represents a set of nodes to be executed in parallel by the Gateway executor + message ParallelNode { + repeated QueryPlanNode nodes = 1; + } + // This represents a node to send an operation to an implementing service + message FetchNode { + // XXX When we want to include more details about the sub-operation that was + // executed against this service, we should include that here in each fetch node. + // This might include an operation signature, requires directive, reference resolutions, etc. + string service_name = 1; + + bool trace_parsing_failed = 2; + + // This Trace only contains start_time, end_time, duration_ns, and root; + // all timings were calculated **on the federated service**, and clock skew + // will be handled by the ingress server. + Trace trace = 3; + + // relative to the outer trace's start_time, in ns, measured in the gateway. + uint64 sent_time_offset = 4; + + // Wallclock times measured in the gateway for when this operation was + // sent and received. + google.protobuf.Timestamp sent_time = 5; + google.protobuf.Timestamp received_time = 6; + } + + // This node represents a way to reach into the response path and attach related entities. + // XXX Flatten is really not the right name and this node may be renamed in the query planner. + message FlattenNode { + repeated ResponsePathElement response_path = 1; + QueryPlanNode node = 2; + } + message ResponsePathElement { + oneof id { + string field_name = 1; + uint32 index = 2; + } + } + oneof node { + SequenceNode sequence = 1; + ParallelNode parallel = 2; + FetchNode fetch = 3; + FlattenNode flatten = 4; + } + } + + // Wallclock time when the trace began. + google.protobuf.Timestamp start_time = 4; // required + // Wallclock time when the trace ended. + google.protobuf.Timestamp end_time = 3; // required + // High precision duration of the trace; may not equal end_time-start_time + // (eg, if your machine's clock changed during the trace). + uint64 duration_ns = 11; // required + // A tree containing information about all resolvers run directly by this + // service, including errors. + Node root = 14; + + // ------------------------------------------------------------------------- + // Fields below this line are *not* included in federated traces (the traces + // sent from federated services to the gateway). + + // In addition to details.raw_query, we include a "signature" of the query, + // which can be normalized: for example, you may want to discard aliases, drop + // unused operations and fragments, sort fields, etc. The most important thing + // here is that the signature match the signature in StatsReports. In + // StatsReports signatures show up as the key in the per_query map (with the + // operation name prepended). The signature should be a valid GraphQL query. + // All traces must have a signature; if this Trace is in a FullTracesReport + // that signature is in the key of traces_per_query rather than in this field. + // Engineproxy provides the signature in legacy_signature_needs_resigning + // instead. + string signature = 19; + + // Optional: when GraphQL parsing or validation against the GraphQL schema fails, these fields + // can include reference to the operation being sent for users to dig into the set of operations + // that are failing validation. + string unexecutedOperationBody = 27; + string unexecutedOperationName = 28; + + Details details = 6; + + string client_name = 7; + string client_version = 8; + + HTTP http = 10; + + CachePolicy cache_policy = 18; + + // If this Trace was created by a gateway, this is the query plan, including + // sub-Traces for federated services. Note that the 'root' tree on the + // top-level Trace won't contain any resolvers (though it could contain errors + // that occurred in the gateway itself). + QueryPlanNode query_plan = 26; + + // Was this response served from a full query response cache? (In that case + // the node tree will have no resolvers.) + bool full_query_cache_hit = 20; + + // Was this query specified successfully as a persisted query hash? + bool persisted_query_hit = 21; + // Did this query contain both a full query string and a persisted query hash? + // (This typically means that a previous request was rejected as an unknown + // persisted query.) + bool persisted_query_register = 22; + + // Was this operation registered and a part of the safelist? + bool registered_operation = 24; + + // Was this operation forbidden due to lack of safelisting? + bool forbidden_operation = 25; + + // Some servers don't do field-level instrumentation for every request and assign + // each request a "weight" for each request that they do instrument. When this + // trace is aggregated into field usage stats, it should count as this value + // towards the estimated_execution_count rather than just 1. This value should + // typically be at least 1. + // + // 0 is treated as 1 for backwards compatibility. + double field_execution_weight = 31; + + + + // removed: Node parse = 12; Node validate = 13; + // Id128 server_id = 1; Id128 client_id = 2; + // String client_reference_id = 23; String client_address = 9; + reserved 1, 2, 9, 12, 13, 23; +} + +// The `service` value embedded within the header key is not guaranteed to contain an actual service, +// and, in most cases, the service information is trusted to come from upstream processing. If the +// service _is_ specified in this header, then it is checked to match the context that is reporting it. +// Otherwise, the service information is deduced from the token context of the reporter and then sent +// along via other mechanisms (in Kafka, the `ReportKafkaKey). The other information (hostname, +// agent_version, etc.) is sent by the Apollo Engine Reporting agent, but we do not currently save that +// information to any of our persistent storage. +message ReportHeader { + // eg "mygraph@myvariant" + string graph_ref = 12; + + // eg "host-01.example.com" + string hostname = 5; + + // eg "engineproxy 0.1.0" + string agent_version = 6; // required + // eg "prod-4279-20160804T065423Z-5-g3cf0aa8" (taken from `git describe --tags`) + string service_version = 7; + // eg "node v4.6.0" + string runtime_version = 8; + // eg "Linux box 4.6.5-1-ec2 #1 SMP Mon Aug 1 02:31:38 PDT 2016 x86_64 GNU/Linux" + string uname = 9; + // An id that is used to represent the schema to Apollo Graph Manager + // Using this in place of what used to be schema_hash, since that is no longer + // attached to a schema in the backend. + string executable_schema_id = 11; + + reserved 3; // removed string service = 3; +} + +message PathErrorStats { + map children = 1; + uint64 errors_count = 4; + uint64 requests_with_errors_count = 5; +} + +message QueryLatencyStats { + repeated sint64 latency_count = 13; + uint64 request_count = 2; + uint64 cache_hits = 3; + uint64 persisted_query_hits = 4; + uint64 persisted_query_misses = 5; + repeated sint64 cache_latency_count = 14; + PathErrorStats root_error_stats = 7; + uint64 requests_with_errors_count = 8; + repeated sint64 public_cache_ttl_count = 15; + repeated sint64 private_cache_ttl_count = 16; + uint64 registered_operation_count = 11; + uint64 forbidden_operation_count = 12; + // The number of requests that were executed without field-level + // instrumentation (and thus do not contribute to `observed_execution_count` + // fields on this message's cousin-twice-removed FieldStats). + uint64 requests_without_field_instrumentation = 17; + // 1, 6, 9, and 10 were old int64 histograms + reserved 1, 6, 9, 10; +} + +message StatsContext { + // string client_reference_id = 1; + reserved 1; + string client_name = 2; + string client_version = 3; +} + +message ContextualizedQueryLatencyStats { + QueryLatencyStats query_latency_stats = 1; + StatsContext context = 2; +} + +message ContextualizedTypeStats { + StatsContext context = 1; + map per_type_stat = 2; +} + +message FieldStat { + string return_type = 3; // required; eg "String!" for User.email:String! + // Number of errors whose path is this field. Note that we assume that error + // tracking does *not* require field-level instrumentation so this *will* + // include errors from requests that don't contribute to the + // `observed_execution_count` field (and does not need to be scaled by + // field_execution_weight). + uint64 errors_count = 4; + // Number of times that the resolver for this field is directly observed being + // executed. + uint64 observed_execution_count = 5; + // Same as `count` but potentially scaled upwards if the server was only + // performing field-level instrumentation on a sampling of operations. For + // example, if the server randomly instruments 1% of requests for this + // operation, this number will be 100 times greater than + // `observed_execution_count`. (When aggregating a Trace into FieldStats, + // this number goes up by the trace's `field_execution_weight` for each + // observed field execution, while `observed_execution_count` above goes + // up by 1.) + uint64 estimated_execution_count = 10; + // Number of times the resolver for this field is executed that resulted in + // at least one error. "Request" is a misnomer here as this corresponds to + // resolver calls, not overall operations. Like `errors_count` above, this + // includes all requests rather than just requests with field-level + // instrumentation. + uint64 requests_with_errors_count = 6; + // Duration histogram for the latency of this field. Note that it is scaled in + // the same way as estimated_execution_count so its "total count" might be + // greater than `observed_execution_count` and may not exactly equal + // `estimated_execution_count` due to rounding. + repeated sint64 latency_count = 9; + reserved 1, 2, 7, 8; +} + +message TypeStat { + // Key is (eg) "email" for User.email:String! + map per_field_stat = 3; + reserved 1, 2; +} + +message ReferencedFieldsForType { + // Contains (eg) "email" for User.email:String! + repeated string field_names = 1; + // True if this type is an interface. + bool is_interface = 2; +} + + + +// This is the top-level message used by the new traces ingress. This +// is designed for the apollo-engine-reporting TypeScript agent and will +// eventually be documented as a public ingress API. This message consists +// solely of traces; the equivalent of the StatsReport is automatically +// generated server-side from this message. Agent should either send a trace or include it in the stats +// for every request in this report. Generally, buffering up until a large +// size has been reached (say, 4MB) or 5-10 seconds has passed is appropriate. +// This message used to be know as FullTracesReport, but got renamed since it isn't just for traces anymore +message Report { + ReportHeader header = 1; + + // key is statsReportKey (# operationName\nsignature) Note that the nested + // traces will *not* have a signature or details.operationName (because the + // key is adequate). + // + // We also assume that traces don't have + // legacy_per_query_implicit_operation_name, and we don't require them to have + // details.raw_query (which would consume a lot of space and has privacy/data + // access issues, and isn't currently exposed by our app anyway). + map traces_per_query = 5; + + // This is the time that the requests in this trace are considered to have taken place + // If this field is not present the max of the end_time of each trace will be used instead. + // If there are no traces and no end_time present the report will not be able to be processed. + // Note: This will override the end_time from traces. + google.protobuf.Timestamp end_time = 2; // required if no traces in this message + + // Total number of operations processed during this period. + uint64 operation_count = 6; +} + +message ContextualizedStats { + StatsContext context = 1; + QueryLatencyStats query_latency_stats = 2; + // Key is type name. This structure provides data for the count and latency of individual + // field executions and thus only reflects operations for which field-level tracing occurred. + map per_type_stat = 3; + +} + +// A sequence of traces and stats. An individual operation should either be described as a trace +// or as part of stats, but not both. +message TracesAndStats { + repeated Trace trace = 1; + repeated ContextualizedStats stats_with_context = 2; + // This describes the fields referenced in the operation. Note that this may + // include fields that don't show up in FieldStats (due to being interface fields, + // being nested under null fields or empty lists or non-matching fragments or + // `@include` or `@skip`, etc). It also may be missing fields that show up in FieldStats + // (as FieldStats will include the concrete object type for fields referenced + // via an interface type). + map referenced_fields_by_type = 4; + // This field is used to validate that the algorithm used to construct `stats_with_context` + // matches similar algorithms in Apollo's servers. It is otherwise ignored and should not + // be included in reports. + repeated Trace internal_traces_contributing_to_stats = 3; +} \ No newline at end of file diff --git a/graphql/handler/apollofederatedtracingv1/tracing.go b/graphql/handler/apollofederatedtracingv1/tracing.go new file mode 100644 index 0000000..a930e25 --- /dev/null +++ b/graphql/handler/apollofederatedtracingv1/tracing.go @@ -0,0 +1,112 @@ +package apollofederatedtracingv1 + +import ( + "context" + "encoding/base64" + "fmt" + + "google.golang.org/protobuf/proto" + + "github.com/niko0xdev/gqlgen/graphql" +) + +type ( + Tracer struct { + ClientName string + Version string + Hostname string + } + + treeBuilderKey string +) + +const ( + key = treeBuilderKey("treeBuilder") +) + +var _ interface { + graphql.HandlerExtension + graphql.ResponseInterceptor + graphql.FieldInterceptor + graphql.OperationInterceptor +} = &Tracer{} + +// ExtensionName returns the name of the extension +func (Tracer) ExtensionName() string { + return "ApolloFederatedTracingV1" +} + +// Validate returns errors based on the schema; since this extension doesn't require validation, we return nil +func (Tracer) Validate(graphql.ExecutableSchema) error { + return nil +} + +func (t *Tracer) shouldTrace(ctx context.Context) bool { + return graphql.HasOperationContext(ctx) && + graphql.GetOperationContext(ctx).Headers.Get("apollo-federation-include-trace") == "ftv1" +} + +func (t *Tracer) getTreeBuilder(ctx context.Context) *TreeBuilder { + val := ctx.Value(key) + if val == nil { + return nil + } + if tb, ok := val.(*TreeBuilder); ok { + return tb + } + return nil +} + +// InterceptOperation acts on each Graph operation; on each operation, start a tree builder and start the tree's timer for tracing +func (t *Tracer) InterceptOperation(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler { + if !t.shouldTrace(ctx) { + return next(ctx) + } + return next(context.WithValue(ctx, key, NewTreeBuilder())) +} + +// InterceptField is called on each field's resolution, including information about the path and parent node. +// This information is then used to build the relevant Node Tree used in the FTV1 tracing format +func (t *Tracer) InterceptField(ctx context.Context, next graphql.Resolver) (interface{}, error) { + if !t.shouldTrace(ctx) { + return next(ctx) + } + if tb := t.getTreeBuilder(ctx); tb != nil { + tb.WillResolveField(ctx) + } + + return next(ctx) +} + +// InterceptResponse is called before the overall response is sent, but before each field resolves; as a result +// the final marshaling is deferred to happen at the end of the operation +func (t *Tracer) InterceptResponse(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + if !t.shouldTrace(ctx) { + return next(ctx) + } + tb := t.getTreeBuilder(ctx) + if tb == nil { + return next(ctx) + } + + tb.StartTimer(ctx) + + val := new(string) + graphql.RegisterExtension(ctx, "ftv1", val) + + // now that fields have finished resolving, it stops the timer to calculate trace duration + defer func(val *string) { + tb.StopTimer(ctx) + + // marshal the protobuf ... + p, err := proto.Marshal(tb.Trace) + if err != nil { + fmt.Print(err) + } + + // ... then set the previously instantiated string as the base64 formatted string as required + *val = base64.StdEncoding.EncodeToString(p) + }(val) + resp := next(ctx) + return resp +} diff --git a/graphql/handler/apollofederatedtracingv1/tracing_test.go b/graphql/handler/apollofederatedtracingv1/tracing_test.go new file mode 100644 index 0000000..d8d7e7c --- /dev/null +++ b/graphql/handler/apollofederatedtracingv1/tracing_test.go @@ -0,0 +1,172 @@ +package apollofederatedtracingv1_test + +import ( + "context" + "encoding/base64" + "encoding/json" + "fmt" + "io" + "net/http" + "net/http/httptest" + "strings" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/v2/gqlerror" + "google.golang.org/protobuf/proto" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler/apollofederatedtracingv1" + "github.com/niko0xdev/gqlgen/graphql/handler/apollofederatedtracingv1/generated" + "github.com/niko0xdev/gqlgen/graphql/handler/extension" + "github.com/niko0xdev/gqlgen/graphql/handler/lru" + "github.com/niko0xdev/gqlgen/graphql/handler/testserver" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" +) + +type alwaysError struct{} + +func (a *alwaysError) Read(p []byte) (int, error) { + return 0, io.ErrUnexpectedEOF +} + +func TestApolloTracing(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.POST{}) + h.Use(&apollofederatedtracingv1.Tracer{}) + h.Use(&delayMiddleware{}) + + resp := doRequest(h, http.MethodPost, "/graphql", `{"query":"{ name }"}`) + assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + var respData struct { + Extensions struct { + FTV1 string `json:"ftv1"` + } `json:"extensions"` + } + require.NoError(t, json.Unmarshal(resp.Body.Bytes(), &respData)) + + tracing := respData.Extensions.FTV1 + pbuf, err := base64.StdEncoding.DecodeString(tracing) + require.Nil(t, err) + + ftv1 := &generated.Trace{} + err = proto.Unmarshal(pbuf, ftv1) + require.Nil(t, err) + + require.NotZero(t, ftv1.StartTime.Nanos) + require.Less(t, ftv1.StartTime.Nanos, ftv1.EndTime.Nanos) + require.EqualValues(t, ftv1.EndTime.Nanos-ftv1.StartTime.Nanos, ftv1.DurationNs) + + fmt.Printf("%#v\n", resp.Body.String()) + require.Equal(t, "Query", ftv1.Root.Child[0].ParentType) + require.Equal(t, "name", ftv1.Root.Child[0].GetResponseName()) + require.Equal(t, "String!", ftv1.Root.Child[0].Type) +} + +func TestApolloTracing_Concurrent(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.POST{}) + h.Use(&apollofederatedtracingv1.Tracer{}) + for i := 0; i < 2; i++ { + go func() { + resp := doRequest(h, http.MethodPost, "/graphql", `{"query":"{ name }"}`) + assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + var respData struct { + Extensions struct { + FTV1 string `json:"ftv1"` + } `json:"extensions"` + } + require.NoError(t, json.Unmarshal(resp.Body.Bytes(), &respData)) + + tracing := respData.Extensions.FTV1 + pbuf, err := base64.StdEncoding.DecodeString(tracing) + require.Nil(t, err) + + ftv1 := &generated.Trace{} + err = proto.Unmarshal(pbuf, ftv1) + require.Nil(t, err) + require.NotZero(t, ftv1.StartTime.Nanos) + }() + } +} + +func TestApolloTracing_withFail(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.POST{}) + h.Use(extension.AutomaticPersistedQuery{Cache: lru.New(100)}) + h.Use(&apollofederatedtracingv1.Tracer{}) + + resp := doRequest(h, http.MethodPost, "/graphql", `{"operationName":"A","extensions":{"persistedQuery":{"version":1,"sha256Hash":"338bbc16ac780daf81845339fbf0342061c1e9d2b702c96d3958a13a557083a6"}}}`) + assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + b := resp.Body.Bytes() + t.Log(string(b)) + var respData struct { + Errors gqlerror.List + } + require.NoError(t, json.Unmarshal(b, &respData)) + require.Len(t, respData.Errors, 1) + require.Equal(t, "PersistedQueryNotFound", respData.Errors[0].Message) +} + +// This tests that the tracing extension does not panic when the request +// can't be processed for some reason. The specific cause is not +// important, the scenario being tested is the response interceptor +// being run to process the error response when no other interceptor +// has been run, due to (for example) a problem creating the OperationContext. +func TestApolloTracing_withMissingOp(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.POST{}) + h.Use(extension.AutomaticPersistedQuery{Cache: lru.New(100)}) + h.Use(&apollofederatedtracingv1.Tracer{}) + + resp := doRequest(h, http.MethodPost, "/graphql", `{}`) + assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + b := resp.Body.Bytes() + t.Log(string(b)) + var respData struct { + Errors gqlerror.List + } + require.NoError(t, json.Unmarshal(b, &respData)) + require.Len(t, respData.Errors, 1) + require.Equal(t, "no operation provided", respData.Errors[0].Message) +} + +func TestApolloTracing_withUnexpectedEOF(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.POST{}) + h.Use(&apollofederatedtracingv1.Tracer{}) + + resp := doRequestWithReader(h, http.MethodPost, "/graphql", &alwaysError{}) + assert.Equal(t, http.StatusOK, resp.Code) +} +func doRequest(handler http.Handler, method, target, body string) *httptest.ResponseRecorder { + return doRequestWithReader(handler, method, target, strings.NewReader(body)) +} + +func doRequestWithReader(handler http.Handler, method string, target string, + reader io.Reader) *httptest.ResponseRecorder { + r := httptest.NewRequest(method, target, reader) + r.Header.Set("Content-Type", "application/json") + r.Header.Set("apollo-federation-include-trace", "ftv1") + w := httptest.NewRecorder() + + handler.ServeHTTP(w, r) + return w +} + +type delayMiddleware struct{} + +func (*delayMiddleware) InterceptOperation(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler { + time.Sleep(time.Millisecond) + return next(ctx) +} + +func (*delayMiddleware) ExtensionName() string { + return "delay" +} + +func (*delayMiddleware) Validate(schema graphql.ExecutableSchema) error { + return nil +} diff --git a/graphql/handler/apollofederatedtracingv1/tree_builder.go b/graphql/handler/apollofederatedtracingv1/tree_builder.go new file mode 100644 index 0000000..89216bb --- /dev/null +++ b/graphql/handler/apollofederatedtracingv1/tree_builder.go @@ -0,0 +1,145 @@ +package apollofederatedtracingv1 + +import ( + "context" + "fmt" + "sync" + "time" + + "google.golang.org/protobuf/types/known/timestamppb" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler/apollofederatedtracingv1/generated" +) + +type TreeBuilder struct { + Trace *generated.Trace + rootNode generated.Trace_Node + nodes map[string]NodeMap // nodes is used to store a pointer map using the node path (e.g. todo[0].id) to itself as well as it's parent + + startTime *time.Time + stopped bool + mu sync.Mutex +} + +type NodeMap struct { + self *generated.Trace_Node + parent *generated.Trace_Node +} + +// NewTreeBuilder is used to start the node tree with a default root node, along with the related tree nodes map entry +func NewTreeBuilder() *TreeBuilder { + tb := TreeBuilder{ + rootNode: generated.Trace_Node{}, + } + + t := generated.Trace{ + Root: &tb.rootNode, + } + tb.nodes = make(map[string]NodeMap) + tb.nodes[""] = NodeMap{self: &tb.rootNode, parent: nil} + + tb.Trace = &t + + return &tb +} + +// StartTimer marks the time using protobuf timestamp format for use in timing calculations +func (tb *TreeBuilder) StartTimer(ctx context.Context) { + if tb.startTime != nil { + fmt.Println(fmt.Errorf("StartTimer called twice")) + } + if tb.stopped { + fmt.Println(fmt.Errorf("StartTimer called after StopTimer")) + } + + rc := graphql.GetOperationContext(ctx) + start := rc.Stats.OperationStart + + tb.Trace.StartTime = timestamppb.New(start) + tb.startTime = &start +} + +// StopTimer marks the end of the timer, along with setting the related fields in the protobuf representation +func (tb *TreeBuilder) StopTimer(ctx context.Context) { + if tb.startTime == nil { + fmt.Println(fmt.Errorf("StopTimer called before StartTimer")) + } + if tb.stopped { + fmt.Println(fmt.Errorf("StopTimer called twice")) + } + + ts := graphql.Now().UTC() + tb.Trace.DurationNs = uint64(ts.Sub(*tb.startTime).Nanoseconds()) + tb.Trace.EndTime = timestamppb.New(ts) + tb.stopped = true +} + +// On each field, it calculates the time started at as now - tree.StartTime, as well as a deferred function upon full resolution of the +// field as now - tree.StartTime; these are used by Apollo to calculate how fields are being resolved in the AST +func (tb *TreeBuilder) WillResolveField(ctx context.Context) { + if tb.startTime == nil { + fmt.Println(fmt.Errorf("WillResolveField called before StartTimer")) + return + } + if tb.stopped { + fmt.Println(fmt.Errorf("WillResolveField called after StopTimer")) + return + } + fc := graphql.GetFieldContext(ctx) + + node := tb.newNode(fc) + node.StartTime = uint64(graphql.Now().Sub(*tb.startTime).Nanoseconds()) + defer func() { + node.EndTime = uint64(graphql.Now().Sub(*tb.startTime).Nanoseconds()) + }() + + node.Type = fc.Field.Definition.Type.String() + node.ParentType = fc.Object +} + +// newNode is called on each new node within the AST and sets related values such as the entry in the tree.node map and ID attribute +func (tb *TreeBuilder) newNode(path *graphql.FieldContext) *generated.Trace_Node { + // if the path is empty, it is the root node of the operation + if path.Path().String() == "" { + return &tb.rootNode + } + + self := &generated.Trace_Node{} + pn := tb.ensureParentNode(path) + + if path.Index != nil { + self.Id = &generated.Trace_Node_Index{Index: uint32(*path.Index)} + } else { + self.Id = &generated.Trace_Node_ResponseName{ResponseName: path.Field.Name} + } + + // lock the map from being read/written concurrently to avoid panics + tb.mu.Lock() + nodeRef := tb.nodes[path.Path().String()] + // set the values for the node references to help build the tree + nodeRef.parent = pn + nodeRef.self = self + + // since they are references, we point the parent to it's children nodes + nodeRef.parent.Child = append(nodeRef.parent.Child, self) + nodeRef.self = self + tb.nodes[path.Path().String()] = nodeRef + tb.mu.Unlock() + + return self +} + +// ensureParentNode ensures the node isn't orphaned +func (tb *TreeBuilder) ensureParentNode(path *graphql.FieldContext) *generated.Trace_Node { + // lock to read briefly, then unlock to avoid r/w issues + tb.mu.Lock() + nodeRef := tb.nodes[path.Parent.Path().String()] + tb.mu.Unlock() + + if nodeRef.self != nil { + return nodeRef.self + } + + return tb.newNode(path.Parent) +} diff --git a/graphql/handler/apollotracing/tracer.go b/graphql/handler/apollotracing/tracer.go new file mode 100644 index 0000000..add59d9 --- /dev/null +++ b/graphql/handler/apollotracing/tracer.go @@ -0,0 +1,119 @@ +package apollotracing + +import ( + "context" + "sync" + "time" + + "github.com/vektah/gqlparser/v2/ast" + + "github.com/niko0xdev/gqlgen/graphql" +) + +type ( + Tracer struct{} + + TracingExtension struct { + mu sync.Mutex + Version int `json:"version"` + StartTime time.Time `json:"startTime"` + EndTime time.Time `json:"endTime"` + Duration time.Duration `json:"duration"` + Parsing Span `json:"parsing"` + Validation Span `json:"validation"` + Execution struct { + Resolvers []*ResolverExecution `json:"resolvers"` + } `json:"execution"` + } + + Span struct { + StartOffset time.Duration `json:"startOffset"` + Duration time.Duration `json:"duration"` + } + + ResolverExecution struct { + Path ast.Path `json:"path"` + ParentType string `json:"parentType"` + FieldName string `json:"fieldName"` + ReturnType string `json:"returnType"` + StartOffset time.Duration `json:"startOffset"` + Duration time.Duration `json:"duration"` + } +) + +var _ interface { + graphql.HandlerExtension + graphql.ResponseInterceptor + graphql.FieldInterceptor +} = Tracer{} + +func (Tracer) ExtensionName() string { + return "ApolloTracing" +} + +func (Tracer) Validate(graphql.ExecutableSchema) error { + return nil +} + +func (Tracer) InterceptField(ctx context.Context, next graphql.Resolver) (interface{}, error) { + td, ok := graphql.GetExtension(ctx, "tracing").(*TracingExtension) + if !ok { + return next(ctx) + } + + start := graphql.Now() + + defer func() { + end := graphql.Now() + + rc := graphql.GetOperationContext(ctx) + fc := graphql.GetFieldContext(ctx) + resolver := &ResolverExecution{ + Path: fc.Path(), + ParentType: fc.Object, + FieldName: fc.Field.Name, + ReturnType: fc.Field.Definition.Type.String(), + StartOffset: start.Sub(rc.Stats.OperationStart), + Duration: end.Sub(start), + } + + td.mu.Lock() + td.Execution.Resolvers = append(td.Execution.Resolvers, resolver) + td.mu.Unlock() + }() + + return next(ctx) +} + +func (Tracer) InterceptResponse(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + if !graphql.HasOperationContext(ctx) { + return next(ctx) + } + + rc := graphql.GetOperationContext(ctx) + + start := rc.Stats.OperationStart + + td := &TracingExtension{ + Version: 1, + StartTime: start, + Parsing: Span{ + StartOffset: rc.Stats.Parsing.Start.Sub(start), + Duration: rc.Stats.Parsing.End.Sub(rc.Stats.Parsing.Start), + }, + + Validation: Span{ + StartOffset: rc.Stats.Validation.Start.Sub(start), + Duration: rc.Stats.Validation.End.Sub(rc.Stats.Validation.Start), + }, + } + + graphql.RegisterExtension(ctx, "tracing", td) + resp := next(ctx) + + end := graphql.Now() + td.EndTime = end + td.Duration = end.Sub(start) + + return resp +} diff --git a/graphql/handler/apollotracing/tracer_test.go b/graphql/handler/apollotracing/tracer_test.go new file mode 100644 index 0000000..5651bc6 --- /dev/null +++ b/graphql/handler/apollotracing/tracer_test.go @@ -0,0 +1,124 @@ +package apollotracing_test + +import ( + "encoding/json" + "io" + "net/http" + "net/http/httptest" + "strings" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/v2/ast" + "github.com/vektah/gqlparser/v2/gqlerror" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler/apollotracing" + "github.com/niko0xdev/gqlgen/graphql/handler/extension" + "github.com/niko0xdev/gqlgen/graphql/handler/lru" + "github.com/niko0xdev/gqlgen/graphql/handler/testserver" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" +) + +type alwaysError struct{} + +func (a *alwaysError) Read(p []byte) (int, error) { + return 0, io.ErrUnexpectedEOF +} + +func TestApolloTracing(t *testing.T) { + now := time.Unix(0, 0) + + graphql.Now = func() time.Time { + defer func() { + now = now.Add(100 * time.Nanosecond) + }() + return now + } + + h := testserver.New() + h.AddTransport(transport.POST{}) + h.Use(apollotracing.Tracer{}) + + resp := doRequest(h, http.MethodPost, "/graphql", `{"query":"{ name }"}`) + assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + var respData struct { + Extensions struct { + Tracing apollotracing.TracingExtension `json:"tracing"` + } `json:"extensions"` + } + require.NoError(t, json.Unmarshal(resp.Body.Bytes(), &respData)) + + tracing := &respData.Extensions.Tracing + + require.EqualValues(t, 1, tracing.Version) + + require.Zero(t, tracing.StartTime.UnixNano()) + require.EqualValues(t, 900, tracing.EndTime.UnixNano()) + require.EqualValues(t, 900, tracing.Duration) + + require.EqualValues(t, 300, tracing.Parsing.StartOffset) + require.EqualValues(t, 100, tracing.Parsing.Duration) + + require.EqualValues(t, 500, tracing.Validation.StartOffset) + require.EqualValues(t, 100, tracing.Validation.Duration) + + require.EqualValues(t, 700, tracing.Execution.Resolvers[0].StartOffset) + require.EqualValues(t, 100, tracing.Execution.Resolvers[0].Duration) + require.EqualValues(t, ast.Path{ast.PathName("name")}, tracing.Execution.Resolvers[0].Path) + require.Equal(t, "Query", tracing.Execution.Resolvers[0].ParentType) + require.Equal(t, "name", tracing.Execution.Resolvers[0].FieldName) + require.Equal(t, "String!", tracing.Execution.Resolvers[0].ReturnType) +} + +func TestApolloTracing_withFail(t *testing.T) { + now := time.Unix(0, 0) + + graphql.Now = func() time.Time { + defer func() { + now = now.Add(100 * time.Nanosecond) + }() + return now + } + + h := testserver.New() + h.AddTransport(transport.POST{}) + h.Use(extension.AutomaticPersistedQuery{Cache: lru.New(100)}) + h.Use(apollotracing.Tracer{}) + + resp := doRequest(h, http.MethodPost, "/graphql", `{"operationName":"A","extensions":{"persistedQuery":{"version":1,"sha256Hash":"338bbc16ac780daf81845339fbf0342061c1e9d2b702c96d3958a13a557083a6"}}}`) + assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + b := resp.Body.Bytes() + t.Log(string(b)) + var respData struct { + Errors gqlerror.List + } + require.NoError(t, json.Unmarshal(b, &respData)) + require.Len(t, respData.Errors, 1) + require.Equal(t, "PersistedQueryNotFound", respData.Errors[0].Message) +} + +func TestApolloTracing_withUnexpectedEOF(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.POST{}) + h.Use(apollotracing.Tracer{}) + + resp := doRequestWithReader(h, http.MethodPost, "/graphql", &alwaysError{}) + assert.Equal(t, http.StatusOK, resp.Code) +} + +func doRequest(handler http.Handler, method, target, body string) *httptest.ResponseRecorder { + return doRequestWithReader(handler, method, target, strings.NewReader(body)) +} + +func doRequestWithReader(handler http.Handler, method string, target string, + reader io.Reader) *httptest.ResponseRecorder { + r := httptest.NewRequest(method, target, reader) + r.Header.Set("Content-Type", "application/json") + w := httptest.NewRecorder() + + handler.ServeHTTP(w, r) + return w +} diff --git a/graphql/handler/debug/tracer.go b/graphql/handler/debug/tracer.go new file mode 100644 index 0000000..19adddb --- /dev/null +++ b/graphql/handler/debug/tracer.go @@ -0,0 +1,70 @@ +package debug + +import ( + "context" + "encoding/json" + "fmt" + "io" + "os" + "strings" + + . "github.com/logrusorgru/aurora/v3" + "github.com/mattn/go-colorable" + "github.com/mattn/go-isatty" + + "github.com/niko0xdev/gqlgen/graphql" +) + +type Tracer struct { + DisableColor bool + au Aurora + out io.Writer +} + +var _ interface { + graphql.HandlerExtension + graphql.ResponseInterceptor +} = &Tracer{} + +func (a Tracer) ExtensionName() string { + return "ApolloTracing" +} + +func (a *Tracer) Validate(schema graphql.ExecutableSchema) error { + isTTY := isatty.IsTerminal(os.Stdout.Fd()) + + a.au = NewAurora(!a.DisableColor && isTTY) + a.out = colorable.NewColorableStdout() + + return nil +} + +func stringify(value interface{}) string { + valueJson, err := json.MarshalIndent(value, " ", " ") + if err == nil { + return string(valueJson) + } + + return fmt.Sprint(value) +} + +func (a Tracer) InterceptResponse(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + rctx := graphql.GetOperationContext(ctx) + + fmt.Fprintln(a.out, "GraphQL Request {") + for _, line := range strings.Split(rctx.RawQuery, "\n") { + fmt.Fprintln(a.out, " ", Cyan(line)) + } + for name, value := range rctx.Variables { + fmt.Fprintf(a.out, " var %s = %s\n", name, Yellow(stringify(value))) + } + resp := next(ctx) + + fmt.Fprintln(a.out, " resp:", Green(stringify(resp))) + for _, err := range resp.Errors { + fmt.Fprintln(a.out, " error:", Bold(err.Path.String()+":"), Red(err.Message)) + } + fmt.Fprintln(a.out, "}") + fmt.Fprintln(a.out) + return resp +} diff --git a/graphql/handler/extension/apq.go b/graphql/handler/extension/apq.go new file mode 100644 index 0000000..09abead --- /dev/null +++ b/graphql/handler/extension/apq.go @@ -0,0 +1,113 @@ +package extension + +import ( + "context" + "crypto/sha256" + "encoding/hex" + "fmt" + + "github.com/mitchellh/mapstructure" + "github.com/vektah/gqlparser/v2/gqlerror" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/errcode" +) + +const ( + errPersistedQueryNotFound = "PersistedQueryNotFound" + errPersistedQueryNotFoundCode = "PERSISTED_QUERY_NOT_FOUND" +) + +// AutomaticPersistedQuery saves client upload by optimistically sending only the hashes of queries, if the server +// does not yet know what the query is for the hash it will respond telling the client to send the query along with the +// hash in the next request. +// see https://github.com/apollographql/apollo-link-persisted-queries +type AutomaticPersistedQuery struct { + Cache graphql.Cache +} + +type ApqStats struct { + // The hash of the incoming query + Hash string + + // SentQuery is true if the incoming request sent the full query + SentQuery bool +} + +const apqExtension = "APQ" + +var _ interface { + graphql.OperationParameterMutator + graphql.HandlerExtension +} = AutomaticPersistedQuery{} + +func (a AutomaticPersistedQuery) ExtensionName() string { + return "AutomaticPersistedQuery" +} + +func (a AutomaticPersistedQuery) Validate(schema graphql.ExecutableSchema) error { + if a.Cache == nil { + return fmt.Errorf("AutomaticPersistedQuery.Cache can not be nil") + } + return nil +} + +func (a AutomaticPersistedQuery) MutateOperationParameters(ctx context.Context, rawParams *graphql.RawParams) *gqlerror.Error { + if rawParams.Extensions["persistedQuery"] == nil { + return nil + } + + var extension struct { + Sha256 string `mapstructure:"sha256Hash"` + Version int64 `mapstructure:"version"` + } + + if err := mapstructure.Decode(rawParams.Extensions["persistedQuery"], &extension); err != nil { + return gqlerror.Errorf("invalid APQ extension data") + } + + if extension.Version != 1 { + return gqlerror.Errorf("unsupported APQ version") + } + + fullQuery := false + if rawParams.Query == "" { + // client sent optimistic query hash without query string, get it from the cache + query, ok := a.Cache.Get(ctx, extension.Sha256) + if !ok { + err := gqlerror.Errorf(errPersistedQueryNotFound) + errcode.Set(err, errPersistedQueryNotFoundCode) + return err + } + rawParams.Query = query.(string) + } else { + // client sent optimistic query hash with query string, verify and store it + if computeQueryHash(rawParams.Query) != extension.Sha256 { + return gqlerror.Errorf("provided APQ hash does not match query") + } + a.Cache.Add(ctx, extension.Sha256, rawParams.Query) + fullQuery = true + } + + graphql.GetOperationContext(ctx).Stats.SetExtension(apqExtension, &ApqStats{ + Hash: extension.Sha256, + SentQuery: fullQuery, + }) + + return nil +} + +func GetApqStats(ctx context.Context) *ApqStats { + rc := graphql.GetOperationContext(ctx) + if rc == nil { + return nil + } + + s, _ := rc.Stats.GetExtension(apqExtension).(*ApqStats) + return s +} + +func computeQueryHash(query string) string { + b := sha256.Sum256([]byte(query)) + return hex.EncodeToString(b[:]) +} diff --git a/graphql/handler/extension/apq_test.go b/graphql/handler/extension/apq_test.go new file mode 100644 index 0000000..36d0c27 --- /dev/null +++ b/graphql/handler/extension/apq_test.go @@ -0,0 +1,168 @@ +package extension_test + +import ( + "context" + "net/http" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler/extension" + "github.com/niko0xdev/gqlgen/graphql/handler/testserver" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" +) + +func TestAPQIntegration(t *testing.T) { + h := testserver.New() + h.Use(&extension.AutomaticPersistedQuery{Cache: graphql.MapCache{}}) + h.AddTransport(&transport.POST{}) + + var stats *extension.ApqStats + h.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + stats = extension.GetApqStats(ctx) + return next(ctx) + }) + + resp := doRequest(h, "POST", "/graphql", `{"query":"{ name }","extensions":{"persistedQuery":{"version":1,"sha256Hash":"30166fc3298853f22709fce1e4a00e98f1b6a3160eaaaf9cb3b7db6a16073b07"}}}`) + require.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + require.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + + require.NotNil(t, stats) + require.True(t, stats.SentQuery) + require.Equal(t, "30166fc3298853f22709fce1e4a00e98f1b6a3160eaaaf9cb3b7db6a16073b07", stats.Hash) +} + +func TestAPQ(t *testing.T) { + const query = "{ me { name } }" + const hash = "b8d9506e34c83b0e53c2aa463624fcea354713bc38f95276e6f0bd893ffb5b88" + + t.Run("with query and no hash", func(t *testing.T) { + ctx := newOC() + params := &graphql.RawParams{ + Query: "original query", + } + err := extension.AutomaticPersistedQuery{graphql.MapCache{}}.MutateOperationParameters(ctx, params) + require.Nil(t, err) + + require.Equal(t, "original query", params.Query) + }) + + t.Run("with hash miss and no query", func(t *testing.T) { + ctx := newOC() + params := &graphql.RawParams{ + Extensions: map[string]interface{}{ + "persistedQuery": map[string]interface{}{ + "sha256Hash": hash, + "version": 1, + }, + }, + } + + err := extension.AutomaticPersistedQuery{graphql.MapCache{}}.MutateOperationParameters(ctx, params) + require.Equal(t, err.Message, "PersistedQueryNotFound") + }) + + t.Run("with hash miss and query", func(t *testing.T) { + ctx := newOC() + params := &graphql.RawParams{ + Query: query, + Extensions: map[string]interface{}{ + "persistedQuery": map[string]interface{}{ + "sha256Hash": hash, + "version": 1, + }, + }, + } + cache := graphql.MapCache{} + err := extension.AutomaticPersistedQuery{cache}.MutateOperationParameters(ctx, params) + require.Nil(t, err) + + require.Equal(t, "{ me { name } }", params.Query) + require.Equal(t, "{ me { name } }", cache[hash]) + }) + + t.Run("with hash miss and query", func(t *testing.T) { + ctx := newOC() + params := &graphql.RawParams{ + Query: query, + Extensions: map[string]interface{}{ + "persistedQuery": map[string]interface{}{ + "sha256Hash": hash, + "version": 1, + }, + }, + } + cache := graphql.MapCache{} + err := extension.AutomaticPersistedQuery{cache}.MutateOperationParameters(ctx, params) + require.Nil(t, err) + + require.Equal(t, "{ me { name } }", params.Query) + require.Equal(t, "{ me { name } }", cache[hash]) + }) + + t.Run("with hash hit and no query", func(t *testing.T) { + ctx := newOC() + params := &graphql.RawParams{ + Extensions: map[string]interface{}{ + "persistedQuery": map[string]interface{}{ + "sha256Hash": hash, + "version": 1, + }, + }, + } + cache := graphql.MapCache{ + hash: query, + } + err := extension.AutomaticPersistedQuery{cache}.MutateOperationParameters(ctx, params) + require.Nil(t, err) + + require.Equal(t, "{ me { name } }", params.Query) + }) + + t.Run("with malformed extension payload", func(t *testing.T) { + ctx := newOC() + params := &graphql.RawParams{ + Extensions: map[string]interface{}{ + "persistedQuery": "asdf", + }, + } + + err := extension.AutomaticPersistedQuery{graphql.MapCache{}}.MutateOperationParameters(ctx, params) + require.Equal(t, err.Message, "invalid APQ extension data") + }) + + t.Run("with invalid extension version", func(t *testing.T) { + ctx := newOC() + params := &graphql.RawParams{ + Extensions: map[string]interface{}{ + "persistedQuery": map[string]interface{}{ + "version": 2, + }, + }, + } + err := extension.AutomaticPersistedQuery{graphql.MapCache{}}.MutateOperationParameters(ctx, params) + require.Equal(t, err.Message, "unsupported APQ version") + }) + + t.Run("with hash mismatch", func(t *testing.T) { + ctx := newOC() + params := &graphql.RawParams{ + Query: query, + Extensions: map[string]interface{}{ + "persistedQuery": map[string]interface{}{ + "sha256Hash": "badhash", + "version": 1, + }, + }, + } + + err := extension.AutomaticPersistedQuery{graphql.MapCache{}}.MutateOperationParameters(ctx, params) + require.Equal(t, err.Message, "provided APQ hash does not match query") + }) +} + +func newOC() context.Context { + oc := &graphql.OperationContext{} + return graphql.WithOperationContext(context.Background(), oc) +} diff --git a/graphql/handler/extension/complexity.go b/graphql/handler/extension/complexity.go new file mode 100644 index 0000000..11272c1 --- /dev/null +++ b/graphql/handler/extension/complexity.go @@ -0,0 +1,89 @@ +package extension + +import ( + "context" + "fmt" + + "github.com/vektah/gqlparser/v2/gqlerror" + + "github.com/niko0xdev/gqlgen/complexity" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/errcode" +) + +const errComplexityLimit = "COMPLEXITY_LIMIT_EXCEEDED" + +// ComplexityLimit allows you to define a limit on query complexity +// +// If a query is submitted that exceeds the limit, a 422 status code will be returned. +type ComplexityLimit struct { + Func func(ctx context.Context, rc *graphql.OperationContext) int + + es graphql.ExecutableSchema +} + +var _ interface { + graphql.OperationContextMutator + graphql.HandlerExtension +} = &ComplexityLimit{} + +const complexityExtension = "ComplexityLimit" + +type ComplexityStats struct { + // The calculated complexity for this request + Complexity int + + // The complexity limit for this request returned by the extension func + ComplexityLimit int +} + +// FixedComplexityLimit sets a complexity limit that does not change +func FixedComplexityLimit(limit int) *ComplexityLimit { + return &ComplexityLimit{ + Func: func(ctx context.Context, rc *graphql.OperationContext) int { + return limit + }, + } +} + +func (c ComplexityLimit) ExtensionName() string { + return complexityExtension +} + +func (c *ComplexityLimit) Validate(schema graphql.ExecutableSchema) error { + if c.Func == nil { + return fmt.Errorf("ComplexityLimit func can not be nil") + } + c.es = schema + return nil +} + +func (c ComplexityLimit) MutateOperationContext(ctx context.Context, rc *graphql.OperationContext) *gqlerror.Error { + op := rc.Doc.Operations.ForName(rc.OperationName) + complexityCalcs := complexity.Calculate(c.es, op, rc.Variables) + + limit := c.Func(ctx, rc) + + rc.Stats.SetExtension(complexityExtension, &ComplexityStats{ + Complexity: complexityCalcs, + ComplexityLimit: limit, + }) + + if complexityCalcs > limit { + err := gqlerror.Errorf("operation has complexity %d, which exceeds the limit of %d", complexityCalcs, limit) + errcode.Set(err, errComplexityLimit) + return err + } + + return nil +} + +func GetComplexityStats(ctx context.Context) *ComplexityStats { + rc := graphql.GetOperationContext(ctx) + if rc == nil { + return nil + } + + s, _ := rc.Stats.GetExtension(complexityExtension).(*ComplexityStats) + return s +} diff --git a/graphql/handler/extension/complexity_test.go b/graphql/handler/extension/complexity_test.go new file mode 100644 index 0000000..b3c8da9 --- /dev/null +++ b/graphql/handler/extension/complexity_test.go @@ -0,0 +1,118 @@ +package extension_test + +import ( + "context" + "net/http" + "net/http/httptest" + "strings" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler/extension" + "github.com/niko0xdev/gqlgen/graphql/handler/testserver" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" +) + +func TestHandlerComplexity(t *testing.T) { + h := testserver.New() + h.Use(&extension.ComplexityLimit{ + Func: func(ctx context.Context, rc *graphql.OperationContext) int { + if rc.RawQuery == "{ ok: name }" { + return 4 + } + return 2 + }, + }) + h.AddTransport(&transport.POST{}) + var stats *extension.ComplexityStats + h.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + stats = extension.GetComplexityStats(ctx) + return next(ctx) + }) + + t.Run("below complexity limit", func(t *testing.T) { + stats = nil + h.SetCalculatedComplexity(2) + resp := doRequest(h, "POST", "/graphql", `{"query":"{ 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, 2, stats.Complexity) + }) + + t.Run("above complexity limit", func(t *testing.T) { + stats = nil + h.SetCalculatedComplexity(4) + resp := doRequest(h, "POST", "/graphql", `{"query":"{ name }"}`) + require.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + require.Equal(t, `{"errors":[{"message":"operation has complexity 4, which exceeds the limit of 2","extensions":{"code":"COMPLEXITY_LIMIT_EXCEEDED"}}],"data":null}`, resp.Body.String()) + + require.Equal(t, 2, stats.ComplexityLimit) + require.Equal(t, 4, stats.Complexity) + }) + + t.Run("within dynamic complexity limit", func(t *testing.T) { + stats = nil + h.SetCalculatedComplexity(4) + resp := doRequest(h, "POST", "/graphql", `{"query":"{ ok: name }"}`) + require.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + require.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + + require.Equal(t, 4, stats.ComplexityLimit) + require.Equal(t, 4, stats.Complexity) + }) +} + +func TestFixedComplexity(t *testing.T) { + h := testserver.New() + h.Use(extension.FixedComplexityLimit(2)) + h.AddTransport(&transport.POST{}) + + var stats *extension.ComplexityStats + h.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + stats = extension.GetComplexityStats(ctx) + return next(ctx) + }) + + t.Run("below complexity limit", func(t *testing.T) { + h.SetCalculatedComplexity(2) + resp := doRequest(h, "POST", "/graphql", `{"query":"{ 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, 2, stats.Complexity) + }) + + t.Run("above complexity limit", func(t *testing.T) { + h.SetCalculatedComplexity(4) + resp := doRequest(h, "POST", "/graphql", `{"query":"{ name }"}`) + require.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + require.Equal(t, `{"errors":[{"message":"operation has complexity 4, which exceeds the limit of 2","extensions":{"code":"COMPLEXITY_LIMIT_EXCEEDED"}}],"data":null}`, resp.Body.String()) + + 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 { + r := httptest.NewRequest(method, target, strings.NewReader(body)) + r.Header.Set("Content-Type", "application/json") + w := httptest.NewRecorder() + + handler.ServeHTTP(w, r) + return w +} diff --git a/graphql/handler/extension/introspection.go b/graphql/handler/extension/introspection.go new file mode 100644 index 0000000..a3ac18e --- /dev/null +++ b/graphql/handler/extension/introspection.go @@ -0,0 +1,30 @@ +package extension + +import ( + "context" + + "github.com/vektah/gqlparser/v2/gqlerror" + + "github.com/niko0xdev/gqlgen/graphql" +) + +// EnableIntrospection enables clients to reflect all of the types available on the graph. +type Introspection struct{} + +var _ interface { + graphql.OperationContextMutator + graphql.HandlerExtension +} = Introspection{} + +func (c Introspection) ExtensionName() string { + return "Introspection" +} + +func (c Introspection) Validate(schema graphql.ExecutableSchema) error { + return nil +} + +func (c Introspection) MutateOperationContext(ctx context.Context, rc *graphql.OperationContext) *gqlerror.Error { + rc.DisableIntrospection = false + return nil +} diff --git a/graphql/handler/extension/introspection_test.go b/graphql/handler/extension/introspection_test.go new file mode 100644 index 0000000..f0958ba --- /dev/null +++ b/graphql/handler/extension/introspection_test.go @@ -0,0 +1,18 @@ +package extension + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/graphql" +) + +func TestIntrospection(t *testing.T) { + rc := &graphql.OperationContext{ + DisableIntrospection: true, + } + require.Nil(t, Introspection{}.MutateOperationContext(context.Background(), rc)) + require.Equal(t, false, rc.DisableIntrospection) +} diff --git a/graphql/handler/lru/lru.go b/graphql/handler/lru/lru.go new file mode 100644 index 0000000..55b941c --- /dev/null +++ b/graphql/handler/lru/lru.go @@ -0,0 +1,33 @@ +package lru + +import ( + "context" + + lru "github.com/hashicorp/golang-lru/v2" + + "github.com/niko0xdev/gqlgen/graphql" +) + +type LRU struct { + lru *lru.Cache[string, any] +} + +var _ graphql.Cache = &LRU{} + +func New(size int) *LRU { + cache, err := lru.New[string, any](size) + if err != nil { + // An error is only returned for non-positive cache size + // and we already checked for that. + panic("unexpected error creating cache: " + err.Error()) + } + return &LRU{cache} +} + +func (l LRU) Get(ctx context.Context, key string) (value interface{}, ok bool) { + return l.lru.Get(key) +} + +func (l LRU) Add(ctx context.Context, key string, value interface{}) { + l.lru.Add(key, value) +} diff --git a/graphql/handler/server.go b/graphql/handler/server.go new file mode 100644 index 0000000..2c251d4 --- /dev/null +++ b/graphql/handler/server.go @@ -0,0 +1,187 @@ +package handler + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + "time" + + "github.com/vektah/gqlparser/v2/gqlerror" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/executor" + "github.com/niko0xdev/gqlgen/graphql/handler/extension" + "github.com/niko0xdev/gqlgen/graphql/handler/lru" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" +) + +type ( + Server struct { + transports []graphql.Transport + exec *executor.Executor + } +) + +func New(es graphql.ExecutableSchema) *Server { + return &Server{ + exec: executor.New(es), + } +} + +func NewDefaultServer(es graphql.ExecutableSchema) *Server { + srv := New(es) + + srv.AddTransport(transport.Websocket{ + KeepAlivePingInterval: 10 * time.Second, + }) + srv.AddTransport(transport.Options{}) + srv.AddTransport(transport.GET{}) + srv.AddTransport(transport.POST{}) + srv.AddTransport(transport.MultipartForm{}) + + srv.SetQueryCache(lru.New(1000)) + + srv.Use(extension.Introspection{}) + srv.Use(extension.AutomaticPersistedQuery{ + Cache: lru.New(100), + }) + + return srv +} + +func (s *Server) AddTransport(transport graphql.Transport) { + s.transports = append(s.transports, transport) +} + +func (s *Server) SetErrorPresenter(f graphql.ErrorPresenterFunc) { + s.exec.SetErrorPresenter(f) +} + +func (s *Server) SetRecoverFunc(f graphql.RecoverFunc) { + s.exec.SetRecoverFunc(f) +} + +func (s *Server) SetQueryCache(cache graphql.Cache) { + s.exec.SetQueryCache(cache) +} + +func (s *Server) Use(extension graphql.HandlerExtension) { + s.exec.Use(extension) +} + +// AroundFields is a convenience method for creating an extension that only implements field middleware +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) +} + +// AroundResponses is a convenience method for creating an extension that only implements response middleware +func (s *Server) AroundResponses(f graphql.ResponseMiddleware) { + s.exec.AroundResponses(f) +} + +func (s *Server) getTransport(r *http.Request) graphql.Transport { + for _, t := range s.transports { + if t.Supports(r) { + return t + } + } + return nil +} + +func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { + defer func() { + if err := recover(); err != nil { + err := s.exec.PresentRecoveredError(r.Context(), err) + gqlErr, _ := err.(*gqlerror.Error) + resp := &graphql.Response{Errors: []*gqlerror.Error{gqlErr}} + b, _ := json.Marshal(resp) + w.WriteHeader(http.StatusUnprocessableEntity) + w.Write(b) + } + }() + + r = r.WithContext(graphql.StartOperationTrace(r.Context())) + + transport := s.getTransport(r) + if transport == nil { + sendErrorf(w, http.StatusBadRequest, "transport not supported") + return + } + + transport.Do(w, r, s.exec) +} + +func sendError(w http.ResponseWriter, code int, errors ...*gqlerror.Error) { + w.WriteHeader(code) + b, err := json.Marshal(&graphql.Response{Errors: errors}) + if err != nil { + panic(err) + } + w.Write(b) +} + +func sendErrorf(w http.ResponseWriter, code int, format string, args ...interface{}) { + sendError(w, code, &gqlerror.Error{Message: fmt.Sprintf(format, args...)}) +} + +type OperationFunc func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler + +func (r OperationFunc) ExtensionName() string { + return "InlineOperationFunc" +} + +func (r OperationFunc) Validate(schema graphql.ExecutableSchema) error { + if r == nil { + return fmt.Errorf("OperationFunc can not be nil") + } + return nil +} + +func (r OperationFunc) InterceptOperation(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler { + return r(ctx, next) +} + +type ResponseFunc func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response + +func (r ResponseFunc) ExtensionName() string { + return "InlineResponseFunc" +} + +func (r ResponseFunc) Validate(schema graphql.ExecutableSchema) error { + if r == nil { + return fmt.Errorf("ResponseFunc can not be nil") + } + return nil +} + +func (r ResponseFunc) InterceptResponse(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + return r(ctx, next) +} + +type FieldFunc func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) + +func (f FieldFunc) ExtensionName() string { + return "InlineFieldFunc" +} + +func (f FieldFunc) Validate(schema graphql.ExecutableSchema) error { + if f == nil { + return fmt.Errorf("FieldFunc can not be nil") + } + return nil +} + +func (f FieldFunc) InterceptField(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + return f(ctx, next) +} diff --git a/graphql/handler/server_test.go b/graphql/handler/server_test.go new file mode 100644 index 0000000..ca0f5ef --- /dev/null +++ b/graphql/handler/server_test.go @@ -0,0 +1,203 @@ +package handler_test + +import ( + "context" + "fmt" + "net/http" + "net/http/httptest" + "net/url" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/v2/ast" + "github.com/vektah/gqlparser/v2/gqlerror" + "github.com/vektah/gqlparser/v2/parser" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler/testserver" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" +) + +func TestServer(t *testing.T) { + srv := testserver.New() + srv.AddTransport(&transport.GET{}) + + t.Run("returns an error if no transport matches", func(t *testing.T) { + resp := post(srv, "/foo", "application/json") + assert.Equal(t, http.StatusBadRequest, resp.Code) + assert.Equal(t, `{"errors":[{"message":"transport not supported"}],"data":null}`, resp.Body.String()) + }) + + t.Run("calls query on executable schema", func(t *testing.T) { + resp := get(srv, "/foo?query={name}") + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + }) + + t.Run("mutations are forbidden", func(t *testing.T) { + resp := get(srv, "/foo?query=mutation{name}") + assert.Equal(t, http.StatusNotAcceptable, resp.Code) + assert.Equal(t, `{"errors":[{"message":"GET requests only allow query operations"}],"data":null}`, resp.Body.String()) + }) + + t.Run("subscriptions are forbidden", func(t *testing.T) { + resp := get(srv, "/foo?query=subscription{name}") + assert.Equal(t, http.StatusNotAcceptable, resp.Code) + assert.Equal(t, `{"errors":[{"message":"GET requests only allow query operations"}],"data":null}`, resp.Body.String()) + }) + + t.Run("invokes operation middleware in order", func(t *testing.T) { + var calls []string + srv.AroundOperations(func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler { + calls = append(calls, "first") + return next(ctx) + }) + srv.AroundOperations(func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler { + calls = append(calls, "second") + return next(ctx) + }) + + resp := get(srv, "/foo?query={name}") + assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + assert.Equal(t, []string{"first", "second"}, calls) + }) + + t.Run("invokes response middleware in order", func(t *testing.T) { + var calls []string + srv.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + calls = append(calls, "first") + return next(ctx) + }) + srv.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + calls = append(calls, "second") + return next(ctx) + }) + + resp := get(srv, "/foo?query={name}") + assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + assert.Equal(t, []string{"first", "second"}, calls) + }) + + t.Run("invokes field middleware in order", func(t *testing.T) { + var calls []string + srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + calls = append(calls, "first") + return next(ctx) + }) + srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + calls = append(calls, "second") + return next(ctx) + }) + + resp := get(srv, "/foo?query={name}") + assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + assert.Equal(t, []string{"first", "second"}, calls) + }) + + t.Run("get query parse error in AroundResponses", func(t *testing.T) { + var errors1 gqlerror.List + var errors2 gqlerror.List + srv.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + resp := next(ctx) + errors1 = graphql.GetErrors(ctx) + errors2 = resp.Errors + return resp + }) + + resp := get(srv, "/foo?query=invalid") + assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + assert.Equal(t, 1, len(errors1)) + assert.Equal(t, 1, len(errors2)) + }) + + t.Run("query caching", func(t *testing.T) { + ctx := context.Background() + cache := &graphql.MapCache{} + srv.SetQueryCache(cache) + qry := `query Foo {name}` + + t.Run("cache miss populates cache", func(t *testing.T) { + resp := get(srv, "/foo?query="+url.QueryEscape(qry)) + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + + cacheDoc, ok := cache.Get(ctx, qry) + require.True(t, ok) + require.Equal(t, "Foo", cacheDoc.(*ast.QueryDocument).Operations[0].Name) + }) + + t.Run("cache hits use document from cache", func(t *testing.T) { + doc, err := parser.ParseQuery(&ast.Source{Input: `query Bar {name}`}) + require.Nil(t, err) + cache.Add(ctx, qry, doc) + + resp := get(srv, "/foo?query="+url.QueryEscape(qry)) + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + + cacheDoc, ok := cache.Get(ctx, qry) + require.True(t, ok) + require.Equal(t, "Bar", cacheDoc.(*ast.QueryDocument).Operations[0].Name) + }) + }) +} + +func TestErrorServer(t *testing.T) { + srv := testserver.NewError() + srv.AddTransport(&transport.GET{}) + + t.Run("get resolver error in AroundResponses", func(t *testing.T) { + var errors1 gqlerror.List + var errors2 gqlerror.List + srv.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { + resp := next(ctx) + errors1 = graphql.GetErrors(ctx) + errors2 = resp.Errors + return resp + }) + + resp := get(srv, "/foo?query={name}") + assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + assert.Equal(t, 1, len(errors1)) + assert.Equal(t, 1, len(errors2)) + }) +} + +type panicTransport struct{} + +func (t panicTransport) Supports(r *http.Request) bool { + return true +} + +func (t 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() + + handler.ServeHTTP(w, r) + return w +} + +func post(handler http.Handler, target, contentType string) *httptest.ResponseRecorder { + r := httptest.NewRequest("POST", target, nil) + r.Header.Set("Content-Type", contentType) + w := httptest.NewRecorder() + + handler.ServeHTTP(w, r) + return w +} diff --git a/graphql/handler/testserver/testserver.go b/graphql/handler/testserver/testserver.go new file mode 100644 index 0000000..95caf83 --- /dev/null +++ b/graphql/handler/testserver/testserver.go @@ -0,0 +1,174 @@ +package testserver + +import ( + "context" + "fmt" + "time" + + "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" +) + +// 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() *TestServer { + next := make(chan struct{}) + completeSubscription := make(chan struct{}) + + schema := gqlparser.MustLoadSchema(&ast.Source{Input: ` + type Query { + name: String! + find(id: Int!): String! + } + type Mutation { + name: String! + } + type Subscription { + name: String! + } + `}) + + srv := &TestServer{ + next: next, + completeSubscription: completeSubscription, + } + + srv.Server = handler.New(&graphql.ExecutableSchemaMock{ + ExecFunc: func(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + switch rc.Operation.Operation { + case ast.Query: + ran := false + return func(ctx context.Context) *graphql.Response { + if ran { + return nil + } + ran = true + // Field execution happens inside the generated code, lets simulate some of it. + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ + Object: "Query", + Field: graphql.CollectedField{ + Field: &ast.Field{ + Name: "name", + Alias: "name", + Definition: schema.Types["Query"].Fields.ForName("name"), + }, + }, + }) + res, err := graphql.GetOperationContext(ctx).ResolverMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return &graphql.Response{Data: []byte(`{"name":"test"}`)}, nil + }) + if err != nil { + panic(err) + } + return res.(*graphql.Response) + } + case ast.Mutation: + return graphql.OneShot(graphql.ErrorResponse(ctx, "mutations are not supported")) + case ast.Subscription: + return func(context context.Context) *graphql.Response { + select { + case <-ctx.Done(): + return nil + case <-next: + return &graphql.Response{ + Data: []byte(`{"name":"test"}`), + } + case <-completeSubscription: + return nil + } + } + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } + }, + SchemaFunc: func() *ast.Schema { + return schema + }, + ComplexityFunc: func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (i int, b bool) { + return srv.complexity, true + }, + }) + return srv +} + +// NewError provides a server for use in resolver error 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 NewError() *TestServer { + next := make(chan struct{}) + + schema := gqlparser.MustLoadSchema(&ast.Source{Input: ` + type Query { + name: String! + } + `}) + + srv := &TestServer{ + next: next, + } + + srv.Server = handler.New(&graphql.ExecutableSchemaMock{ + ExecFunc: func(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + switch rc.Operation.Operation { + case ast.Query: + ran := false + return func(ctx context.Context) *graphql.Response { + if ran { + return nil + } + ran = true + + graphql.AddError(ctx, fmt.Errorf("resolver error")) + + return &graphql.Response{ + Data: []byte(`null`), + } + } + case ast.Mutation: + return graphql.OneShot(graphql.ErrorResponse(ctx, "mutations are not supported")) + case ast.Subscription: + return graphql.OneShot(graphql.ErrorResponse(ctx, "subscription are not supported")) + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } + }, + SchemaFunc: func() *ast.Schema { + return schema + }, + ComplexityFunc: func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (i int, b bool) { + return srv.complexity, true + }, + }) + return srv +} + +type TestServer struct { + *handler.Server + next chan struct{} + completeSubscription chan struct{} + complexity int +} + +func (s *TestServer) SendNextSubscriptionMessage() { + select { + case s.next <- struct{}{}: + case <-time.After(1 * time.Second): + fmt.Println("WARNING: no active subscription") + } +} + +func (s *TestServer) SendCompleteSubscriptionMessage() { + select { + case s.completeSubscription <- struct{}{}: + case <-time.After(1 * time.Second): + fmt.Println("WARNING: no active subscription") + } +} + +func (s *TestServer) SetCalculatedComplexity(complexity int) { + s.complexity = complexity +} diff --git a/graphql/handler/transport/error.go b/graphql/handler/transport/error.go new file mode 100644 index 0000000..dba4fbe --- /dev/null +++ b/graphql/handler/transport/error.go @@ -0,0 +1,27 @@ +package transport + +import ( + "encoding/json" + "fmt" + "net/http" + + "github.com/vektah/gqlparser/v2/gqlerror" + + "github.com/niko0xdev/gqlgen/graphql" +) + +// SendError sends a best effort error to a raw response writer. It assumes the client can understand the standard +// json error response +func SendError(w http.ResponseWriter, code int, errors ...*gqlerror.Error) { + w.WriteHeader(code) + b, err := json.Marshal(&graphql.Response{Errors: errors}) + if err != nil { + panic(err) + } + w.Write(b) +} + +// SendErrorf wraps SendError to add formatted messages +func SendErrorf(w http.ResponseWriter, code int, format string, args ...interface{}) { + SendError(w, code, &gqlerror.Error{Message: fmt.Sprintf(format, args...)}) +} diff --git a/graphql/handler/transport/headers.go b/graphql/handler/transport/headers.go new file mode 100644 index 0000000..bc4e572 --- /dev/null +++ b/graphql/handler/transport/headers.go @@ -0,0 +1,17 @@ +package transport + +import "net/http" + +func writeHeaders(w http.ResponseWriter, headers map[string][]string) { + if len(headers) == 0 { + headers = map[string][]string{ + "Content-Type": {"application/json"}, + } + } + + for key, values := range headers { + for _, value := range values { + w.Header().Add(key, value) + } + } +} diff --git a/graphql/handler/transport/headers_test.go b/graphql/handler/transport/headers_test.go new file mode 100644 index 0000000..1be52e0 --- /dev/null +++ b/graphql/handler/transport/headers_test.go @@ -0,0 +1,220 @@ +package transport_test + +import ( + "context" + "net/http" + "net/http/httptest" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/handler/testserver" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" +) + +func TestHeadersWithPOST(t *testing.T) { + t.Run("Headers not set", func(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.POST{}) + + resp := doRequest(h, "POST", "/graphql", `{"query":"{ name }"}`, "application/json") + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, 1, len(resp.Header())) + assert.Equal(t, "application/json", resp.Header().Get("Content-Type")) + }) + + t.Run("Headers set", func(t *testing.T) { + headers := map[string][]string{ + "Content-Type": {"application/json; charset: utf8"}, + "Other-Header": {"dummy-post", "another-one"}, + } + + h := testserver.New() + h.AddTransport(transport.POST{ResponseHeaders: headers}) + + resp := doRequest(h, "POST", "/graphql", `{"query":"{ name }"}`, "application/json") + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, 2, len(resp.Header())) + assert.Equal(t, "application/json; charset: utf8", resp.Header().Get("Content-Type")) + assert.Equal(t, "dummy-post", resp.Header().Get("Other-Header")) + assert.Equal(t, "another-one", resp.Header().Values("Other-Header")[1]) + }) +} + +func TestHeadersWithGET(t *testing.T) { + t.Run("Headers not set", func(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.GET{}) + + resp := doRequest(h, "GET", "/graphql?query={name}", "", "application/json") + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, 1, len(resp.Header())) + assert.Equal(t, "application/json", resp.Header().Get("Content-Type")) + }) + + t.Run("Headers set", func(t *testing.T) { + headers := map[string][]string{ + "Content-Type": {"application/json; charset: utf8"}, + "Other-Header": {"dummy-get"}, + } + + h := testserver.New() + h.AddTransport(transport.GET{ResponseHeaders: headers}) + + resp := doRequest(h, "GET", "/graphql?query={name}", "", "application/json") + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, 2, len(resp.Header())) + assert.Equal(t, "application/json; charset: utf8", resp.Header().Get("Content-Type")) + assert.Equal(t, "dummy-get", resp.Header().Get("Other-Header")) + }) +} + +func TestHeadersWithGRAPHQL(t *testing.T) { + t.Run("Headers not set", func(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.GRAPHQL{}) + + resp := doRequest(h, "POST", "/graphql", `{ name }`, "application/graphql") + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, 1, len(resp.Header())) + assert.Equal(t, "application/json", resp.Header().Get("Content-Type")) + }) + + t.Run("Headers set", func(t *testing.T) { + headers := map[string][]string{ + "Content-Type": {"application/json; charset: utf8"}, + "Other-Header": {"dummy-get-qraphql"}, + } + + h := testserver.New() + h.AddTransport(transport.GRAPHQL{ResponseHeaders: headers}) + + resp := doRequest(h, "POST", "/graphql", `{ name }`, "application/graphql") + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, 2, len(resp.Header())) + assert.Equal(t, "application/json; charset: utf8", resp.Header().Get("Content-Type")) + assert.Equal(t, "dummy-get-qraphql", resp.Header().Get("Other-Header")) + }) +} + +func TestHeadersWithFormUrlEncoded(t *testing.T) { + t.Run("Headers not set", func(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.UrlEncodedForm{}) + + resp := doRequest(h, "POST", "/graphql", `{ name }`, "application/x-www-form-urlencoded") + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, 1, len(resp.Header())) + assert.Equal(t, "application/json", resp.Header().Get("Content-Type")) + }) + + t.Run("Headers set", func(t *testing.T) { + headers := map[string][]string{ + "Content-Type": {"application/json; charset: utf8"}, + "Other-Header": {"dummy-get-urlencoded-form"}, + } + + h := testserver.New() + h.AddTransport(transport.UrlEncodedForm{ResponseHeaders: headers}) + + resp := doRequest(h, "POST", "/graphql", `{ name }`, "application/x-www-form-urlencoded") + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, 2, len(resp.Header())) + assert.Equal(t, "application/json; charset: utf8", resp.Header().Get("Content-Type")) + assert.Equal(t, "dummy-get-urlencoded-form", resp.Header().Get("Other-Header")) + }) +} + +func TestHeadersWithMULTIPART(t *testing.T) { + t.Run("Headers not set", func(t *testing.T) { + es := &graphql.ExecutableSchemaMock{ + ExecFunc: func(ctx context.Context) graphql.ResponseHandler { + return graphql.OneShot(graphql.ErrorResponse(ctx, "not implemented")) + }, + SchemaFunc: func() *ast.Schema { + return gqlparser.MustLoadSchema(&ast.Source{Input: ` + type Mutation { + singleUpload(file: Upload!): String! + } + scalar Upload + `}) + }, + } + + h := handler.New(es) + h.AddTransport(transport.MultipartForm{}) + + es.ExecFunc = func(ctx context.Context) graphql.ResponseHandler { + return graphql.OneShot(&graphql.Response{Data: []byte(`{"singleUpload":"test"}`)}) + } + + operations := `{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) }", "variables": { "file": null } }` + mapData := `{ "0": ["variables.file"] }` + files := []file{ + { + mapKey: "0", + name: "a.txt", + content: "test1", + contentType: "text/plain", + }, + } + req := createUploadRequest(t, operations, mapData, files) + + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + assert.Equal(t, 1, len(resp.Header())) + assert.Equal(t, "application/json", resp.Header().Get("Content-Type")) + }) + + t.Run("Headers set", func(t *testing.T) { + es := &graphql.ExecutableSchemaMock{ + ExecFunc: func(ctx context.Context) graphql.ResponseHandler { + return graphql.OneShot(graphql.ErrorResponse(ctx, "not implemented")) + }, + SchemaFunc: func() *ast.Schema { + return gqlparser.MustLoadSchema(&ast.Source{Input: ` + type Mutation { + singleUpload(file: Upload!): String! + } + scalar Upload + `}) + }, + } + + h := handler.New(es) + headers := map[string][]string{ + "Content-Type": {"application/json; charset: utf8"}, + "Other-Header": {"dummy-multipart"}, + } + h.AddTransport(transport.MultipartForm{ResponseHeaders: headers}) + + es.ExecFunc = func(ctx context.Context) graphql.ResponseHandler { + return graphql.OneShot(&graphql.Response{Data: []byte(`{"singleUpload":"test"}`)}) + } + + operations := `{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) }", "variables": { "file": null } }` + mapData := `{ "0": ["variables.file"] }` + files := []file{ + { + mapKey: "0", + name: "a.txt", + content: "test1", + contentType: "text/plain", + }, + } + req := createUploadRequest(t, operations, mapData, files) + + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + assert.Equal(t, 2, len(resp.Header())) + assert.Equal(t, "application/json; charset: utf8", resp.Header().Get("Content-Type")) + assert.Equal(t, "dummy-multipart", resp.Header().Get("Other-Header")) + }) +} diff --git a/graphql/handler/transport/http_form_multipart.go b/graphql/handler/transport/http_form_multipart.go new file mode 100644 index 0000000..96c3969 --- /dev/null +++ b/graphql/handler/transport/http_form_multipart.go @@ -0,0 +1,222 @@ +package transport + +import ( + "encoding/json" + "io" + "mime" + "net/http" + "os" + + "github.com/niko0xdev/gqlgen/graphql" +) + +// MultipartForm the Multipart request spec https://github.com/jaydenseric/graphql-multipart-request-spec +type MultipartForm struct { + // MaxUploadSize sets the maximum number of bytes used to parse a request body + // as multipart/form-data. + MaxUploadSize int64 + + // MaxMemory defines the maximum number of bytes used to parse a request body + // as multipart/form-data in memory, with the remainder stored on disk in + // temporary files. + MaxMemory int64 + + // Map of all headers that are added to graphql response. If not + // set, only one header: Content-Type: application/json will be set. + ResponseHeaders map[string][]string +} + +var _ graphql.Transport = MultipartForm{} + +func (f MultipartForm) Supports(r *http.Request) bool { + if r.Header.Get("Upgrade") != "" { + return false + } + + mediaType, _, err := mime.ParseMediaType(r.Header.Get("Content-Type")) + if err != nil { + return false + } + + return r.Method == "POST" && mediaType == "multipart/form-data" +} + +func (f MultipartForm) maxUploadSize() int64 { + if f.MaxUploadSize == 0 { + return 32 << 20 + } + return f.MaxUploadSize +} + +func (f MultipartForm) maxMemory() int64 { + if f.MaxMemory == 0 { + return 32 << 20 + } + return f.MaxMemory +} + +func (f MultipartForm) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecutor) { + writeHeaders(w, f.ResponseHeaders) + + start := graphql.Now() + + var err error + if r.ContentLength > f.maxUploadSize() { + writeJsonError(w, "failed to parse multipart form, request body too large") + return + } + r.Body = http.MaxBytesReader(w, r.Body, f.maxUploadSize()) + defer r.Body.Close() + + mr, err := r.MultipartReader() + if err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonError(w, "failed to parse multipart form") + return + } + + part, err := mr.NextPart() + if err != nil || part.FormName() != "operations" { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonError(w, "first part must be operations") + return + } + + var params graphql.RawParams + if err = jsonDecode(part, ¶ms); err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonError(w, "operations form field could not be decoded") + return + } + + part, err = mr.NextPart() + if err != nil || part.FormName() != "map" { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonError(w, "second part must be map") + return + } + + uploadsMap := map[string][]string{} + if err = json.NewDecoder(part).Decode(&uploadsMap); err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonError(w, "map form field could not be decoded") + return + } + + for { + part, err = mr.NextPart() + if err == io.EOF { + break + } else if err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonErrorf(w, "failed to parse part") + return + } + + key := part.FormName() + filename := part.FileName() + contentType := part.Header.Get("Content-Type") + + paths := uploadsMap[key] + if len(paths) == 0 { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonErrorf(w, "invalid empty operations paths list for key %s", key) + return + } + delete(uploadsMap, key) + + var upload graphql.Upload + if r.ContentLength < f.maxMemory() { + fileBytes, err := io.ReadAll(part) + if err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonErrorf(w, "failed to read file for key %s", key) + return + } + for _, path := range paths { + upload = graphql.Upload{ + File: &bytesReader{s: &fileBytes, i: 0}, + Size: int64(len(fileBytes)), + Filename: filename, + ContentType: contentType, + } + + if err := params.AddUpload(upload, key, path); err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonGraphqlError(w, err) + return + } + } + } else { + tmpFile, err := os.CreateTemp(os.TempDir(), "gqlgen-") + if err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonErrorf(w, "failed to create temp file for key %s", key) + return + } + tmpName := tmpFile.Name() + defer func() { + _ = os.Remove(tmpName) + }() + fileSize, err := io.Copy(tmpFile, part) + if err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + if err := tmpFile.Close(); err != nil { + writeJsonErrorf(w, "failed to copy to temp file and close temp file for key %s", key) + return + } + writeJsonErrorf(w, "failed to copy to temp file for key %s", key) + return + } + if err := tmpFile.Close(); err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonErrorf(w, "failed to close temp file for key %s", key) + return + } + for _, path := range paths { + pathTmpFile, err := os.Open(tmpName) + if err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonErrorf(w, "failed to open temp file for key %s", key) + return + } + defer pathTmpFile.Close() + upload = graphql.Upload{ + File: pathTmpFile, + Size: fileSize, + Filename: filename, + ContentType: contentType, + } + + if err := params.AddUpload(upload, key, path); err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonGraphqlError(w, err) + return + } + } + } + } + + for key := range uploadsMap { + w.WriteHeader(http.StatusUnprocessableEntity) + writeJsonErrorf(w, "failed to get key %s from form", key) + return + } + + params.Headers = r.Header + + params.ReadTime = graphql.TraceTiming{ + Start: start, + End: graphql.Now(), + } + + rc, gerr := exec.CreateOperationContext(r.Context(), ¶ms) + if gerr != nil { + resp := exec.DispatchError(graphql.WithOperationContext(r.Context(), rc), gerr) + w.WriteHeader(statusFor(gerr)) + writeJson(w, resp) + return + } + responses, ctx := exec.DispatchOperation(r.Context(), rc) + writeJson(w, responses(ctx)) +} diff --git a/graphql/handler/transport/http_form_multipart_test.go b/graphql/handler/transport/http_form_multipart_test.go new file mode 100644 index 0000000..3d79c09 --- /dev/null +++ b/graphql/handler/transport/http_form_multipart_test.go @@ -0,0 +1,307 @@ +package transport_test + +import ( + "bytes" + "context" + "fmt" + "io" + "mime/multipart" + "net/http" + "net/http/httptest" + "net/textproto" + "testing" + + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" +) + +func TestFileUpload(t *testing.T) { + es := &graphql.ExecutableSchemaMock{ + ExecFunc: func(ctx context.Context) graphql.ResponseHandler { + return graphql.OneShot(graphql.ErrorResponse(ctx, "not implemented")) + }, + SchemaFunc: func() *ast.Schema { + return gqlparser.MustLoadSchema(&ast.Source{Input: ` + type Mutation { + singleUpload(file: Upload!): String! + singleUploadWithPayload(req: UploadFile!): String! + multipleUpload(files: [Upload!]!): String! + multipleUploadWithPayload(req: [UploadFile!]!): String! + } + scalar Upload + scalar UploadFile + `}) + }, + } + + h := handler.New(es) + multipartForm := transport.MultipartForm{} + h.AddTransport(&multipartForm) + + t.Run("valid single file upload", func(t *testing.T) { + es.ExecFunc = func(ctx context.Context) graphql.ResponseHandler { + op := graphql.GetOperationContext(ctx).Operation + require.Equal(t, len(op.VariableDefinitions), 1) + require.Equal(t, op.VariableDefinitions[0].Variable, "file") + return graphql.OneShot(&graphql.Response{Data: []byte(`{"singleUpload":"test"}`)}) + } + + operations := `{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) }", "variables": { "file": null } }` + mapData := `{ "0": ["variables.file"] }` + files := []file{ + { + mapKey: "0", + name: "a.txt", + content: "test1", + contentType: "text/plain", + }, + } + req := createUploadRequest(t, operations, mapData, files) + + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + require.Equal(t, `{"data":{"singleUpload":"test"}}`, resp.Body.String()) + }) + + t.Run("valid single file upload with payload", func(t *testing.T) { + es.ExecFunc = func(ctx context.Context) graphql.ResponseHandler { + op := graphql.GetOperationContext(ctx).Operation + require.Equal(t, len(op.VariableDefinitions), 1) + require.Equal(t, op.VariableDefinitions[0].Variable, "req") + return graphql.OneShot(&graphql.Response{Data: []byte(`{"singleUploadWithPayload":"test"}`)}) + } + + operations := `{ "query": "mutation ($req: UploadFile!) { singleUploadWithPayload(req: $req) }", "variables": { "req": {"file": null, "id": 1 } } }` + mapData := `{ "0": ["variables.req.file"] }` + files := []file{ + { + mapKey: "0", + name: "a.txt", + content: "test1", + contentType: "text/plain", + }, + } + req := createUploadRequest(t, operations, mapData, files) + + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + require.Equal(t, `{"data":{"singleUploadWithPayload":"test"}}`, resp.Body.String()) + }) + + t.Run("valid file list upload", func(t *testing.T) { + es.ExecFunc = func(ctx context.Context) graphql.ResponseHandler { + op := graphql.GetOperationContext(ctx).Operation + require.Equal(t, len(op.VariableDefinitions), 1) + require.Equal(t, op.VariableDefinitions[0].Variable, "files") + return graphql.OneShot(&graphql.Response{Data: []byte(`{"multipleUpload":[{"id":1},{"id":2}]}`)}) + } + + operations := `{ "query": "mutation($files: [Upload!]!) { multipleUpload(files: $files) }", "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", + }, + } + req := createUploadRequest(t, operations, mapData, files) + + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + require.Equal(t, `{"data":{"multipleUpload":[{"id":1},{"id":2}]}}`, resp.Body.String()) + }) + + t.Run("valid file list upload with payload", func(t *testing.T) { + es.ExecFunc = func(ctx context.Context) graphql.ResponseHandler { + op := graphql.GetOperationContext(ctx).Operation + require.Equal(t, len(op.VariableDefinitions), 1) + require.Equal(t, op.VariableDefinitions[0].Variable, "req") + return graphql.OneShot(&graphql.Response{Data: []byte(`{"multipleUploadWithPayload":[{"id":1},{"id":2}]}`)}) + } + + operations := `{ "query": "mutation($req: [UploadFile!]!) { multipleUploadWithPayload(req: $req) }", "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", + }, + } + req := createUploadRequest(t, operations, mapData, files) + + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusOK, resp.Code) + require.Equal(t, `{"data":{"multipleUploadWithPayload":[{"id":1},{"id":2}]}}`, resp.Body.String()) + }) + + t.Run("valid file list upload with payload and file reuse", func(t *testing.T) { + test := func(uploadMaxMemory int64) { + es.ExecFunc = func(ctx context.Context) graphql.ResponseHandler { + op := graphql.GetOperationContext(ctx).Operation + require.Equal(t, len(op.VariableDefinitions), 1) + require.Equal(t, op.VariableDefinitions[0].Variable, "req") + return graphql.OneShot(&graphql.Response{Data: []byte(`{"multipleUploadWithPayload":[{"id":1},{"id":2}]}`)}) + } + multipartForm.MaxMemory = uploadMaxMemory + + operations := `{ "query": "mutation($req: [UploadFile!]!) { multipleUploadWithPayload(req: $req) }", "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", + }, + } + req := createUploadRequest(t, operations, mapData, files) + + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + require.Equal(t, `{"data":{"multipleUploadWithPayload":[{"id":1},{"id":2}]}}`, resp.Body.String()) + } + + t.Run("payload smaller than UploadMaxMemory, stored in memory", func(t *testing.T) { + test(5000) + }) + + t.Run("payload bigger than UploadMaxMemory, persisted to disk", func(t *testing.T) { + test(2) + }) + }) + + validOperations := `{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) }", "variables": { "file": null } }` + validMap := `{ "0": ["variables.file"] }` + validFiles := []file{ + { + mapKey: "0", + name: "a.txt", + content: "test1", + contentType: "text/plain", + }, + } + + t.Run("failed invalid multipart", func(t *testing.T) { + req := &http.Request{ + Method: "POST", + Header: http.Header{"Content-Type": {`multipart/form-data; boundary="foo123"`}}, + Body: io.NopCloser(new(bytes.Buffer)), + } + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + require.Equal(t, `{"errors":[{"message":"first part must be operations"}],"data":null}`, resp.Body.String()) + }) + + t.Run("fail parse operation", func(t *testing.T) { + operations := `invalid operation` + req := createUploadRequest(t, operations, validMap, validFiles) + + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + require.Equal(t, `{"errors":[{"message":"operations form field could not be decoded"}],"data":null}`, resp.Body.String()) + }) + + t.Run("fail parse map", func(t *testing.T) { + mapData := `invalid map` + req := createUploadRequest(t, validOperations, mapData, validFiles) + + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + require.Equal(t, `{"errors":[{"message":"map form field could not be decoded"}],"data":null}`, resp.Body.String()) + }) + + t.Run("fail missing file", func(t *testing.T) { + var files []file + req := createUploadRequest(t, validOperations, validMap, files) + + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + require.Equal(t, `{"errors":[{"message":"failed to get key 0 from form"}],"data":null}`, resp.Body.String()) + }) + + t.Run("fail map entry with invalid operations paths prefix", func(t *testing.T) { + mapData := `{ "0": ["var.file"] }` + req := createUploadRequest(t, validOperations, mapData, validFiles) + + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + require.Equal(t, `{"errors":[{"message":"invalid operations paths for key 0"}],"data":null}`, resp.Body.String()) + }) + + t.Run("fail parse request big body", func(t *testing.T) { + multipartForm.MaxUploadSize = 2 + req := createUploadRequest(t, validOperations, validMap, validFiles) + + resp := httptest.NewRecorder() + h.ServeHTTP(resp, req) + require.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + require.Equal(t, `{"errors":[{"message":"failed to parse multipart form, request body too large"}],"data":null}`, resp.Body.String()) + }) +} + +type file struct { + mapKey string + name string + content string + contentType string +} + +func createUploadRequest(t *testing.T, 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", "/graphql", bodyBuf) + require.NoError(t, err) + + req.Header.Set("Content-Type", bodyWriter.FormDataContentType()) + return req +} diff --git a/graphql/handler/transport/http_form_urlencode_test.go b/graphql/handler/transport/http_form_urlencode_test.go new file mode 100644 index 0000000..b165655 --- /dev/null +++ b/graphql/handler/transport/http_form_urlencode_test.go @@ -0,0 +1,96 @@ +package transport_test + +import ( + "fmt" + "net/http" + "net/http/httptest" + "strings" + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/niko0xdev/gqlgen/graphql/handler/testserver" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" +) + +func TestUrlEncodedForm(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.UrlEncodedForm{}) + + t.Run("success json", func(t *testing.T) { + resp := doRequest(h, "POST", "/graphql", `{"query":"{ name }"}`, "application/x-www-form-urlencoded") + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + }) + + t.Run("success urlencoded", func(t *testing.T) { + resp := doRequest(h, "POST", "/graphql", `query=%7B%20name%20%7D`, "application/x-www-form-urlencoded") + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + }) + + t.Run("success plain", func(t *testing.T) { + resp := doRequest(h, "POST", "/graphql", `query={ name }`, "application/x-www-form-urlencoded") + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + }) + + t.Run("decode failure json", func(t *testing.T) { + resp := doRequest(h, "POST", "/graphql", "notjson", "application/x-www-form-urlencoded") + assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") + assert.Equal(t, `{"errors":[{"message":"Unexpected Name \"notjson\"","locations":[{"line":1,"column":1}],"extensions":{"code":"GRAPHQL_PARSE_FAILED"}}],"data":null}`, resp.Body.String()) + }) + + t.Run("decode failure urlencoded", func(t *testing.T) { + resp := doRequest(h, "POST", "/graphql", "query=%7Bnot-good", "application/x-www-form-urlencoded") + assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") + assert.Equal(t, `{"errors":[{"message":"Expected Name, found \u003cInvalid\u003e","locations":[{"line":1,"column":6}],"extensions":{"code":"GRAPHQL_PARSE_FAILED"}}],"data":null}`, resp.Body.String()) + }) + + t.Run("parse query failure", func(t *testing.T) { + resp := doRequest(h, "POST", "/graphql", `{"query":{"wrong": "format"}}`, "application/x-www-form-urlencoded") + assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") + assert.Equal(t, resp.Body.String(), `{"errors":[{"message":"could not cleanup body: json: cannot unmarshal object into Go struct field RawParams.query of type string"}],"data":null}`) + }) + + t.Run("validate content type", func(t *testing.T) { + doReq := func(handler http.Handler, method string, target string, body string, contentType string) *httptest.ResponseRecorder { + r := httptest.NewRequest(method, target, strings.NewReader(body)) + if contentType != "" { + r.Header.Set("Content-Type", contentType) + } + w := httptest.NewRecorder() + + handler.ServeHTTP(w, r) + return w + } + + validContentTypes := []string{ + "application/x-www-form-urlencoded", + } + + for _, contentType := range validContentTypes { + t.Run(fmt.Sprintf("allow for content type %s", contentType), func(t *testing.T) { + resp := doReq(h, "POST", "/graphql", `{"query":"{ name }"}`, contentType) + assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + }) + } + + invalidContentTypes := []string{ + "", + "text/plain", + } + + for _, tc := range invalidContentTypes { + t.Run(fmt.Sprintf("reject for content type %s", tc), func(t *testing.T) { + resp := doReq(h, "POST", "/graphql", `{"query":"{ name }"}`, tc) + assert.Equal(t, http.StatusBadRequest, resp.Code, resp.Body.String()) + assert.Equal(t, fmt.Sprintf(`{"errors":[{"message":"%s"}],"data":null}`, "transport not supported"), resp.Body.String()) + }) + } + }) +} diff --git a/graphql/handler/transport/http_form_urlencoded.go b/graphql/handler/transport/http_form_urlencoded.go new file mode 100644 index 0000000..85a8a65 --- /dev/null +++ b/graphql/handler/transport/http_form_urlencoded.go @@ -0,0 +1,119 @@ +package transport + +import ( + "io" + "mime" + "net/http" + "net/url" + "strings" + + "github.com/vektah/gqlparser/v2/gqlerror" + + "github.com/niko0xdev/gqlgen/graphql" +) + +// FORM implements the application/x-www-form-urlencoded side of the default HTTP transport +type UrlEncodedForm struct { + // Map of all headers that are added to graphql response. If not + // set, only one header: Content-Type: application/json will be set. + ResponseHeaders map[string][]string +} + +var _ graphql.Transport = UrlEncodedForm{} + +func (h UrlEncodedForm) Supports(r *http.Request) bool { + if r.Header.Get("Upgrade") != "" { + return false + } + + mediaType, _, err := mime.ParseMediaType(r.Header.Get("Content-Type")) + if err != nil { + return false + } + + return r.Method == "POST" && mediaType == "application/x-www-form-urlencoded" +} + +func (h UrlEncodedForm) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecutor) { + ctx := r.Context() + writeHeaders(w, h.ResponseHeaders) + params := &graphql.RawParams{} + start := graphql.Now() + params.Headers = r.Header + params.ReadTime = graphql.TraceTiming{ + Start: start, + End: graphql.Now(), + } + + bodyString, err := getRequestBody(r) + if err != nil { + w.WriteHeader(http.StatusBadRequest) + gqlErr := gqlerror.Errorf("could not get form body: %+v", err) + resp := exec.DispatchError(ctx, gqlerror.List{gqlErr}) + writeJson(w, resp) + return + } + + params, err = h.parseBody(bodyString) + if err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + gqlErr := gqlerror.Errorf("could not cleanup body: %+v", err) + resp := exec.DispatchError(ctx, gqlerror.List{gqlErr}) + writeJson(w, resp) + return + } + + rc, OpErr := exec.CreateOperationContext(ctx, params) + if OpErr != nil { + w.WriteHeader(statusFor(OpErr)) + resp := exec.DispatchError(graphql.WithOperationContext(ctx, rc), OpErr) + writeJson(w, resp) + return + } + + var responses graphql.ResponseHandler + responses, ctx = exec.DispatchOperation(ctx, rc) + writeJson(w, responses(ctx)) +} + +func (h UrlEncodedForm) parseBody(bodyString string) (*graphql.RawParams, error) { + switch { + case strings.Contains(bodyString, "\"query\":"): + // body is json + return h.parseJson(bodyString) + case strings.HasPrefix(bodyString, "query=%7B"): + // body is urlencoded + return h.parseEncoded(bodyString) + default: + // body is plain text + params := &graphql.RawParams{} + params.Query = strings.TrimPrefix(bodyString, "query=") + + return params, nil + } +} + +func (h UrlEncodedForm) parseEncoded(bodyString string) (*graphql.RawParams, error) { + params := &graphql.RawParams{} + + query, err := url.QueryUnescape(bodyString) + if err != nil { + return nil, err + } + + params.Query = strings.TrimPrefix(query, "query=") + + return params, nil +} + +func (h UrlEncodedForm) parseJson(bodyString string) (*graphql.RawParams, error) { + params := &graphql.RawParams{} + bodyReader := io.NopCloser(strings.NewReader(bodyString)) + + err := jsonDecode(bodyReader, ¶ms) + if err != nil { + return nil, err + } + + return params, nil +} diff --git a/graphql/handler/transport/http_get.go b/graphql/handler/transport/http_get.go new file mode 100644 index 0000000..d217b84 --- /dev/null +++ b/graphql/handler/transport/http_get.go @@ -0,0 +1,100 @@ +package transport + +import ( + "encoding/json" + "io" + "net/http" + "net/url" + "strings" + + "github.com/vektah/gqlparser/v2/ast" + "github.com/vektah/gqlparser/v2/gqlerror" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/errcode" +) + +// GET implements the GET side of the default HTTP transport +// defined in https://github.com/APIs-guru/graphql-over-http#get +type GET struct { + // Map of all headers that are added to graphql response. If not + // set, only one header: Content-Type: application/json will be set. + ResponseHeaders map[string][]string +} + +var _ graphql.Transport = GET{} + +func (h GET) Supports(r *http.Request) bool { + if r.Header.Get("Upgrade") != "" { + return false + } + + return r.Method == "GET" +} + +func (h GET) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecutor) { + query, err := url.ParseQuery(r.URL.RawQuery) + if err != nil { + w.WriteHeader(http.StatusBadRequest) + writeJsonError(w, err.Error()) + return + } + writeHeaders(w, h.ResponseHeaders) + + raw := &graphql.RawParams{ + Query: query.Get("query"), + OperationName: query.Get("operationName"), + Headers: r.Header, + } + raw.ReadTime.Start = graphql.Now() + + if variables := query.Get("variables"); variables != "" { + if err := jsonDecode(strings.NewReader(variables), &raw.Variables); err != nil { + w.WriteHeader(http.StatusBadRequest) + writeJsonError(w, "variables could not be decoded") + return + } + } + + if extensions := query.Get("extensions"); extensions != "" { + if err := jsonDecode(strings.NewReader(extensions), &raw.Extensions); err != nil { + w.WriteHeader(http.StatusBadRequest) + writeJsonError(w, "extensions could not be decoded") + return + } + } + + raw.ReadTime.End = graphql.Now() + + rc, gqlError := exec.CreateOperationContext(r.Context(), raw) + if gqlError != nil { + w.WriteHeader(statusFor(gqlError)) + resp := exec.DispatchError(graphql.WithOperationContext(r.Context(), rc), gqlError) + writeJson(w, resp) + return + } + op := rc.Doc.Operations.ForName(rc.OperationName) + if op.Operation != ast.Query { + w.WriteHeader(http.StatusNotAcceptable) + writeJsonError(w, "GET requests only allow query operations") + return + } + + responses, ctx := exec.DispatchOperation(r.Context(), rc) + writeJson(w, responses(ctx)) +} + +func jsonDecode(r io.Reader, val interface{}) error { + dec := json.NewDecoder(r) + dec.UseNumber() + return dec.Decode(val) +} + +func statusFor(errs gqlerror.List) int { + switch errcode.GetErrorKind(errs) { + case errcode.KindProtocol: + return http.StatusUnprocessableEntity + default: + return http.StatusOK + } +} diff --git a/graphql/handler/transport/http_get_test.go b/graphql/handler/transport/http_get_test.go new file mode 100644 index 0000000..0cc0f94 --- /dev/null +++ b/graphql/handler/transport/http_get_test.go @@ -0,0 +1,51 @@ +package transport_test + +import ( + "net/http" + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/niko0xdev/gqlgen/graphql/handler/testserver" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" +) + +func TestGET(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.GET{}) + + t.Run("success", func(t *testing.T) { + resp := doRequest(h, "GET", "/graphql?query={name}", ``, "application/json") + assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + }) + + t.Run("has json content-type header", func(t *testing.T) { + resp := doRequest(h, "GET", "/graphql?query={name}", ``, "application/json") + assert.Equal(t, "application/json", resp.Header().Get("Content-Type")) + }) + + t.Run("decode failure", func(t *testing.T) { + resp := doRequest(h, "GET", "/graphql?query={name}&variables=notjson", "", "application/json") + assert.Equal(t, http.StatusBadRequest, resp.Code, resp.Body.String()) + assert.Equal(t, `{"errors":[{"message":"variables could not be decoded"}],"data":null}`, resp.Body.String()) + }) + + t.Run("invalid variable", func(t *testing.T) { + resp := doRequest(h, "GET", `/graphql?query=query($id:Int!){find(id:$id)}&variables={"id":false}`, "", "application/json") + assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + assert.Equal(t, `{"errors":[{"message":"cannot use bool as Int","path":["variable","id"],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}],"data":null}`, resp.Body.String()) + }) + + t.Run("parse failure", func(t *testing.T) { + resp := doRequest(h, "GET", "/graphql?query=!", "", "application/json") + assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + assert.Equal(t, `{"errors":[{"message":"Unexpected !","locations":[{"line":1,"column":1}],"extensions":{"code":"GRAPHQL_PARSE_FAILED"}}],"data":null}`, resp.Body.String()) + }) + + t.Run("no mutations", func(t *testing.T) { + resp := doRequest(h, "GET", "/graphql?query=mutation{name}", "", "application/json") + assert.Equal(t, http.StatusNotAcceptable, resp.Code, resp.Body.String()) + assert.Equal(t, `{"errors":[{"message":"GET requests only allow query operations"}],"data":null}`, resp.Body.String()) + }) +} diff --git a/graphql/handler/transport/http_graphql.go b/graphql/handler/transport/http_graphql.go new file mode 100644 index 0000000..5a651fe --- /dev/null +++ b/graphql/handler/transport/http_graphql.go @@ -0,0 +1,98 @@ +package transport + +import ( + "mime" + "net/http" + "net/url" + "strings" + + "github.com/vektah/gqlparser/v2/gqlerror" + + "github.com/niko0xdev/gqlgen/graphql" +) + +// GRAPHQL implements the application/graphql side of the HTTP transport +// see: https://graphql.org/learn/serving-over-http/#post-request +// If the "application/graphql" Content-Type header is present, treat +// the HTTP POST body contents as the GraphQL query string. +type GRAPHQL struct { + // Map of all headers that are added to graphql response. If not + // set, only one header: Content-Type: application/json will be set. + ResponseHeaders map[string][]string +} + +var _ graphql.Transport = GRAPHQL{} + +func (h GRAPHQL) Supports(r *http.Request) bool { + if r.Header.Get("Upgrade") != "" { + return false + } + + mediaType, _, err := mime.ParseMediaType(r.Header.Get("Content-Type")) + if err != nil { + return false + } + + return r.Method == "POST" && mediaType == "application/graphql" +} + +func (h GRAPHQL) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecutor) { + ctx := r.Context() + writeHeaders(w, h.ResponseHeaders) + params := &graphql.RawParams{} + start := graphql.Now() + params.Headers = r.Header + params.ReadTime = graphql.TraceTiming{ + Start: start, + End: graphql.Now(), + } + + bodyString, err := getRequestBody(r) + if err != nil { + gqlErr := gqlerror.Errorf("could not get request body: %+v", err) + resp := exec.DispatchError(ctx, gqlerror.List{gqlErr}) + writeJson(w, resp) + return + } + + params.Query, err = cleanupBody(bodyString) + if err != nil { + w.WriteHeader(http.StatusUnprocessableEntity) + gqlErr := gqlerror.Errorf("could not cleanup body: %+v", err) + resp := exec.DispatchError(ctx, gqlerror.List{gqlErr}) + writeJson(w, resp) + return + } + + rc, OpErr := exec.CreateOperationContext(ctx, params) + if OpErr != nil { + w.WriteHeader(statusFor(OpErr)) + resp := exec.DispatchError(graphql.WithOperationContext(ctx, rc), OpErr) + writeJson(w, resp) + return + } + + var responses graphql.ResponseHandler + responses, ctx = exec.DispatchOperation(ctx, rc) + writeJson(w, responses(ctx)) +} + +// Makes sure we strip "query=" keyword from body and +// that body is not url escaped +func cleanupBody(body string) (out string, err error) { + // Some clients send 'query=' at the start of body payload. Let's remove + // it to get GQL query only. + body = strings.TrimPrefix(body, "query=") + + // Body payload can be url encoded or not. We check if %7B - "{" character + // is where query starts. If it is, query is url encoded. + if strings.HasPrefix(body, "%7B") { + body, err = url.QueryUnescape(body) + + if err != nil { + return body, err + } + } + + return body, err +} diff --git a/graphql/handler/transport/http_graphql_test.go b/graphql/handler/transport/http_graphql_test.go new file mode 100644 index 0000000..e780d32 --- /dev/null +++ b/graphql/handler/transport/http_graphql_test.go @@ -0,0 +1,107 @@ +package transport_test + +import ( + "fmt" + "net/http" + "net/http/httptest" + "strings" + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/niko0xdev/gqlgen/graphql/handler/testserver" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" +) + +func TestGRAPHQL(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.GRAPHQL{}) + + t.Run("success", func(t *testing.T) { + resp := doGraphqlRequest(h, "POST", "/graphql", `{ name }`) + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + }) + + t.Run("success even if url encoded", func(t *testing.T) { + resp := doGraphqlRequest(h, "POST", "/graphql", `%7B%20name%20%7D`) + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + }) + + t.Run("parse failure", func(t *testing.T) { + resp := doGraphqlRequest(h, "POST", "/graphql", `{"!"}`) + assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") + assert.Equal(t, `{"errors":[{"message":"Expected Name, found String","locations":[{"line":1,"column":3}],"extensions":{"code":"GRAPHQL_PARSE_FAILED"}}],"data":null}`, resp.Body.String()) + }) + + t.Run("parse query failure", func(t *testing.T) { + resp := doGraphqlRequest(h, "POST", "/graphql", `%7B%H7U6Z`) + assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") + assert.Equal(t, resp.Body.String(), `{"errors":[{"message":"could not cleanup body: invalid URL escape \"%H7\""}],"data":null}`) + }) + + t.Run("validation failure", func(t *testing.T) { + resp := doGraphqlRequest(h, "POST", "/graphql", `{ title }`) + assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") + assert.Equal(t, `{"errors":[{"message":"Cannot query field \"title\" on type \"Query\".","locations":[{"line":1,"column":3}],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}],"data":null}`, resp.Body.String()) + }) + + t.Run("execution failure", func(t *testing.T) { + resp := doGraphqlRequest(h, "POST", "/graphql", `mutation { name }`) + assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") + assert.Equal(t, `{"errors":[{"message":"mutations are not supported"}],"data":null}`, resp.Body.String()) + }) + + t.Run("validate content type", func(t *testing.T) { + doReq := func(handler http.Handler, method string, target string, body string, contentType string) *httptest.ResponseRecorder { + r := httptest.NewRequest(method, target, strings.NewReader(body)) + if contentType != "" { + r.Header.Set("Content-Type", contentType) + } + w := httptest.NewRecorder() + + handler.ServeHTTP(w, r) + return w + } + + validContentTypes := []string{ + "application/graphql", + "application/graphql; charset=utf-8", + } + + for _, contentType := range validContentTypes { + t.Run(fmt.Sprintf("allow for content type %s", contentType), func(t *testing.T) { + resp := doReq(h, "POST", "/graphql", `{ name }`, contentType) + assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + }) + } + + invalidContentTypes := []string{ + "", + "text/plain", + } + + for _, tc := range invalidContentTypes { + t.Run(fmt.Sprintf("reject for content type %s", tc), func(t *testing.T) { + resp := doReq(h, "POST", "/graphql", `{"query":"{ name }"}`, tc) + assert.Equal(t, http.StatusBadRequest, resp.Code, resp.Body.String()) + assert.Equal(t, fmt.Sprintf(`{"errors":[{"message":"%s"}],"data":null}`, "transport not supported"), resp.Body.String()) + }) + } + }) +} + +func doGraphqlRequest(handler http.Handler, method string, target string, body string) *httptest.ResponseRecorder { + r := httptest.NewRequest(method, target, strings.NewReader(body)) + r.Header.Set("Content-Type", "application/graphql") + w := httptest.NewRecorder() + + handler.ServeHTTP(w, r) + return w +} diff --git a/graphql/handler/transport/http_post.go b/graphql/handler/transport/http_post.go new file mode 100644 index 0000000..bba83df --- /dev/null +++ b/graphql/handler/transport/http_post.go @@ -0,0 +1,92 @@ +package transport + +import ( + "fmt" + "io" + "mime" + "net/http" + "strings" + + "github.com/vektah/gqlparser/v2/gqlerror" + + "github.com/niko0xdev/gqlgen/graphql" +) + +// POST implements the POST side of the default HTTP transport +// defined in https://github.com/APIs-guru/graphql-over-http#post +type POST struct { + // Map of all headers that are added to graphql response. If not + // set, only one header: Content-Type: application/json will be set. + ResponseHeaders map[string][]string +} + +var _ graphql.Transport = POST{} + +func (h POST) Supports(r *http.Request) bool { + if r.Header.Get("Upgrade") != "" { + return false + } + + mediaType, _, err := mime.ParseMediaType(r.Header.Get("Content-Type")) + if err != nil { + return false + } + + return r.Method == "POST" && mediaType == "application/json" +} + +func getRequestBody(r *http.Request) (string, error) { + if r == nil || r.Body == nil { + return "", nil + } + body, err := io.ReadAll(r.Body) + if err != nil { + return "", fmt.Errorf("unable to get Request Body %w", err) + } + return string(body), nil +} + +func (h POST) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecutor) { + ctx := r.Context() + writeHeaders(w, h.ResponseHeaders) + params := &graphql.RawParams{} + start := graphql.Now() + params.Headers = r.Header + params.ReadTime = graphql.TraceTiming{ + Start: start, + End: graphql.Now(), + } + + bodyString, err := getRequestBody(r) + if err != nil { + gqlErr := gqlerror.Errorf("could not get json request body: %+v", err) + resp := exec.DispatchError(ctx, gqlerror.List{gqlErr}) + writeJson(w, resp) + return + } + + bodyReader := io.NopCloser(strings.NewReader(bodyString)) + if err = jsonDecode(bodyReader, ¶ms); err != nil { + w.WriteHeader(http.StatusBadRequest) + gqlErr := gqlerror.Errorf( + "json request body could not be decoded: %+v body:%s", + err, + bodyString, + ) + resp := exec.DispatchError(ctx, gqlerror.List{gqlErr}) + writeJson(w, resp) + return + } + + rc, OpErr := exec.CreateOperationContext(ctx, params) + if OpErr != nil { + w.WriteHeader(statusFor(OpErr)) + resp := exec.DispatchError(graphql.WithOperationContext(ctx, rc), OpErr) + writeJson(w, resp) + return + } + + var responses graphql.ResponseHandler + responses, ctx = exec.DispatchOperation(ctx, rc) + writeJson(w, responses(ctx)) +} diff --git a/graphql/handler/transport/http_post_test.go b/graphql/handler/transport/http_post_test.go new file mode 100644 index 0000000..e8a2ddf --- /dev/null +++ b/graphql/handler/transport/http_post_test.go @@ -0,0 +1,108 @@ +package transport_test + +import ( + "fmt" + "net/http" + "net/http/httptest" + "strings" + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/niko0xdev/gqlgen/graphql/handler/testserver" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" +) + +func TestPOST(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.POST{}) + + t.Run("success", func(t *testing.T) { + resp := doRequest(h, "POST", "/graphql", `{"query":"{ name }"}`, "application/json") + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + }) + + t.Run("decode failure", func(t *testing.T) { + resp := doRequest(h, "POST", "/graphql", "notjson", "application/json") + assert.Equal(t, http.StatusBadRequest, resp.Code, resp.Body.String()) + assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") + assert.Equal(t, `{"errors":[{"message":"json request body could not be decoded: invalid character 'o' in literal null (expecting 'u') body:notjson"}],"data":null}`, resp.Body.String()) + }) + + t.Run("parse failure", func(t *testing.T) { + resp := doRequest(h, "POST", "/graphql", `{"query": "!"}`, "application/json") + assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") + assert.Equal(t, `{"errors":[{"message":"Unexpected !","locations":[{"line":1,"column":1}],"extensions":{"code":"GRAPHQL_PARSE_FAILED"}}],"data":null}`, resp.Body.String()) + }) + + t.Run("validation failure", func(t *testing.T) { + resp := doRequest(h, "POST", "/graphql", `{"query": "{ title }"}`, "application/json") + assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") + assert.Equal(t, `{"errors":[{"message":"Cannot query field \"title\" on type \"Query\".","locations":[{"line":1,"column":3}],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}],"data":null}`, resp.Body.String()) + }) + + t.Run("invalid variable", func(t *testing.T) { + resp := doRequest(h, "POST", "/graphql", `{"query": "query($id:Int!){find(id:$id)}","variables":{"id":false}}`, "application/json") + assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String()) + assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") + assert.Equal(t, `{"errors":[{"message":"cannot use bool as Int","path":["variable","id"],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}],"data":null}`, resp.Body.String()) + }) + + t.Run("execution failure", func(t *testing.T) { + resp := doRequest(h, "POST", "/graphql", `{"query": "mutation { name }"}`, "application/json") + assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") + assert.Equal(t, `{"errors":[{"message":"mutations are not supported"}],"data":null}`, resp.Body.String()) + }) + + t.Run("validate content type", func(t *testing.T) { + doReq := func(handler http.Handler, method string, target string, body string, contentType string) *httptest.ResponseRecorder { + r := httptest.NewRequest(method, target, strings.NewReader(body)) + if contentType != "" { + r.Header.Set("Content-Type", contentType) + } + w := httptest.NewRecorder() + + handler.ServeHTTP(w, r) + return w + } + + validContentTypes := []string{ + "application/json", + "application/json; charset=utf-8", + } + + for _, contentType := range validContentTypes { + t.Run(fmt.Sprintf("allow for content type %s", contentType), func(t *testing.T) { + resp := doReq(h, "POST", "/graphql", `{"query":"{ name }"}`, contentType) + assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String()) + assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + }) + } + + invalidContentTypes := []string{ + "", + "text/plain", + } + + for _, tc := range invalidContentTypes { + t.Run(fmt.Sprintf("reject for content type %s", tc), func(t *testing.T) { + resp := doReq(h, "POST", "/graphql", `{"query":"{ name }"}`, tc) + assert.Equal(t, http.StatusBadRequest, resp.Code, resp.Body.String()) + assert.Equal(t, fmt.Sprintf(`{"errors":[{"message":"%s"}],"data":null}`, "transport not supported"), resp.Body.String()) + }) + } + }) +} + +func doRequest(handler http.Handler, method string, target string, body string, contentType string) *httptest.ResponseRecorder { + r := httptest.NewRequest(method, target, strings.NewReader(body)) + r.Header.Set("Content-Type", contentType) + w := httptest.NewRecorder() + + handler.ServeHTTP(w, r) + return w +} diff --git a/graphql/handler/transport/options.go b/graphql/handler/transport/options.go new file mode 100644 index 0000000..b8dafbe --- /dev/null +++ b/graphql/handler/transport/options.go @@ -0,0 +1,37 @@ +package transport + +import ( + "net/http" + "strings" + + "github.com/niko0xdev/gqlgen/graphql" +) + +// Options responds to http OPTIONS and HEAD requests +type Options struct { + // AllowedMethods is a list of allowed HTTP methods. + AllowedMethods []string +} + +var _ graphql.Transport = Options{} + +func (o Options) Supports(r *http.Request) bool { + return r.Method == "HEAD" || r.Method == "OPTIONS" +} + +func (o Options) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecutor) { + switch r.Method { + case http.MethodOptions: + w.Header().Set("Allow", o.allowedMethods()) + w.WriteHeader(http.StatusOK) + case http.MethodHead: + w.WriteHeader(http.StatusMethodNotAllowed) + } +} + +func (o Options) allowedMethods() string { + if len(o.AllowedMethods) == 0 { + return "OPTIONS, GET, POST" + } + return strings.Join(o.AllowedMethods, ", ") +} diff --git a/graphql/handler/transport/options_test.go b/graphql/handler/transport/options_test.go new file mode 100644 index 0000000..3953749 --- /dev/null +++ b/graphql/handler/transport/options_test.go @@ -0,0 +1,38 @@ +package transport_test + +import ( + "net/http" + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/niko0xdev/gqlgen/graphql/handler/testserver" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" +) + +func TestOptions(t *testing.T) { + t.Run("responds to options requests with default methods", func(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.Options{}) + resp := doRequest(h, "OPTIONS", "/graphql?query={me{name}}", ``, "application/json") + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, "OPTIONS, GET, POST", resp.Header().Get("Allow")) + }) + + t.Run("responds to options requests with specified methods", func(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.Options{ + AllowedMethods: []string{http.MethodOptions, http.MethodPost, http.MethodHead}, + }) + resp := doRequest(h, "OPTIONS", "/graphql?query={me{name}}", ``, "application/json") + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, "OPTIONS, POST, HEAD", resp.Header().Get("Allow")) + }) + + t.Run("responds to head requests", func(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.Options{}) + resp := doRequest(h, "HEAD", "/graphql?query={me{name}}", ``, "application/json") + assert.Equal(t, http.StatusMethodNotAllowed, resp.Code) + }) +} diff --git a/graphql/handler/transport/reader.go b/graphql/handler/transport/reader.go new file mode 100644 index 0000000..c58eccf --- /dev/null +++ b/graphql/handler/transport/reader.go @@ -0,0 +1,45 @@ +package transport + +import ( + "errors" + "io" +) + +type bytesReader struct { + s *[]byte + i int64 // current reading index +} + +func (r *bytesReader) Read(b []byte) (n int, err error) { + if r.s == nil { + return 0, errors.New("byte slice pointer is nil") + } + if r.i >= int64(len(*r.s)) { + return 0, io.EOF + } + n = copy(b, (*r.s)[r.i:]) + r.i += int64(n) + return +} + +func (r *bytesReader) Seek(offset int64, whence int) (int64, error) { + if r.s == nil { + return 0, errors.New("byte slice pointer is nil") + } + var abs int64 + switch whence { + case io.SeekStart: + abs = offset + case io.SeekCurrent: + abs = r.i + offset + case io.SeekEnd: + abs = int64(len(*r.s)) + offset + default: + return 0, errors.New("invalid whence") + } + if abs < 0 { + return 0, errors.New("negative position") + } + r.i = abs + return abs, nil +} diff --git a/graphql/handler/transport/reader_test.go b/graphql/handler/transport/reader_test.go new file mode 100644 index 0000000..e57ac5a --- /dev/null +++ b/graphql/handler/transport/reader_test.go @@ -0,0 +1,127 @@ +package transport + +import ( + "io" + "sync" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestBytesRead(t *testing.T) { + t.Run("test concurrency", func(t *testing.T) { + // Test for the race detector, to verify a Read that doesn't yield any bytes + // is okay to use from multiple goroutines. This was our historic behavior. + // See golang.org/issue/7856 + r := bytesReader{s: &([]byte{})} + var wg sync.WaitGroup + for i := 0; i < 5; i++ { + wg.Add(2) + go func() { + defer wg.Done() + var buf [1]byte + r.Read(buf[:]) + }() + go func() { + defer wg.Done() + r.Read(nil) + }() + } + wg.Wait() + }) + + t.Run("fail to read if pointer is nil", func(t *testing.T) { + n, err := (&bytesReader{}).Read(nil) + require.Equal(t, 0, n) + require.NotNil(t, err) + require.Equal(t, "byte slice pointer is nil", err.Error()) + }) + + t.Run("read using buffer", func(t *testing.T) { + data := []byte("0123456789") + r := bytesReader{s: &data} + + got := make([]byte, 0, 11) + buf := make([]byte, 1) + for { + n, err := r.Read(buf) + if n < 0 { + require.Fail(t, "unexpected bytes read size") + } + got = append(got, buf[:n]...) + if err != nil { + if err == io.EOF { + break + } + require.Fail(t, "unexpected error while reading", err.Error()) + } + } + require.Equal(t, "0123456789", string(got)) + }) + + t.Run("read updated pointer value", func(t *testing.T) { + data := []byte("0123456789") + pointer := &data + r := bytesReader{s: pointer} + data[2] = []byte("9")[0] + + got := make([]byte, 0, 11) + buf := make([]byte, 1) + for { + n, err := r.Read(buf) + if n < 0 { + require.Fail(t, "unexpected bytes read size") + } + got = append(got, buf[:n]...) + if err != nil { + if err == io.EOF { + break + } + require.Fail(t, "unexpected error while reading", err.Error()) + } + } + require.Equal(t, "0193456789", string(got)) + }) + + t.Run("read using buffer multiple times", func(t *testing.T) { + data := []byte("0123456789") + r := bytesReader{s: &data} + + got := make([]byte, 0, 11) + buf := make([]byte, 1) + for { + n, err := r.Read(buf) + if n < 0 { + require.Fail(t, "unexpected bytes read size") + } + got = append(got, buf[:n]...) + if err != nil { + if err == io.EOF { + break + } + require.Fail(t, "unexpected error while reading", err.Error()) + } + } + require.Equal(t, "0123456789", string(got)) + + pos, err := r.Seek(0, io.SeekStart) + require.NoError(t, err) + require.Equal(t, int64(0), pos) + + got = make([]byte, 0, 11) + for { + n, err := r.Read(buf) + if n < 0 { + require.Fail(t, "unexpected bytes read size") + } + got = append(got, buf[:n]...) + if err != nil { + if err == io.EOF { + break + } + require.Fail(t, "unexpected error while reading", err.Error()) + } + } + require.Equal(t, "0123456789", string(got)) + }) +} diff --git a/graphql/handler/transport/sse.go b/graphql/handler/transport/sse.go new file mode 100644 index 0000000..3725c8b --- /dev/null +++ b/graphql/handler/transport/sse.go @@ -0,0 +1,107 @@ +package transport + +import ( + "encoding/json" + "fmt" + "io" + "log" + "mime" + "net/http" + "strings" + + "github.com/vektah/gqlparser/v2/gqlerror" + + "github.com/niko0xdev/gqlgen/graphql" +) + +type SSE struct{} + +var _ graphql.Transport = SSE{} + +func (t SSE) Supports(r *http.Request) bool { + if !strings.Contains(r.Header.Get("Accept"), "text/event-stream") { + return false + } + mediaType, _, err := mime.ParseMediaType(r.Header.Get("Content-Type")) + if err != nil { + return false + } + return r.Method == http.MethodPost && mediaType == "application/json" +} + +func (t SSE) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecutor) { + ctx := r.Context() + flusher, ok := w.(http.Flusher) + if !ok { + SendErrorf(w, http.StatusInternalServerError, "streaming unsupported") + return + } + defer flusher.Flush() + + w.Header().Set("Cache-Control", "no-cache") + w.Header().Set("Connection", "keep-alive") + w.Header().Set("Content-Type", "application/json") + + params := &graphql.RawParams{} + start := graphql.Now() + params.Headers = r.Header + params.ReadTime = graphql.TraceTiming{ + Start: start, + End: graphql.Now(), + } + + bodyString, err := getRequestBody(r) + if err != nil { + gqlErr := gqlerror.Errorf("could not get json request body: %+v", err) + resp := exec.DispatchError(ctx, gqlerror.List{gqlErr}) + log.Printf("could not get json request body: %+v", err.Error()) + writeJson(w, resp) + return + } + + bodyReader := io.NopCloser(strings.NewReader(bodyString)) + if err = jsonDecode(bodyReader, ¶ms); err != nil { + w.WriteHeader(http.StatusBadRequest) + gqlErr := gqlerror.Errorf( + "json request body could not be decoded: %+v body:%s", + err, + bodyString, + ) + resp := exec.DispatchError(ctx, gqlerror.List{gqlErr}) + log.Printf("decoding error: %+v body:%s", err.Error(), bodyString) + writeJson(w, resp) + return + } + + rc, opErr := exec.CreateOperationContext(ctx, params) + ctx = graphql.WithOperationContext(ctx, rc) + + w.Header().Set("Content-Type", "text/event-stream") + fmt.Fprint(w, ":\n\n") + flusher.Flush() + + if opErr != nil { + resp := exec.DispatchError(ctx, opErr) + writeJsonWithSSE(w, resp) + } else { + responses, ctx := exec.DispatchOperation(ctx, rc) + for { + response := responses(ctx) + if response == nil { + break + } + writeJsonWithSSE(w, response) + flusher.Flush() + } + } + + fmt.Fprint(w, "event: complete\n\n") +} + +func writeJsonWithSSE(w io.Writer, response *graphql.Response) { + b, err := json.Marshal(response) + if err != nil { + panic(err) + } + fmt.Fprintf(w, "event: next\ndata: %s\n\n", b) +} diff --git a/graphql/handler/transport/sse_test.go b/graphql/handler/transport/sse_test.go new file mode 100644 index 0000000..096bc3c --- /dev/null +++ b/graphql/handler/transport/sse_test.go @@ -0,0 +1,150 @@ +package transport_test + +import ( + "bufio" + "io" + "net/http" + "net/http/httptest" + "strings" + "sync" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/graphql/handler/testserver" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" +) + +func TestSSE(t *testing.T) { + initialize := func() *testserver.TestServer { + h := testserver.New() + h.AddTransport(transport.SSE{}) + return h + } + + initializeWithServer := func() (*testserver.TestServer, *httptest.Server) { + h := initialize() + return h, httptest.NewServer(h) + } + + createHTTPTestRequest := func(query string) *http.Request { + req := httptest.NewRequest(http.MethodPost, "/graphql", strings.NewReader(query)) + req.Header.Set("Accept", "text/event-stream") + req.Header.Set("content-type", "application/json; charset=utf-8") + return req + } + + createHTTPRequest := func(url string, query string) *http.Request { + req, err := http.NewRequest("POST", url, strings.NewReader(query)) + require.NoError(t, err, "Request threw error -> %s", err) + req.Header.Set("Accept", "text/event-stream") + req.Header.Set("content-type", "application/json; charset=utf-8") + return req + } + + readLine := func(br *bufio.Reader) string { + bs, err := br.ReadString('\n') + require.NoError(t, err) + return bs + } + + t.Run("stream failure", func(t *testing.T) { + h := initialize() + req := httptest.NewRequest(http.MethodPost, "/graphql", strings.NewReader(`{"query":"subscription { name }"}`)) + req.Header.Set("content-type", "application/json; charset=utf-8") + w := httptest.NewRecorder() + h.ServeHTTP(w, req) + assert.Equal(t, 400, w.Code, "Request return wrong status -> %d", w.Code) + assert.Equal(t, `{"errors":[{"message":"transport not supported"}],"data":null}`, w.Body.String()) + }) + + t.Run("decode failure", func(t *testing.T) { + h := initialize() + req := createHTTPTestRequest("notjson") + w := httptest.NewRecorder() + h.ServeHTTP(w, req) + assert.Equal(t, 400, w.Code, "Request return wrong status -> %d", w.Code) + assert.Equal(t, `{"errors":[{"message":"json request body could not be decoded: invalid character 'o' in literal null (expecting 'u') body:notjson"}],"data":null}`, w.Body.String()) + }) + + t.Run("parse failure", func(t *testing.T) { + h := initialize() + req := createHTTPTestRequest(`{"query":"subscription {{ name }"}`) + w := httptest.NewRecorder() + h.ServeHTTP(w, req) + + assert.Equal(t, 200, w.Code, "Request return wrong status -> %d", w.Code) + assert.Equal(t, "keep-alive", w.Header().Get("Connection")) + assert.Equal(t, "text/event-stream", w.Header().Get("Content-Type")) + + br := bufio.NewReader(w.Body) + + assert.Equal(t, ":\n", readLine(br)) + assert.Equal(t, "\n", readLine(br)) + assert.Equal(t, "event: next\n", readLine(br)) + assert.Equal(t, "data: {\"errors\":[{\"message\":\"Expected Name, found {\",\"locations\":[{\"line\":1,\"column\":15}],\"extensions\":{\"code\":\"GRAPHQL_PARSE_FAILED\"}}],\"data\":null}\n", readLine(br)) + assert.Equal(t, "\n", readLine(br)) + assert.Equal(t, "event: complete\n", readLine(br)) + assert.Equal(t, "\n", readLine(br)) + + _, err := br.ReadByte() + assert.Equal(t, err, io.EOF) + }) + + t.Run("subscribe", func(t *testing.T) { + handler, srv := initializeWithServer() + defer srv.Close() + + var wg sync.WaitGroup + wg.Add(1) + go func() { + defer wg.Done() + handler.SendNextSubscriptionMessage() + }() + + client := &http.Client{} + req := createHTTPRequest(srv.URL, `{"query":"subscription { name }"}`) + res, err := client.Do(req) + require.NoError(t, err, "Request threw error -> %s", err) + defer func() { + require.NoError(t, res.Body.Close()) + }() + + assert.Equal(t, 200, res.StatusCode, "Request return wrong status -> %d", res.Status) + assert.Equal(t, "keep-alive", res.Header.Get("Connection")) + assert.Equal(t, "text/event-stream", res.Header.Get("Content-Type")) + + br := bufio.NewReader(res.Body) + + assert.Equal(t, ":\n", readLine(br)) + assert.Equal(t, "\n", readLine(br)) + assert.Equal(t, "event: next\n", readLine(br)) + assert.Equal(t, "data: {\"data\":{\"name\":\"test\"}}\n", readLine(br)) + assert.Equal(t, "\n", readLine(br)) + + wg.Add(1) + go func() { + defer wg.Done() + handler.SendNextSubscriptionMessage() + }() + + assert.Equal(t, "event: next\n", readLine(br)) + assert.Equal(t, "data: {\"data\":{\"name\":\"test\"}}\n", readLine(br)) + assert.Equal(t, "\n", readLine(br)) + + wg.Add(1) + go func() { + defer wg.Done() + handler.SendCompleteSubscriptionMessage() + }() + + assert.Equal(t, "event: complete\n", readLine(br)) + assert.Equal(t, "\n", readLine(br)) + + _, err = br.ReadByte() + assert.Equal(t, err, io.EOF) + + wg.Wait() + }) +} diff --git a/graphql/handler/transport/util.go b/graphql/handler/transport/util.go new file mode 100644 index 0000000..be87b0b --- /dev/null +++ b/graphql/handler/transport/util.go @@ -0,0 +1,31 @@ +package transport + +import ( + "encoding/json" + "fmt" + "io" + + "github.com/vektah/gqlparser/v2/gqlerror" + + "github.com/niko0xdev/gqlgen/graphql" +) + +func writeJson(w io.Writer, response *graphql.Response) { + b, err := json.Marshal(response) + if err != nil { + panic(err) + } + w.Write(b) +} + +func writeJsonError(w io.Writer, msg string) { + writeJson(w, &graphql.Response{Errors: gqlerror.List{{Message: msg}}}) +} + +func writeJsonErrorf(w io.Writer, format string, args ...interface{}) { + writeJson(w, &graphql.Response{Errors: gqlerror.List{{Message: fmt.Sprintf(format, args...)}}}) +} + +func writeJsonGraphqlError(w io.Writer, err ...*gqlerror.Error) { + writeJson(w, &graphql.Response{Errors: err}) +} diff --git a/graphql/handler/transport/websocket.go b/graphql/handler/transport/websocket.go new file mode 100644 index 0000000..67b9951 --- /dev/null +++ b/graphql/handler/transport/websocket.go @@ -0,0 +1,509 @@ +package transport + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "log" + "net" + "net/http" + "sync" + "time" + + "github.com/gorilla/websocket" + "github.com/vektah/gqlparser/v2/gqlerror" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/errcode" +) + +type ( + Websocket struct { + Upgrader websocket.Upgrader + InitFunc WebsocketInitFunc + InitTimeout time.Duration + ErrorFunc WebsocketErrorFunc + CloseFunc WebsocketCloseFunc + KeepAlivePingInterval time.Duration + PongOnlyInterval time.Duration + PingPongInterval time.Duration + /* If PingPongInterval has a non-0 duration, then when the server sends a ping + * it sets a ReadDeadline of PingPongInterval*2 and if the client doesn't respond + * with pong before that deadline is reached then the connection will die with a + * 1006 error code. + * + * MissingPongOk if true, tells the server to not use a ReadDeadline such that a + * missing/slow pong response from the client doesn't kill the connection. + */ + MissingPongOk bool + + didInjectSubprotocols bool + } + wsConnection struct { + Websocket + ctx context.Context + conn *websocket.Conn + me messageExchanger + active map[string]context.CancelFunc + mu sync.Mutex + keepAliveTicker *time.Ticker + pongOnlyTicker *time.Ticker + pingPongTicker *time.Ticker + receivedPong bool + exec graphql.GraphExecutor + closed bool + + initPayload InitPayload + } + + WebsocketInitFunc func(ctx context.Context, initPayload InitPayload) (context.Context, *InitPayload, error) + WebsocketErrorFunc func(ctx context.Context, err error) + + // Callback called when websocket is closed. + WebsocketCloseFunc func(ctx context.Context, closeCode int) +) + +var errReadTimeout = errors.New("read timeout") + +type WebsocketError struct { + Err error + + // IsReadError flags whether the error occurred on read or write to the websocket + IsReadError bool +} + +func (e WebsocketError) Error() string { + if e.IsReadError { + return fmt.Sprintf("websocket read: %v", e.Err) + } + return fmt.Sprintf("websocket write: %v", e.Err) +} + +var ( + _ graphql.Transport = Websocket{} + _ error = WebsocketError{} +) + +func (t Websocket) Supports(r *http.Request) bool { + return r.Header.Get("Upgrade") != "" +} + +func (t Websocket) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecutor) { + t.injectGraphQLWSSubprotocols() + ws, err := t.Upgrader.Upgrade(w, r, http.Header{}) + if err != nil { + log.Printf("unable to upgrade %T to websocket %s: ", w, err.Error()) + SendErrorf(w, http.StatusBadRequest, "unable to upgrade") + return + } + + var me messageExchanger + switch ws.Subprotocol() { + default: + msg := websocket.FormatCloseMessage(websocket.CloseProtocolError, fmt.Sprintf("unsupported negotiated subprotocol %s", ws.Subprotocol())) + ws.WriteMessage(websocket.CloseMessage, msg) + return + case graphqlwsSubprotocol, "": + // clients are required to send a subprotocol, to be backward compatible with the previous implementation we select + // "graphql-ws" by default + me = graphqlwsMessageExchanger{c: ws} + case graphqltransportwsSubprotocol: + me = graphqltransportwsMessageExchanger{c: ws} + } + + conn := wsConnection{ + active: map[string]context.CancelFunc{}, + conn: ws, + ctx: r.Context(), + exec: exec, + me: me, + Websocket: t, + } + + if !conn.init() { + return + } + + conn.run() +} + +func (c *wsConnection) handlePossibleError(err error, isReadError bool) { + if c.ErrorFunc != nil && err != nil { + c.ErrorFunc(c.ctx, WebsocketError{ + Err: err, + IsReadError: isReadError, + }) + } +} + +func (c *wsConnection) nextMessageWithTimeout(timeout time.Duration) (message, error) { + messages, errs := make(chan message, 1), make(chan error, 1) + + go func() { + if m, err := c.me.NextMessage(); err != nil { + errs <- err + } else { + messages <- m + } + }() + + select { + case m := <-messages: + return m, nil + case err := <-errs: + return message{}, err + case <-time.After(timeout): + return message{}, errReadTimeout + } +} + +func (c *wsConnection) init() bool { + var m message + var err error + + if c.InitTimeout != 0 { + m, err = c.nextMessageWithTimeout(c.InitTimeout) + } else { + m, err = c.me.NextMessage() + } + + if err != nil { + if err == errReadTimeout { + c.close(websocket.CloseProtocolError, "connection initialisation timeout") + return false + } + + if err == errInvalidMsg { + c.sendConnectionError("invalid json") + } + + c.close(websocket.CloseProtocolError, "decoding error") + return false + } + + switch m.t { + case initMessageType: + if len(m.payload) > 0 { + c.initPayload = make(InitPayload) + err := json.Unmarshal(m.payload, &c.initPayload) + if err != nil { + return false + } + } + + var initAckPayload *InitPayload = nil + if c.InitFunc != nil { + var ctx context.Context + ctx, initAckPayload, err = c.InitFunc(c.ctx, c.initPayload) + if err != nil { + c.sendConnectionError(err.Error()) + c.close(websocket.CloseNormalClosure, "terminated") + return false + } + c.ctx = ctx + } + + if initAckPayload != nil { + initJsonAckPayload, err := json.Marshal(*initAckPayload) + if err != nil { + panic(err) + } + c.write(&message{t: connectionAckMessageType, payload: initJsonAckPayload}) + } else { + c.write(&message{t: connectionAckMessageType}) + } + c.write(&message{t: keepAliveMessageType}) + case connectionCloseMessageType: + c.close(websocket.CloseNormalClosure, "terminated") + return false + default: + c.sendConnectionError("unexpected message %s", m.t) + c.close(websocket.CloseProtocolError, "unexpected message") + return false + } + + return true +} + +func (c *wsConnection) write(msg *message) { + c.mu.Lock() + c.handlePossibleError(c.me.Send(msg), false) + c.mu.Unlock() +} + +func (c *wsConnection) run() { + // We create a cancellation that will shutdown the keep-alive when we leave + // this function. + ctx, cancel := context.WithCancel(c.ctx) + defer func() { + cancel() + c.close(websocket.CloseAbnormalClosure, "unexpected closure") + }() + + // If we're running in graphql-ws mode, create a timer that will trigger a + // keep alive message every interval + if (c.conn.Subprotocol() == "" || c.conn.Subprotocol() == graphqlwsSubprotocol) && c.KeepAlivePingInterval != 0 { + c.mu.Lock() + c.keepAliveTicker = time.NewTicker(c.KeepAlivePingInterval) + c.mu.Unlock() + + go c.keepAlive(ctx) + } + + // If we're running in graphql-transport-ws mode, create a timer that will trigger a + // just a pong message every interval + if c.conn.Subprotocol() == graphqltransportwsSubprotocol && c.PongOnlyInterval != 0 { + c.mu.Lock() + c.pongOnlyTicker = time.NewTicker(c.PongOnlyInterval) + c.mu.Unlock() + + go c.keepAlivePongOnly(ctx) + } + + // If we're running in graphql-transport-ws mode, create a timer that will + // trigger a ping message every interval and expect a pong! + if c.conn.Subprotocol() == graphqltransportwsSubprotocol && c.PingPongInterval != 0 { + c.mu.Lock() + c.pingPongTicker = time.NewTicker(c.PingPongInterval) + c.mu.Unlock() + + if !c.MissingPongOk { + // Note: when the connection is closed by this deadline, the client + // will receive an "invalid close code" + c.conn.SetReadDeadline(time.Now().UTC().Add(2 * c.PingPongInterval)) + } + go c.ping(ctx) + } + + // Close the connection when the context is cancelled. + // Will optionally send a "close reason" that is retrieved from the context. + go c.closeOnCancel(ctx) + + for { + start := graphql.Now() + m, err := c.me.NextMessage() + if err != nil { + // If the connection got closed by us, don't report the error + if !errors.Is(err, net.ErrClosed) { + c.handlePossibleError(err, true) + } + return + } + + switch m.t { + case startMessageType: + c.subscribe(start, &m) + case stopMessageType: + c.mu.Lock() + closer := c.active[m.id] + c.mu.Unlock() + if closer != nil { + closer() + } + case connectionCloseMessageType: + c.close(websocket.CloseNormalClosure, "terminated") + return + case pingMessageType: + c.write(&message{t: pongMessageType, payload: m.payload}) + case pongMessageType: + c.mu.Lock() + c.receivedPong = true + c.mu.Unlock() + // Clear ReadTimeout -- 0 time val clears. + c.conn.SetReadDeadline(time.Time{}) + default: + c.sendConnectionError("unexpected message %s", m.t) + c.close(websocket.CloseProtocolError, "unexpected message") + return + } + } +} + +func (c *wsConnection) keepAlivePongOnly(ctx context.Context) { + for { + select { + case <-ctx.Done(): + c.pongOnlyTicker.Stop() + return + case <-c.pongOnlyTicker.C: + c.write(&message{t: pongMessageType, payload: json.RawMessage{}}) + } + } +} + +func (c *wsConnection) keepAlive(ctx context.Context) { + for { + select { + case <-ctx.Done(): + c.keepAliveTicker.Stop() + return + case <-c.keepAliveTicker.C: + c.write(&message{t: keepAliveMessageType}) + } + } +} + +func (c *wsConnection) ping(ctx context.Context) { + for { + select { + case <-ctx.Done(): + c.pingPongTicker.Stop() + return + case <-c.pingPongTicker.C: + c.write(&message{t: pingMessageType, payload: json.RawMessage{}}) + // The initial deadline for this method is set in run() + // if we have not yet received a pong, don't reset the deadline. + c.mu.Lock() + if !c.MissingPongOk && c.receivedPong { + c.conn.SetReadDeadline(time.Now().UTC().Add(2 * c.PingPongInterval)) + } + c.receivedPong = false + c.mu.Unlock() + } + } +} + +func (c *wsConnection) closeOnCancel(ctx context.Context) { + <-ctx.Done() + + if r := closeReasonForContext(ctx); r != "" { + c.sendConnectionError(r) + } + c.close(websocket.CloseNormalClosure, "terminated") +} + +func (c *wsConnection) subscribe(start time.Time, msg *message) { + ctx := graphql.StartOperationTrace(c.ctx) + var params *graphql.RawParams + if err := jsonDecode(bytes.NewReader(msg.payload), ¶ms); err != nil { + c.sendError(msg.id, &gqlerror.Error{Message: "invalid json"}) + c.complete(msg.id) + return + } + + params.ReadTime = graphql.TraceTiming{ + Start: start, + End: graphql.Now(), + } + + rc, err := c.exec.CreateOperationContext(ctx, params) + if err != nil { + resp := c.exec.DispatchError(graphql.WithOperationContext(ctx, rc), err) + switch errcode.GetErrorKind(err) { + case errcode.KindProtocol: + c.sendError(msg.id, resp.Errors...) + default: + c.sendResponse(msg.id, &graphql.Response{Errors: err}) + } + + c.complete(msg.id) + return + } + + ctx = graphql.WithOperationContext(ctx, rc) + + if c.initPayload != nil { + ctx = withInitPayload(ctx, c.initPayload) + } + + ctx, cancel := context.WithCancel(ctx) + c.mu.Lock() + c.active[msg.id] = cancel + c.mu.Unlock() + + go func() { + ctx = withSubscriptionErrorContext(ctx) + defer func() { + if r := recover(); r != nil { + 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(msg.id, gqlerr) + } + if errs := getSubscriptionError(ctx); len(errs) != 0 { + c.sendError(msg.id, errs...) + } else { + c.complete(msg.id) + } + c.mu.Lock() + delete(c.active, msg.id) + c.mu.Unlock() + cancel() + }() + + responses, ctx := c.exec.DispatchOperation(ctx, rc) + for { + response := responses(ctx) + if response == nil { + break + } + + c.sendResponse(msg.id, response) + } + + // complete and context cancel comes from the defer + }() +} + +func (c *wsConnection) sendResponse(id string, response *graphql.Response) { + b, err := json.Marshal(response) + if err != nil { + panic(err) + } + c.write(&message{ + payload: b, + id: id, + t: dataMessageType, + }) +} + +func (c *wsConnection) complete(id string) { + c.write(&message{id: id, t: completeMessageType}) +} + +func (c *wsConnection) sendError(id string, errors ...*gqlerror.Error) { + errs := make([]error, len(errors)) + for i, err := range errors { + errs[i] = err + } + b, err := json.Marshal(errs) + if err != nil { + panic(err) + } + c.write(&message{t: errorMessageType, id: id, payload: b}) +} + +func (c *wsConnection) sendConnectionError(format string, args ...interface{}) { + b, err := json.Marshal(&gqlerror.Error{Message: fmt.Sprintf(format, args...)}) + if err != nil { + panic(err) + } + + c.write(&message{t: connectionErrorMessageType, payload: b}) +} + +func (c *wsConnection) close(closeCode int, message string) { + c.mu.Lock() + if c.closed { + c.mu.Unlock() + return + } + _ = c.conn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(closeCode, message)) + for _, closer := range c.active { + closer() + } + c.closed = true + c.mu.Unlock() + _ = c.conn.Close() + + if c.CloseFunc != nil { + c.CloseFunc(c.ctx, closeCode) + } +} diff --git a/graphql/handler/transport/websocket_close_reason.go b/graphql/handler/transport/websocket_close_reason.go new file mode 100644 index 0000000..c8217de --- /dev/null +++ b/graphql/handler/transport/websocket_close_reason.go @@ -0,0 +1,22 @@ +package transport + +import ( + "context" +) + +// A private key for context that only this package can access. This is important +// to prevent collisions between different context uses +var closeReasonCtxKey = &wsCloseReasonContextKey{"close-reason"} + +type wsCloseReasonContextKey struct { + name string +} + +func AppendCloseReason(ctx context.Context, reason string) context.Context { + return context.WithValue(ctx, closeReasonCtxKey, reason) +} + +func closeReasonForContext(ctx context.Context) string { + reason, _ := ctx.Value(closeReasonCtxKey).(string) + return reason +} diff --git a/graphql/handler/transport/websocket_graphql_transport_ws.go b/graphql/handler/transport/websocket_graphql_transport_ws.go new file mode 100644 index 0000000..bfb1254 --- /dev/null +++ b/graphql/handler/transport/websocket_graphql_transport_ws.go @@ -0,0 +1,149 @@ +package transport + +import ( + "encoding/json" + "fmt" + + "github.com/gorilla/websocket" +) + +// https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md +const ( + graphqltransportwsSubprotocol = "graphql-transport-ws" + + graphqltransportwsConnectionInitMsg = graphqltransportwsMessageType("connection_init") + graphqltransportwsConnectionAckMsg = graphqltransportwsMessageType("connection_ack") + graphqltransportwsSubscribeMsg = graphqltransportwsMessageType("subscribe") + graphqltransportwsNextMsg = graphqltransportwsMessageType("next") + graphqltransportwsErrorMsg = graphqltransportwsMessageType("error") + graphqltransportwsCompleteMsg = graphqltransportwsMessageType("complete") + graphqltransportwsPingMsg = graphqltransportwsMessageType("ping") + graphqltransportwsPongMsg = graphqltransportwsMessageType("pong") +) + +var allGraphqltransportwsMessageTypes = []graphqltransportwsMessageType{ + graphqltransportwsConnectionInitMsg, + graphqltransportwsConnectionAckMsg, + graphqltransportwsSubscribeMsg, + graphqltransportwsNextMsg, + graphqltransportwsErrorMsg, + graphqltransportwsCompleteMsg, + graphqltransportwsPingMsg, + graphqltransportwsPongMsg, +} + +type ( + graphqltransportwsMessageExchanger struct { + c *websocket.Conn + } + + graphqltransportwsMessage struct { + Payload json.RawMessage `json:"payload,omitempty"` + ID string `json:"id,omitempty"` + Type graphqltransportwsMessageType `json:"type"` + noOp bool + } + + graphqltransportwsMessageType string +) + +func (me graphqltransportwsMessageExchanger) NextMessage() (message, error) { + _, r, err := me.c.NextReader() + if err != nil { + return message{}, handleNextReaderError(err) + } + + var graphqltransportwsMessage graphqltransportwsMessage + if err := jsonDecode(r, &graphqltransportwsMessage); err != nil { + return message{}, errInvalidMsg + } + + return graphqltransportwsMessage.toMessage() +} + +func (me graphqltransportwsMessageExchanger) Send(m *message) error { + msg := &graphqltransportwsMessage{} + if err := msg.fromMessage(m); err != nil { + return err + } + + if msg.noOp { + return nil + } + + return me.c.WriteJSON(msg) +} + +func (t *graphqltransportwsMessageType) UnmarshalText(text []byte) (err error) { + var found bool + for _, candidate := range allGraphqltransportwsMessageTypes { + if string(candidate) == string(text) { + *t = candidate + found = true + break + } + } + + if !found { + err = fmt.Errorf("invalid message type %s", string(text)) + } + + return err +} + +func (t graphqltransportwsMessageType) MarshalText() ([]byte, error) { + return []byte(string(t)), nil +} + +func (m graphqltransportwsMessage) toMessage() (message, error) { + var t messageType + var err error + switch m.Type { + default: + err = fmt.Errorf("invalid client->server message type %s", m.Type) + case graphqltransportwsConnectionInitMsg: + t = initMessageType + case graphqltransportwsSubscribeMsg: + t = startMessageType + case graphqltransportwsCompleteMsg: + t = stopMessageType + case graphqltransportwsPingMsg: + t = pingMessageType + case graphqltransportwsPongMsg: + t = pongMessageType + } + + return message{ + payload: m.Payload, + id: m.ID, + t: t, + }, err +} + +func (m *graphqltransportwsMessage) fromMessage(msg *message) (err error) { + m.ID = msg.id + m.Payload = msg.payload + + switch msg.t { + default: + err = fmt.Errorf("invalid server->client message type %s", msg.t) + case connectionAckMessageType: + m.Type = graphqltransportwsConnectionAckMsg + case keepAliveMessageType: + m.noOp = true + case connectionErrorMessageType: + m.noOp = true + case dataMessageType: + m.Type = graphqltransportwsNextMsg + case completeMessageType: + m.Type = graphqltransportwsCompleteMsg + case errorMessageType: + m.Type = graphqltransportwsErrorMsg + case pingMessageType: + m.Type = graphqltransportwsPingMsg + case pongMessageType: + m.Type = graphqltransportwsPongMsg + } + + return err +} diff --git a/graphql/handler/transport/websocket_graphqlws.go b/graphql/handler/transport/websocket_graphqlws.go new file mode 100644 index 0000000..d690cec --- /dev/null +++ b/graphql/handler/transport/websocket_graphqlws.go @@ -0,0 +1,171 @@ +package transport + +import ( + "encoding/json" + "fmt" + + "github.com/gorilla/websocket" +) + +// https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md +const ( + graphqlwsSubprotocol = "graphql-ws" + + graphqlwsConnectionInitMsg = graphqlwsMessageType("connection_init") + graphqlwsConnectionTerminateMsg = graphqlwsMessageType("connection_terminate") + graphqlwsStartMsg = graphqlwsMessageType("start") + graphqlwsStopMsg = graphqlwsMessageType("stop") + graphqlwsConnectionAckMsg = graphqlwsMessageType("connection_ack") + graphqlwsConnectionErrorMsg = graphqlwsMessageType("connection_error") + graphqlwsDataMsg = graphqlwsMessageType("data") + graphqlwsErrorMsg = graphqlwsMessageType("error") + graphqlwsCompleteMsg = graphqlwsMessageType("complete") + graphqlwsConnectionKeepAliveMsg = graphqlwsMessageType("ka") +) + +var allGraphqlwsMessageTypes = []graphqlwsMessageType{ + graphqlwsConnectionInitMsg, + graphqlwsConnectionTerminateMsg, + graphqlwsStartMsg, + graphqlwsStopMsg, + graphqlwsConnectionAckMsg, + graphqlwsConnectionErrorMsg, + graphqlwsDataMsg, + graphqlwsErrorMsg, + graphqlwsCompleteMsg, + graphqlwsConnectionKeepAliveMsg, +} + +type ( + graphqlwsMessageExchanger struct { + c *websocket.Conn + } + + graphqlwsMessage struct { + Payload json.RawMessage `json:"payload,omitempty"` + ID string `json:"id,omitempty"` + Type graphqlwsMessageType `json:"type"` + noOp bool + } + + graphqlwsMessageType string +) + +func (me graphqlwsMessageExchanger) NextMessage() (message, error) { + _, r, err := me.c.NextReader() + if err != nil { + return message{}, handleNextReaderError(err) + } + + var graphqlwsMessage graphqlwsMessage + if err := jsonDecode(r, &graphqlwsMessage); err != nil { + return message{}, errInvalidMsg + } + + return graphqlwsMessage.toMessage() +} + +func (me graphqlwsMessageExchanger) Send(m *message) error { + msg := &graphqlwsMessage{} + if err := msg.fromMessage(m); err != nil { + return err + } + + if msg.noOp { + return nil + } + + return me.c.WriteJSON(msg) +} + +func (t *graphqlwsMessageType) UnmarshalText(text []byte) (err error) { + var found bool + for _, candidate := range allGraphqlwsMessageTypes { + if string(candidate) == string(text) { + *t = candidate + found = true + break + } + } + + if !found { + err = fmt.Errorf("invalid message type %s", string(text)) + } + + return err +} + +func (t graphqlwsMessageType) MarshalText() ([]byte, error) { + return []byte(string(t)), nil +} + +func (m graphqlwsMessage) toMessage() (message, error) { + var t messageType + var err error + switch m.Type { + default: + err = fmt.Errorf("invalid client->server message type %s", m.Type) + case graphqlwsConnectionInitMsg: + t = initMessageType + case graphqlwsConnectionTerminateMsg: + t = connectionCloseMessageType + case graphqlwsStartMsg: + t = startMessageType + case graphqlwsStopMsg: + t = stopMessageType + case graphqlwsConnectionAckMsg: + t = connectionAckMessageType + case graphqlwsConnectionErrorMsg: + t = connectionErrorMessageType + case graphqlwsDataMsg: + t = dataMessageType + case graphqlwsErrorMsg: + t = errorMessageType + case graphqlwsCompleteMsg: + t = completeMessageType + case graphqlwsConnectionKeepAliveMsg: + t = keepAliveMessageType + } + + return message{ + payload: m.Payload, + id: m.ID, + t: t, + }, err +} + +func (m *graphqlwsMessage) fromMessage(msg *message) (err error) { + m.ID = msg.id + m.Payload = msg.payload + + switch msg.t { + default: + err = fmt.Errorf("invalid server->client message type %s", msg.t) + case initMessageType: + m.Type = graphqlwsConnectionInitMsg + case connectionAckMessageType: + m.Type = graphqlwsConnectionAckMsg + case keepAliveMessageType: + m.Type = graphqlwsConnectionKeepAliveMsg + case connectionErrorMessageType: + m.Type = graphqlwsConnectionErrorMsg + case connectionCloseMessageType: + m.Type = graphqlwsConnectionTerminateMsg + case startMessageType: + m.Type = graphqlwsStartMsg + case stopMessageType: + m.Type = graphqlwsStopMsg + case dataMessageType: + m.Type = graphqlwsDataMsg + case completeMessageType: + m.Type = graphqlwsCompleteMsg + case errorMessageType: + m.Type = graphqlwsErrorMsg + case pingMessageType: + m.noOp = true + case pongMessageType: + m.noOp = true + } + + return err +} diff --git a/graphql/handler/transport/websocket_init.go b/graphql/handler/transport/websocket_init.go new file mode 100644 index 0000000..a5f84ba --- /dev/null +++ b/graphql/handler/transport/websocket_init.go @@ -0,0 +1,57 @@ +package transport + +import "context" + +type key string + +const ( + initpayload key = "ws_initpayload_context" +) + +// InitPayload is a structure that is parsed from the websocket init message payload. TO use +// request headers for non-websocket, instead wrap the graphql handler in a middleware. +type InitPayload map[string]interface{} + +// GetString safely gets a string value from the payload. It returns an empty string if the +// payload is nil or the value isn't set. +func (p InitPayload) GetString(key string) string { + if p == nil { + return "" + } + + if value, ok := p[key]; ok { + res, _ := value.(string) + return res + } + + return "" +} + +// Authorization is a short hand for getting the Authorization header from the +// payload. +func (p InitPayload) Authorization() string { + if value := p.GetString("Authorization"); value != "" { + return value + } + + if value := p.GetString("authorization"); value != "" { + return value + } + + return "" +} + +func withInitPayload(ctx context.Context, payload InitPayload) context.Context { + return context.WithValue(ctx, initpayload, payload) +} + +// GetInitPayload gets a map of the data sent with the connection_init message, which is used by +// graphql clients as a stand-in for HTTP headers. +func GetInitPayload(ctx context.Context) InitPayload { + payload, ok := ctx.Value(initpayload).(InitPayload) + if !ok { + return nil + } + + return payload +} diff --git a/graphql/handler/transport/websocket_resolver_error.go b/graphql/handler/transport/websocket_resolver_error.go new file mode 100644 index 0000000..5db4e8a --- /dev/null +++ b/graphql/handler/transport/websocket_resolver_error.go @@ -0,0 +1,69 @@ +package transport + +import ( + "context" + + "github.com/vektah/gqlparser/v2/gqlerror" +) + +// A private key for context that only this package can access. This is important +// to prevent collisions between different context uses +var wsSubscriptionErrorCtxKey = &wsSubscriptionErrorContextKey{"subscription-error"} + +type wsSubscriptionErrorContextKey struct { + name string +} + +type subscriptionError struct { + errs []*gqlerror.Error +} + +// AddSubscriptionError is used to let websocket return an error message after subscription resolver returns a channel. +// for example: +// +// func (r *subscriptionResolver) Method(ctx context.Context) (<-chan *model.Message, error) { +// ch := make(chan *model.Message) +// go func() { +// defer func() { +// close(ch) +// } +// // some kind of block processing (e.g.: gRPC client streaming) +// stream, err := gRPCClientStreamRequest(ctx) +// if err != nil { +// transport.AddSubscriptionError(ctx, err) +// return // must return and close channel so websocket can send error back +// } +// for { +// m, err := stream.Recv() +// if err == io.EOF { +// return +// } +// if err != nil { +// transport.AddSubscriptionError(ctx, err) +// return // must return and close channel so websocket can send error back +// } +// ch <- m +// } +// }() +// +// return ch, nil +// } +// +// see https://github.com/niko0xdev/gqlgen/pull/2506 for more details +func AddSubscriptionError(ctx context.Context, err *gqlerror.Error) { + subscriptionErrStruct := getSubscriptionErrorStruct(ctx) + subscriptionErrStruct.errs = append(subscriptionErrStruct.errs, err) +} + +func withSubscriptionErrorContext(ctx context.Context) context.Context { + return context.WithValue(ctx, wsSubscriptionErrorCtxKey, &subscriptionError{}) +} + +func getSubscriptionErrorStruct(ctx context.Context) *subscriptionError { + v, _ := ctx.Value(wsSubscriptionErrorCtxKey).(*subscriptionError) + return v +} + +func getSubscriptionError(ctx context.Context) []*gqlerror.Error { + return getSubscriptionErrorStruct(ctx).errs +} diff --git a/graphql/handler/transport/websocket_subprotocol.go b/graphql/handler/transport/websocket_subprotocol.go new file mode 100644 index 0000000..c02098a --- /dev/null +++ b/graphql/handler/transport/websocket_subprotocol.go @@ -0,0 +1,116 @@ +package transport + +import ( + "encoding/json" + "errors" + + "github.com/gorilla/websocket" +) + +const ( + initMessageType messageType = iota + connectionAckMessageType + keepAliveMessageType + connectionErrorMessageType + connectionCloseMessageType + startMessageType + stopMessageType + dataMessageType + completeMessageType + errorMessageType + pingMessageType + pongMessageType +) + +var ( + supportedSubprotocols = []string{ + graphqlwsSubprotocol, + graphqltransportwsSubprotocol, + } + + errWsConnClosed = errors.New("websocket connection closed") + errInvalidMsg = errors.New("invalid message received") +) + +type ( + messageType int + message struct { + payload json.RawMessage + id string + t messageType + } + messageExchanger interface { + NextMessage() (message, error) + Send(m *message) error + } +) + +func (t messageType) String() string { + var text string + switch t { + default: + text = "unknown" + case initMessageType: + text = "init" + case connectionAckMessageType: + text = "connection ack" + case keepAliveMessageType: + text = "keep alive" + case connectionErrorMessageType: + text = "connection error" + case connectionCloseMessageType: + text = "connection close" + case startMessageType: + text = "start" + case stopMessageType: + text = "stop subscription" + case dataMessageType: + text = "data" + case completeMessageType: + text = "complete" + case errorMessageType: + text = "error" + case pingMessageType: + text = "ping" + case pongMessageType: + text = "pong" + } + return text +} + +func contains(list []string, elem string) bool { + for _, e := range list { + if e == elem { + return true + } + } + + return false +} + +func (t *Websocket) injectGraphQLWSSubprotocols() { + // the list of subprotocols is specified by the consumer of the Websocket struct, + // in order to preserve backward compatibility, we inject the graphql specific subprotocols + // at runtime + if !t.didInjectSubprotocols { + defer func() { + t.didInjectSubprotocols = true + }() + + for _, subprotocol := range supportedSubprotocols { + if !contains(t.Upgrader.Subprotocols, subprotocol) { + t.Upgrader.Subprotocols = append(t.Upgrader.Subprotocols, subprotocol) + } + } + } +} + +func handleNextReaderError(err error) error { + // TODO: should we consider all closure scenarios here for the ws connection? + // for now we only list the error codes from the previous implementation + if websocket.IsCloseError(err, websocket.CloseNormalClosure, websocket.CloseNoStatusReceived) { + return errWsConnClosed + } + + return err +} diff --git a/graphql/handler/transport/websocket_test.go b/graphql/handler/transport/websocket_test.go new file mode 100644 index 0000000..a948bf5 --- /dev/null +++ b/graphql/handler/transport/websocket_test.go @@ -0,0 +1,865 @@ +package transport_test + +import ( + "context" + "encoding/json" + "errors" + "net/http" + "net/http/httptest" + "strings" + "testing" + "time" + + "github.com/gorilla/websocket" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/handler/testserver" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" +) + +type ckey string + +func TestWebsocket(t *testing.T) { + handler := testserver.New() + handler.AddTransport(transport.Websocket{}) + + srv := httptest.NewServer(handler) + defer srv.Close() + + t.Run("client must send valid json", func(t *testing.T) { + c := wsConnect(srv.URL) + defer c.Close() + + writeRaw(c, "hello") + + msg := readOp(c) + assert.Equal(t, "connection_error", msg.Type) + assert.Equal(t, `{"message":"invalid json"}`, string(msg.Payload)) + }) + + t.Run("client can terminate before init", func(t *testing.T) { + c := wsConnect(srv.URL) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionTerminateMsg})) + + _, _, err := c.ReadMessage() + assert.Equal(t, websocket.CloseNormalClosure, err.(*websocket.CloseError).Code) + }) + + t.Run("client must send init first", func(t *testing.T) { + c := wsConnect(srv.URL) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: startMsg})) + + msg := readOp(c) + assert.Equal(t, connectionErrorMsg, msg.Type) + assert.Equal(t, `{"message":"unexpected message start"}`, string(msg.Payload)) + }) + + t.Run("server acks init", func(t *testing.T) { + c := wsConnect(srv.URL) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + + assert.Equal(t, connectionAckMsg, readOp(c).Type) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + }) + + t.Run("client can terminate before run", func(t *testing.T) { + c := wsConnect(srv.URL) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + assert.Equal(t, connectionAckMsg, readOp(c).Type) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionTerminateMsg})) + + _, _, err := c.ReadMessage() + assert.Equal(t, websocket.CloseNormalClosure, err.(*websocket.CloseError).Code) + }) + + t.Run("client gets parse errors", func(t *testing.T) { + c := wsConnect(srv.URL) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + assert.Equal(t, connectionAckMsg, readOp(c).Type) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + + require.NoError(t, c.WriteJSON(&operationMessage{ + Type: startMsg, + ID: "test_1", + Payload: json.RawMessage(`{"query": "!"}`), + })) + + msg := readOp(c) + assert.Equal(t, errorMsg, msg.Type) + assert.Equal(t, `[{"message":"Unexpected !","locations":[{"line":1,"column":1}],"extensions":{"code":"GRAPHQL_PARSE_FAILED"}}]`, string(msg.Payload)) + }) + + t.Run("client can receive data", func(t *testing.T) { + c := wsConnect(srv.URL) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + assert.Equal(t, connectionAckMsg, readOp(c).Type) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + + require.NoError(t, c.WriteJSON(&operationMessage{ + Type: startMsg, + ID: "test_1", + Payload: json.RawMessage(`{"query": "subscription { name }"}`), + })) + + handler.SendNextSubscriptionMessage() + msg := readOp(c) + require.Equal(t, dataMsg, msg.Type, string(msg.Payload)) + require.Equal(t, "test_1", msg.ID, string(msg.Payload)) + require.Equal(t, `{"data":{"name":"test"}}`, string(msg.Payload)) + + handler.SendNextSubscriptionMessage() + msg = readOp(c) + require.Equal(t, dataMsg, msg.Type, string(msg.Payload)) + require.Equal(t, "test_1", msg.ID, string(msg.Payload)) + require.Equal(t, `{"data":{"name":"test"}}`, string(msg.Payload)) + + require.NoError(t, c.WriteJSON(&operationMessage{Type: stopMsg, ID: "test_1"})) + + msg = readOp(c) + require.Equal(t, completeMsg, msg.Type) + require.Equal(t, "test_1", msg.ID) + + // At this point we should be done and should not receive another message. + c.SetReadDeadline(time.Now().UTC().Add(1 * time.Millisecond)) + + err := c.ReadJSON(&msg) + if err == nil { + // This should not send a second close message for the same id. + require.NotEqual(t, completeMsg, msg.Type) + require.NotEqual(t, "test_1", msg.ID) + } else { + assert.Contains(t, err.Error(), "timeout") + } + }) +} + +func TestWebsocketWithKeepAlive(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.Websocket{ + KeepAlivePingInterval: 100 * time.Millisecond, + }) + + srv := httptest.NewServer(h) + defer srv.Close() + + c := wsConnect(srv.URL) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + assert.Equal(t, connectionAckMsg, readOp(c).Type) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + + require.NoError(t, c.WriteJSON(&operationMessage{ + Type: startMsg, + ID: "test_1", + Payload: json.RawMessage(`{"query": "subscription { name }"}`), + })) + + // keepalive + msg := readOp(c) + assert.Equal(t, connectionKeepAliveMsg, msg.Type) + + // server message + h.SendNextSubscriptionMessage() + msg = readOp(c) + assert.Equal(t, dataMsg, msg.Type) + + // keepalive + msg = readOp(c) + assert.Equal(t, connectionKeepAliveMsg, msg.Type) +} + +func TestWebsocketInitFunc(t *testing.T) { + t.Run("accept connection if WebsocketInitFunc is NOT provided", func(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.Websocket{}) + srv := httptest.NewServer(h) + defer srv.Close() + + c := wsConnect(srv.URL) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + + assert.Equal(t, connectionAckMsg, readOp(c).Type) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + }) + + t.Run("accept connection if WebsocketInitFunc is provided and is accepting connection", func(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.Websocket{ + InitFunc: func(ctx context.Context, initPayload transport.InitPayload) (context.Context, *transport.InitPayload, error) { + return context.WithValue(ctx, ckey("newkey"), "newvalue"), nil, nil + }, + }) + srv := httptest.NewServer(h) + defer srv.Close() + + c := wsConnect(srv.URL) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + + assert.Equal(t, connectionAckMsg, readOp(c).Type) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + }) + + t.Run("reject connection if WebsocketInitFunc is provided and is accepting connection", func(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.Websocket{ + InitFunc: func(ctx context.Context, initPayload transport.InitPayload) (context.Context, *transport.InitPayload, error) { + return ctx, nil, errors.New("invalid init payload") + }, + }) + srv := httptest.NewServer(h) + defer srv.Close() + + c := wsConnect(srv.URL) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + + msg := readOp(c) + assert.Equal(t, connectionErrorMsg, msg.Type) + assert.Equal(t, `{"message":"invalid init payload"}`, string(msg.Payload)) + }) + + t.Run("can return context for request from WebsocketInitFunc", func(t *testing.T) { + es := &graphql.ExecutableSchemaMock{ + ExecFunc: func(ctx context.Context) graphql.ResponseHandler { + assert.Equal(t, "newvalue", ctx.Value(ckey("newkey"))) + return graphql.OneShot(&graphql.Response{Data: []byte(`{"empty":"ok"}`)}) + }, + SchemaFunc: func() *ast.Schema { + return gqlparser.MustLoadSchema(&ast.Source{Input: ` + schema { query: Query } + type Query { + empty: String + } + `}) + }, + } + h := handler.New(es) + + h.AddTransport(transport.Websocket{ + InitFunc: func(ctx context.Context, initPayload transport.InitPayload) (context.Context, *transport.InitPayload, error) { + return context.WithValue(ctx, ckey("newkey"), "newvalue"), nil, nil + }, + }) + + c := client.New(h) + + socket := c.Websocket("{ empty } ") + defer socket.Close() + var resp struct { + Empty string + } + err := socket.Next(&resp) + require.NoError(t, err) + assert.Equal(t, "ok", resp.Empty) + }) + + t.Run("can set a deadline on a websocket connection and close it with a reason", func(t *testing.T) { + h := testserver.New() + var cancel func() + h.AddTransport(transport.Websocket{ + InitFunc: func(ctx context.Context, _ transport.InitPayload) (newCtx context.Context, _ *transport.InitPayload, _ error) { + newCtx, cancel = context.WithTimeout(transport.AppendCloseReason(ctx, "beep boop"), time.Millisecond*5) + return + }, + }) + srv := httptest.NewServer(h) + defer srv.Close() + + c := wsConnect(srv.URL) + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + assert.Equal(t, connectionAckMsg, readOp(c).Type) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + + // Cancel should contain an actual value now, so let's call it when we exit this scope (to make the linter happy) + defer cancel() + + time.Sleep(time.Millisecond * 10) + m := readOp(c) + assert.Equal(t, m.Type, connectionErrorMsg) + assert.Equal(t, string(m.Payload), `{"message":"beep boop"}`) + }) + t.Run("accept connection if WebsocketInitFunc is provided and is accepting connection", func(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.Websocket{ + InitFunc: func(ctx context.Context, initPayload transport.InitPayload) (context.Context, *transport.InitPayload, error) { + initResponsePayload := transport.InitPayload{"trackingId": "123-456"} + return context.WithValue(ctx, ckey("newkey"), "newvalue"), &initResponsePayload, nil + }, + }) + srv := httptest.NewServer(h) + defer srv.Close() + + c := wsConnect(srv.URL) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + + connAck := readOp(c) + assert.Equal(t, connectionAckMsg, connAck.Type) + + var payload map[string]interface{} + err := json.Unmarshal(connAck.Payload, &payload) + if err != nil { + t.Fatal("Unexpected Error", err) + } + assert.EqualValues(t, "123-456", payload["trackingId"]) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + }) +} + +func TestWebSocketInitTimeout(t *testing.T) { + t.Run("times out if no init message is received within the configured duration", func(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.Websocket{ + InitTimeout: 5 * time.Millisecond, + }) + srv := httptest.NewServer(h) + defer srv.Close() + + c := wsConnect(srv.URL) + defer c.Close() + + var msg operationMessage + err := c.ReadJSON(&msg) + assert.Error(t, err) + assert.Contains(t, err.Error(), "timeout") + }) + + t.Run("keeps waiting for an init message if no time out is configured", func(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.Websocket{}) + srv := httptest.NewServer(h) + defer srv.Close() + + c := wsConnect(srv.URL) + defer c.Close() + + done := make(chan interface{}, 1) + go func() { + var msg operationMessage + _ = c.ReadJSON(&msg) + done <- 1 + }() + + select { + case <-done: + assert.Fail(t, "web socket read operation finished while it shouldn't have") + case <-time.After(100 * time.Millisecond): + // Success! I guess? Can't really wait forever to see if the read waits forever... + } + }) +} + +func TestWebSocketErrorFunc(t *testing.T) { + t.Run("the error handler gets called when an error occurs", func(t *testing.T) { + errFuncCalled := make(chan bool, 1) + h := testserver.New() + h.AddTransport(transport.Websocket{ + ErrorFunc: func(_ context.Context, err error) { + require.Error(t, err) + assert.Equal(t, err.Error(), "websocket read: invalid message received") + assert.IsType(t, transport.WebsocketError{}, err) + assert.True(t, err.(transport.WebsocketError).IsReadError) + errFuncCalled <- true + }, + }) + + srv := httptest.NewServer(h) + defer srv.Close() + + c := wsConnect(srv.URL) + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + assert.Equal(t, connectionAckMsg, readOp(c).Type) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + require.NoError(t, c.WriteMessage(websocket.TextMessage, []byte("mark my words, you will regret this"))) + + select { + case res := <-errFuncCalled: + assert.True(t, res) + case <-time.NewTimer(time.Millisecond * 20).C: + assert.Fail(t, "The fail handler was not called in time") + } + }) + + t.Run("init func errors do not call the error handler", func(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.Websocket{ + InitFunc: func(ctx context.Context, _ transport.InitPayload) (context.Context, *transport.InitPayload, error) { + return ctx, nil, errors.New("this is not what we agreed upon") + }, + ErrorFunc: func(_ context.Context, err error) { + assert.Fail(t, "the error handler got called when it shouldn't have", "error: "+err.Error()) + }, + }) + srv := httptest.NewServer(h) + defer srv.Close() + + c := wsConnect(srv.URL) + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + time.Sleep(time.Millisecond * 20) + }) + + t.Run("init func context closes do not call the error handler", func(t *testing.T) { + h := testserver.New() + h.AddTransport(transport.Websocket{ + InitFunc: func(ctx context.Context, _ transport.InitPayload) (context.Context, *transport.InitPayload, error) { + newCtx, cancel := context.WithCancel(ctx) + time.AfterFunc(time.Millisecond*5, cancel) + return newCtx, nil, nil + }, + ErrorFunc: func(_ context.Context, err error) { + assert.Fail(t, "the error handler got called when it shouldn't have", "error: "+err.Error()) + }, + }) + srv := httptest.NewServer(h) + defer srv.Close() + + c := wsConnect(srv.URL) + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + assert.Equal(t, connectionAckMsg, readOp(c).Type) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + time.Sleep(time.Millisecond * 20) + }) + + t.Run("init func context deadlines do not call the error handler", func(t *testing.T) { + h := testserver.New() + var cancel func() + h.AddTransport(transport.Websocket{ + InitFunc: func(ctx context.Context, _ transport.InitPayload) (newCtx context.Context, _ *transport.InitPayload, _ error) { + newCtx, cancel = context.WithDeadline(ctx, time.Now().Add(time.Millisecond*5)) + return newCtx, nil, nil + }, + ErrorFunc: func(_ context.Context, err error) { + assert.Fail(t, "the error handler got called when it shouldn't have", "error: "+err.Error()) + }, + }) + srv := httptest.NewServer(h) + defer srv.Close() + + c := wsConnect(srv.URL) + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + assert.Equal(t, connectionAckMsg, readOp(c).Type) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + + // Cancel should contain an actual value now, so let's call it when we exit this scope (to make the linter happy) + defer cancel() + + time.Sleep(time.Millisecond * 20) + }) +} + +func TestWebSocketCloseFunc(t *testing.T) { + t.Run("the on close handler gets called when the websocket is closed", func(t *testing.T) { + closeFuncCalled := make(chan bool, 1) + h := testserver.New() + h.AddTransport(transport.Websocket{ + CloseFunc: func(_ context.Context, _closeCode int) { + closeFuncCalled <- true + }, + }) + + srv := httptest.NewServer(h) + defer srv.Close() + + c := wsConnect(srv.URL) + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + assert.Equal(t, connectionAckMsg, readOp(c).Type) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionTerminateMsg})) + + select { + case res := <-closeFuncCalled: + assert.True(t, res) + case <-time.NewTimer(time.Millisecond * 20).C: + assert.Fail(t, "The close handler was not called in time") + } + }) + + t.Run("the on close handler gets called only once when the websocket is closed", func(t *testing.T) { + closeFuncCalled := make(chan bool, 1) + h := testserver.New() + h.AddTransport(transport.Websocket{ + CloseFunc: func(_ context.Context, _closeCode int) { + closeFuncCalled <- true + }, + }) + + srv := httptest.NewServer(h) + defer srv.Close() + + c := wsConnect(srv.URL) + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + assert.Equal(t, connectionAckMsg, readOp(c).Type) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionTerminateMsg})) + + select { + case res := <-closeFuncCalled: + assert.True(t, res) + case <-time.NewTimer(time.Millisecond * 20).C: + assert.Fail(t, "The close handler was not called in time") + } + + select { + case <-closeFuncCalled: + assert.Fail(t, "The close handler was called more than once") + case <-time.NewTimer(time.Millisecond * 20).C: + // ok + } + }) + + t.Run("init func errors call the close handler", func(t *testing.T) { + h := testserver.New() + closeFuncCalled := make(chan bool, 1) + h.AddTransport(transport.Websocket{ + InitFunc: func(ctx context.Context, _ transport.InitPayload) (context.Context, *transport.InitPayload, error) { + return ctx, nil, errors.New("error during init") + }, + CloseFunc: func(_ context.Context, _closeCode int) { + closeFuncCalled <- true + }, + }) + srv := httptest.NewServer(h) + defer srv.Close() + + c := wsConnect(srv.URL) + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + select { + case res := <-closeFuncCalled: + assert.True(t, res) + case <-time.NewTimer(time.Millisecond * 20).C: + assert.Fail(t, "The close handler was not called in time") + } + }) +} + +func TestWebsocketGraphqltransportwsSubprotocol(t *testing.T) { + initialize := func(ws transport.Websocket) (*testserver.TestServer, *httptest.Server) { + h := testserver.New() + h.AddTransport(ws) + return h, httptest.NewServer(h) + } + + t.Run("server acks init", func(t *testing.T) { + _, srv := initialize(transport.Websocket{}) + defer srv.Close() + + c := wsConnectWithSubprocotol(srv.URL, graphqltransportwsSubprotocol) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: graphqltransportwsConnectionInitMsg})) + assert.Equal(t, graphqltransportwsConnectionAckMsg, readOp(c).Type) + }) + + t.Run("client can receive data", func(t *testing.T) { + handler, srv := initialize(transport.Websocket{}) + defer srv.Close() + + c := wsConnectWithSubprocotol(srv.URL, graphqltransportwsSubprotocol) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: graphqltransportwsConnectionInitMsg})) + assert.Equal(t, graphqltransportwsConnectionAckMsg, readOp(c).Type) + + require.NoError(t, c.WriteJSON(&operationMessage{ + Type: graphqltransportwsSubscribeMsg, + ID: "test_1", + Payload: json.RawMessage(`{"query": "subscription { name }"}`), + })) + + handler.SendNextSubscriptionMessage() + msg := readOp(c) + require.Equal(t, graphqltransportwsNextMsg, msg.Type, string(msg.Payload)) + require.Equal(t, "test_1", msg.ID, string(msg.Payload)) + require.Equal(t, `{"data":{"name":"test"}}`, string(msg.Payload)) + + handler.SendNextSubscriptionMessage() + msg = readOp(c) + require.Equal(t, graphqltransportwsNextMsg, msg.Type, string(msg.Payload)) + require.Equal(t, "test_1", msg.ID, string(msg.Payload)) + require.Equal(t, `{"data":{"name":"test"}}`, string(msg.Payload)) + + require.NoError(t, c.WriteJSON(&operationMessage{Type: graphqltransportwsCompleteMsg, ID: "test_1"})) + + msg = readOp(c) + require.Equal(t, graphqltransportwsCompleteMsg, msg.Type) + require.Equal(t, "test_1", msg.ID) + }) + + t.Run("receives no graphql-ws keep alive messages", func(t *testing.T) { + _, srv := initialize(transport.Websocket{KeepAlivePingInterval: 5 * time.Millisecond}) + defer srv.Close() + + c := wsConnectWithSubprocotol(srv.URL, graphqltransportwsSubprotocol) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: graphqltransportwsConnectionInitMsg})) + assert.Equal(t, graphqltransportwsConnectionAckMsg, readOp(c).Type) + + // If the keep-alives are sent, this deadline will not be used, and no timeout error will be found + c.SetReadDeadline(time.Now().UTC().Add(50 * time.Millisecond)) + var msg operationMessage + err := c.ReadJSON(&msg) + require.Error(t, err) + assert.Contains(t, err.Error(), "timeout") + }) +} + +func TestWebsocketWithPingPongInterval(t *testing.T) { + initialize := func(ws transport.Websocket) (*testserver.TestServer, *httptest.Server) { + h := testserver.New() + h.AddTransport(ws) + return h, httptest.NewServer(h) + } + + t.Run("client receives ping and responds with pong", func(t *testing.T) { + _, srv := initialize(transport.Websocket{PingPongInterval: 20 * time.Millisecond}) + defer srv.Close() + + c := wsConnectWithSubprocotol(srv.URL, graphqltransportwsSubprotocol) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: graphqltransportwsConnectionInitMsg})) + assert.Equal(t, graphqltransportwsConnectionAckMsg, readOp(c).Type) + + assert.Equal(t, graphqltransportwsPingMsg, readOp(c).Type) + require.NoError(t, c.WriteJSON(&operationMessage{Type: graphqltransportwsPongMsg})) + assert.Equal(t, graphqltransportwsPingMsg, readOp(c).Type) + }) + + t.Run("client sends ping and expects pong", func(t *testing.T) { + _, srv := initialize(transport.Websocket{PingPongInterval: 10 * time.Millisecond}) + defer srv.Close() + }) + + t.Run("client sends ping and expects pong", func(t *testing.T) { + _, srv := initialize(transport.Websocket{PingPongInterval: 10 * time.Millisecond}) + defer srv.Close() + + c := wsConnectWithSubprocotol(srv.URL, graphqltransportwsSubprotocol) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: graphqltransportwsConnectionInitMsg})) + assert.Equal(t, graphqltransportwsConnectionAckMsg, readOp(c).Type) + + require.NoError(t, c.WriteJSON(&operationMessage{Type: graphqltransportwsPingMsg})) + assert.Equal(t, graphqltransportwsPongMsg, readOp(c).Type) + }) + + t.Run("server closes with error if client does not pong and !MissingPongOk", func(t *testing.T) { + h := testserver.New() + closeFuncCalled := make(chan bool, 1) + h.AddTransport(transport.Websocket{ + MissingPongOk: false, // default value but beign explicit for test clarity. + PingPongInterval: 5 * time.Millisecond, + CloseFunc: func(_ context.Context, _closeCode int) { + closeFuncCalled <- true + }, + }) + + srv := httptest.NewServer(h) + defer srv.Close() + + c := wsConnectWithSubprocotol(srv.URL, graphqltransportwsSubprotocol) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: graphqltransportwsConnectionInitMsg})) + assert.Equal(t, graphqltransportwsConnectionAckMsg, readOp(c).Type) + + assert.Equal(t, graphqltransportwsPingMsg, readOp(c).Type) + + select { + case res := <-closeFuncCalled: + assert.True(t, res) + case <-time.NewTimer(time.Millisecond * 20).C: + // with a 5ms interval 10ms should be the timeout, double that to make the test less likely to flake under load + assert.Fail(t, "The close handler was not called in time") + } + }) + + t.Run("server does not close with error if client does not pong and MissingPongOk", func(t *testing.T) { + h := testserver.New() + closeFuncCalled := make(chan bool, 1) + h.AddTransport(transport.Websocket{ + MissingPongOk: true, + PingPongInterval: 10 * time.Millisecond, + CloseFunc: func(_ context.Context, _closeCode int) { + closeFuncCalled <- true + }, + }) + + srv := httptest.NewServer(h) + defer srv.Close() + + c := wsConnectWithSubprocotol(srv.URL, graphqltransportwsSubprotocol) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: graphqltransportwsConnectionInitMsg})) + assert.Equal(t, graphqltransportwsConnectionAckMsg, readOp(c).Type) + + assert.Equal(t, graphqltransportwsPingMsg, readOp(c).Type) + + select { + case <-closeFuncCalled: + assert.Fail(t, "The close handler was called even with MissingPongOk = true") + case _, ok := <-time.NewTimer(time.Millisecond * 20).C: + assert.True(t, ok) + } + }) + + t.Run("ping-pongs are not sent when the graphql-ws sub protocol is used", func(t *testing.T) { + // Regression test + // --- + // Before the refactor, the code would try to convert a ping message to a graphql-ws message type + // But since this message type does not exist in the graphql-ws sub protocol, it would fail + + _, srv := initialize(transport.Websocket{ + PingPongInterval: 5 * time.Millisecond, + KeepAlivePingInterval: 10 * time.Millisecond, + }) + defer srv.Close() + + // Create connection + c := wsConnect(srv.URL) + defer c.Close() + + // Initialize connection + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + assert.Equal(t, connectionAckMsg, readOp(c).Type) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + + // Wait for a few more keep alives to be sure nothing goes wrong + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + assert.Equal(t, connectionKeepAliveMsg, readOp(c).Type) + }) + t.Run("pong only messages are sent when configured with graphql-transport-ws", func(t *testing.T) { + + h, srv := initialize(transport.Websocket{PongOnlyInterval: 10 * time.Millisecond}) + defer srv.Close() + + c := wsConnectWithSubprocotol(srv.URL, graphqltransportwsSubprotocol) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: graphqltransportwsConnectionInitMsg})) + assert.Equal(t, graphqltransportwsConnectionAckMsg, readOp(c).Type) + + assert.Equal(t, graphqltransportwsPongMsg, readOp(c).Type) + + require.NoError(t, c.WriteJSON(&operationMessage{ + Type: graphqltransportwsSubscribeMsg, + ID: "test_1", + Payload: json.RawMessage(`{"query": "subscription { name }"}`), + })) + + // pong + msg := readOp(c) + assert.Equal(t, graphqltransportwsPongMsg, msg.Type) + + // server message + h.SendNextSubscriptionMessage() + msg = readOp(c) + require.Equal(t, graphqltransportwsNextMsg, msg.Type, string(msg.Payload)) + require.Equal(t, "test_1", msg.ID, string(msg.Payload)) + require.Equal(t, `{"data":{"name":"test"}}`, string(msg.Payload)) + + // keepalive + msg = readOp(c) + assert.Equal(t, graphqltransportwsPongMsg, msg.Type) + }) + +} + +func wsConnect(url string) *websocket.Conn { + return wsConnectWithSubprocotol(url, "") +} + +func wsConnectWithSubprocotol(url, subprocotol string) *websocket.Conn { + h := make(http.Header) + if subprocotol != "" { + h.Add("Sec-WebSocket-Protocol", subprocotol) + } + + c, resp, err := websocket.DefaultDialer.Dial(strings.ReplaceAll(url, "http://", "ws://"), h) + if err != nil { + panic(err) + } + _ = resp.Body.Close() + + return c +} + +func writeRaw(conn *websocket.Conn, msg string) { + if err := conn.WriteMessage(websocket.TextMessage, []byte(msg)); err != nil { + panic(err) + } +} + +func readOp(conn *websocket.Conn) operationMessage { + var msg operationMessage + if err := conn.ReadJSON(&msg); err != nil { + panic(err) + } + return msg +} + +// copied out from websocket_graphqlws.go to keep these private + +const ( + connectionInitMsg = "connection_init" // Client -> Server + connectionTerminateMsg = "connection_terminate" // Client -> Server + startMsg = "start" // Client -> Server + stopMsg = "stop" // Client -> Server + connectionAckMsg = "connection_ack" // Server -> Client + connectionErrorMsg = "connection_error" // Server -> Client + dataMsg = "data" // Server -> Client + errorMsg = "error" // Server -> Client + completeMsg = "complete" // Server -> Client + connectionKeepAliveMsg = "ka" // Server -> Client +) + +// copied out from websocket_graphql_transport_ws.go to keep these private + +const ( + graphqltransportwsSubprotocol = "graphql-transport-ws" + + graphqltransportwsConnectionInitMsg = "connection_init" + graphqltransportwsConnectionAckMsg = "connection_ack" + graphqltransportwsSubscribeMsg = "subscribe" + graphqltransportwsNextMsg = "next" + graphqltransportwsCompleteMsg = "complete" + graphqltransportwsPingMsg = "ping" + graphqltransportwsPongMsg = "pong" +) + +type operationMessage struct { + Payload json.RawMessage `json:"payload,omitempty"` + ID string `json:"id,omitempty"` + Type string `json:"type"` +} diff --git a/graphql/handler_test.go b/graphql/handler_test.go new file mode 100644 index 0000000..3ba421f --- /dev/null +++ b/graphql/handler_test.go @@ -0,0 +1,92 @@ +package graphql + +import ( + "os" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestAddUploadToOperations(t *testing.T) { + key := "0" + + t.Run("fail missing all variables", func(t *testing.T) { + file, _ := os.Open("path/to/file") + params := &RawParams{} + + upload := Upload{ + File: file, + Filename: "a.txt", + Size: int64(5), + ContentType: "text/plain", + } + path := "variables.req.0.file" + err := params.AddUpload(upload, key, path) + require.NotNil(t, err) + require.Equal(t, "input: path is missing \"variables.\" prefix, key: 0, path: variables.req.0.file", err.Error()) + }) + + t.Run("valid variable", func(t *testing.T) { + file, _ := os.Open("path/to/file") + request := &RawParams{ + Variables: map[string]interface{}{ + "file": nil, + }, + } + + upload := Upload{ + File: file, + Filename: "a.txt", + Size: int64(5), + ContentType: "text/plain", + } + + expected := &RawParams{ + Variables: map[string]interface{}{ + "file": upload, + }, + } + + path := "variables.file" + err := request.AddUpload(upload, key, path) + require.Nil(t, err) + + require.Equal(t, request, expected) + }) + + t.Run("valid nested variable", func(t *testing.T) { + file, _ := os.Open("path/to/file") + request := &RawParams{ + Variables: map[string]interface{}{ + "req": []interface{}{ + map[string]interface{}{ + "file": nil, + }, + }, + }, + } + + upload := Upload{ + File: file, + Filename: "a.txt", + Size: int64(5), + ContentType: "text/plain", + } + + expected := &RawParams{ + Variables: map[string]interface{}{ + "req": []interface{}{ + map[string]interface{}{ + "file": upload, + }, + }, + }, + } + + path := "variables.req.0.file" + err := request.AddUpload(upload, key, path) + require.Nil(t, err) + + require.Equal(t, request, expected) + }) +} diff --git a/graphql/id.go b/graphql/id.go new file mode 100644 index 0000000..b24605d --- /dev/null +++ b/graphql/id.go @@ -0,0 +1,58 @@ +package graphql + +import ( + "encoding/json" + "fmt" + "io" + "strconv" +) + +func MarshalID(s string) Marshaler { + return MarshalString(s) +} + +func UnmarshalID(v interface{}) (string, error) { + switch v := v.(type) { + case string: + return v, nil + case json.Number: + return string(v), nil + case int: + return strconv.Itoa(v), nil + case int64: + return strconv.FormatInt(v, 10), nil + case float64: + return fmt.Sprintf("%f", v), nil + case bool: + if v { + return "true", nil + } else { + return "false", nil + } + case nil: + return "null", nil + default: + return "", fmt.Errorf("%T is not a string", v) + } +} + +func MarshalIntID(i int) Marshaler { + return WriterFunc(func(w io.Writer) { + writeQuotedString(w, strconv.Itoa(i)) + }) +} + +func UnmarshalIntID(v interface{}) (int, error) { + switch v := v.(type) { + case string: + return strconv.Atoi(v) + case int: + return v, nil + case int64: + return int(v), nil + case json.Number: + return strconv.Atoi(string(v)) + default: + return 0, fmt.Errorf("%T is not an int", v) + } +} diff --git a/graphql/id_test.go b/graphql/id_test.go new file mode 100644 index 0000000..89523f5 --- /dev/null +++ b/graphql/id_test.go @@ -0,0 +1,67 @@ +package graphql + +import ( + "bytes" + "math" + "testing" + + "github.com/stretchr/testify/assert" +) + +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{} + Expected string + ShouldError bool + }{ + { + Name: "int64", + Input: int64(12), + Expected: "12", + ShouldError: false, + }, + { + Name: "int64 max", + Input: math.MaxInt64, + Expected: "9223372036854775807", + }, + { + Name: "int64 min", + Input: math.MinInt64, + Expected: "-9223372036854775808", + }, + } + + for _, tt := range tests { + t.Run(tt.Name, func(t *testing.T) { + id, err := UnmarshalID(tt.Input) + + assert.Equal(t, tt.Expected, id) + if tt.ShouldError { + assert.Error(t, err) + } else { + assert.NoError(t, err) + } + }) + } +} diff --git a/graphql/input.go b/graphql/input.go new file mode 100644 index 0000000..88c3efa --- /dev/null +++ b/graphql/input.go @@ -0,0 +1,55 @@ +package graphql + +import ( + "context" + "errors" + "reflect" +) + +const unmarshalInputCtx key = "unmarshal_input_context" + +// BuildUnmarshalerMap returns a map of unmarshal functions of the ExecutableContext +// to use with the WithUnmarshalerMap function. +func BuildUnmarshalerMap(unmarshaler ...interface{}) map[reflect.Type]reflect.Value { + maps := make(map[reflect.Type]reflect.Value) + for _, v := range unmarshaler { + ft := reflect.TypeOf(v) + if ft.Kind() == reflect.Func { + maps[ft.Out(0)] = reflect.ValueOf(v) + } + } + + return maps +} + +// WithUnmarshalerMap returns a new context with a map from input types to their unmarshaler functions. +func WithUnmarshalerMap(ctx context.Context, maps map[reflect.Type]reflect.Value) context.Context { + return context.WithValue(ctx, unmarshalInputCtx, maps) +} + +// UnmarshalInputFromContext allows unmarshaling input object from a context. +func UnmarshalInputFromContext(ctx context.Context, raw, v interface{}) error { + m, ok := ctx.Value(unmarshalInputCtx).(map[reflect.Type]reflect.Value) + if m == nil || !ok { + return errors.New("graphql: the input context is empty") + } + + rv := reflect.ValueOf(v) + if rv.Kind() != reflect.Ptr || rv.IsNil() { + return errors.New("graphql: input must be a non-nil pointer") + } + if fn, ok := m[rv.Elem().Type()]; ok { + res := fn.Call([]reflect.Value{ + reflect.ValueOf(ctx), + reflect.ValueOf(raw), + }) + if err := res[1].Interface(); err != nil { + return err.(error) + } + + rv.Elem().Set(res[0]) + return nil + } + + return errors.New("graphql: no unmarshal function found") +} diff --git a/graphql/int.go b/graphql/int.go new file mode 100644 index 0000000..57d0d58 --- /dev/null +++ b/graphql/int.go @@ -0,0 +1,79 @@ +package graphql + +import ( + "encoding/json" + "fmt" + "io" + "strconv" +) + +func MarshalInt(i int) Marshaler { + return WriterFunc(func(w io.Writer) { + io.WriteString(w, strconv.Itoa(i)) + }) +} + +func UnmarshalInt(v interface{}) (int, error) { + switch v := v.(type) { + case string: + return strconv.Atoi(v) + case int: + return v, nil + case int64: + return int(v), nil + case json.Number: + return strconv.Atoi(string(v)) + default: + return 0, fmt.Errorf("%T is not an int", v) + } +} + +func MarshalInt64(i int64) Marshaler { + return WriterFunc(func(w io.Writer) { + io.WriteString(w, strconv.FormatInt(i, 10)) + }) +} + +func UnmarshalInt64(v interface{}) (int64, error) { + switch v := v.(type) { + case string: + return strconv.ParseInt(v, 10, 64) + case int: + return int64(v), nil + case int64: + return v, nil + case json.Number: + return strconv.ParseInt(string(v), 10, 64) + default: + return 0, fmt.Errorf("%T is not an int", v) + } +} + +func MarshalInt32(i int32) Marshaler { + return WriterFunc(func(w io.Writer) { + io.WriteString(w, strconv.FormatInt(int64(i), 10)) + }) +} + +func UnmarshalInt32(v interface{}) (int32, error) { + switch v := v.(type) { + case string: + iv, err := strconv.ParseInt(v, 10, 32) + if err != nil { + return 0, err + } + return int32(iv), nil + case int: + return int32(v), nil + case int64: + return int32(v), nil + case json.Number: + iv, err := strconv.ParseInt(string(v), 10, 32) + if err != nil { + return 0, err + } + return int32(iv), nil + default: + return 0, fmt.Errorf("%T is not an int", v) + } +} diff --git a/graphql/int_test.go b/graphql/int_test.go new file mode 100644 index 0000000..ada9ca5 --- /dev/null +++ b/graphql/int_test.go @@ -0,0 +1,71 @@ +package graphql + +import ( + "encoding/json" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestInt(t *testing.T) { + t.Run("marshal", func(t *testing.T) { + assert.Equal(t, "123", m2s(MarshalInt(123))) + }) + + t.Run("unmarshal", func(t *testing.T) { + assert.Equal(t, 123, mustUnmarshalInt(123)) + assert.Equal(t, 123, mustUnmarshalInt(int64(123))) + assert.Equal(t, 123, mustUnmarshalInt(json.Number("123"))) + assert.Equal(t, 123, mustUnmarshalInt("123")) + }) +} + +func mustUnmarshalInt(v interface{}) int { + res, err := UnmarshalInt(v) + if err != nil { + panic(err) + } + return res +} + +func TestInt32(t *testing.T) { + t.Run("marshal", func(t *testing.T) { + assert.Equal(t, "123", m2s(MarshalInt32(123))) + }) + + t.Run("unmarshal", func(t *testing.T) { + assert.Equal(t, int32(123), mustUnmarshalInt32(123)) + assert.Equal(t, int32(123), mustUnmarshalInt32(int64(123))) + assert.Equal(t, int32(123), mustUnmarshalInt32(json.Number("123"))) + assert.Equal(t, int32(123), mustUnmarshalInt32("123")) + }) +} + +func mustUnmarshalInt32(v interface{}) int32 { + res, err := UnmarshalInt32(v) + if err != nil { + panic(err) + } + return res +} + +func TestInt64(t *testing.T) { + t.Run("marshal", func(t *testing.T) { + assert.Equal(t, "123", m2s(MarshalInt32(123))) + }) + + t.Run("unmarshal", func(t *testing.T) { + assert.Equal(t, int64(123), mustUnmarshalInt64(123)) + assert.Equal(t, int64(123), mustUnmarshalInt64(int64(123))) + assert.Equal(t, int64(123), mustUnmarshalInt64(json.Number("123"))) + assert.Equal(t, int64(123), mustUnmarshalInt64("123")) + }) +} + +func mustUnmarshalInt64(v interface{}) int64 { + res, err := UnmarshalInt64(v) + if err != nil { + panic(err) + } + return res +} diff --git a/graphql/introspection/introspection.go b/graphql/introspection/introspection.go new file mode 100644 index 0000000..30c865c --- /dev/null +++ b/graphql/introspection/introspection.go @@ -0,0 +1,103 @@ +// introspection implements the spec defined in https://github.com/facebook/graphql/blob/master/spec/Section%204%20--%20Introspection.md#schema-introspection +package introspection + +import "github.com/vektah/gqlparser/v2/ast" + +type ( + Directive struct { + Name string + description string + Locations []string + Args []InputValue + IsRepeatable bool + } + + EnumValue struct { + Name string + description string + deprecation *ast.Directive + } + + Field struct { + Name string + description string + Type *Type + Args []InputValue + deprecation *ast.Directive + } + + InputValue struct { + Name string + description string + DefaultValue *string + Type *Type + } +) + +func WrapSchema(schema *ast.Schema) *Schema { + return &Schema{schema: schema} +} + +func (f *EnumValue) Description() *string { + if f.description == "" { + return nil + } + return &f.description +} + +func (f *EnumValue) IsDeprecated() bool { + return f.deprecation != nil +} + +func (f *EnumValue) DeprecationReason() *string { + if f.deprecation == nil { + return nil + } + + reason := f.deprecation.Arguments.ForName("reason") + if reason == nil { + return nil + } + + return &reason.Value.Raw +} + +func (f *Field) Description() *string { + if f.description == "" { + return nil + } + return &f.description +} + +func (f *Field) IsDeprecated() bool { + return f.deprecation != nil +} + +func (f *Field) DeprecationReason() *string { + if f.deprecation == nil || !f.IsDeprecated() { + return nil + } + + reason := f.deprecation.Arguments.ForName("reason") + + if reason == nil { + defaultReason := "No longer supported" + return &defaultReason + } + + return &reason.Value.Raw +} + +func (f *InputValue) Description() *string { + if f.description == "" { + return nil + } + return &f.description +} + +func (f *Directive) Description() *string { + if f.description == "" { + return nil + } + return &f.description +} diff --git a/graphql/introspection/query.go b/graphql/introspection/query.go new file mode 100644 index 0000000..389a5d8 --- /dev/null +++ b/graphql/introspection/query.go @@ -0,0 +1,106 @@ +package introspection + +// Query is the query generated by graphiql to determine type information +const Query = ` +query IntrospectionQuery { + __schema { + description + queryType { + name + } + mutationType { + name + } + subscriptionType { + name + } + types { + ...FullType + } + directives { + name + description + locations + args { + ...InputValue + } + } + } +} + +fragment FullType on __Type { + kind + name + description + specifiedByURL + fields(includeDeprecated: true) { + name + description + args { + ...InputValue + } + type { + ...TypeRef + } + isDeprecated + deprecationReason + } + inputFields { + ...InputValue + } + interfaces { + ...TypeRef + } + enumValues(includeDeprecated: true) { + name + description + isDeprecated + deprecationReason + } + possibleTypes { + ...TypeRef + } +} + +fragment InputValue on __InputValue { + name + description + type { + ...TypeRef + } + defaultValue +} + +fragment TypeRef on __Type { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + } + } + } + } + } + } + } +} +` diff --git a/graphql/introspection/schema.go b/graphql/introspection/schema.go new file mode 100644 index 0000000..897b1a0 --- /dev/null +++ b/graphql/introspection/schema.go @@ -0,0 +1,89 @@ +package introspection + +import ( + "sort" + + "github.com/vektah/gqlparser/v2/ast" +) + +type Schema struct { + schema *ast.Schema +} + +func (s *Schema) Description() *string { + if s.schema.Description == "" { + return nil + } + return &s.schema.Description +} + +func (s *Schema) Types() []Type { + typeIndex := map[string]Type{} + typeNames := make([]string, 0, len(s.schema.Types)) + for _, typ := range s.schema.Types { + 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 +} + +func (s *Schema) QueryType() *Type { + return WrapTypeFromDef(s.schema, s.schema.Query) +} + +func (s *Schema) MutationType() *Type { + return WrapTypeFromDef(s.schema, s.schema.Mutation) +} + +func (s *Schema) SubscriptionType() *Type { + return WrapTypeFromDef(s.schema, s.schema.Subscription) +} + +func (s *Schema) Directives() []Directive { + dIndex := map[string]Directive{} + dNames := make([]string, 0, len(s.schema.Directives)) + + for _, d := range s.schema.Directives { + 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 +} + +func (s *Schema) directiveFromDef(d *ast.DirectiveDefinition) Directive { + locs := make([]string, len(d.Locations)) + for i, loc := range d.Locations { + locs[i] = string(loc) + } + + args := make([]InputValue, len(d.Arguments)) + for i, arg := range d.Arguments { + args[i] = InputValue{ + Name: arg.Name, + description: arg.Description, + DefaultValue: defaultValue(arg.DefaultValue), + Type: WrapTypeFromType(s.schema, arg.Type), + } + } + + return Directive{ + Name: d.Name, + description: d.Description, + Locations: locs, + Args: args, + IsRepeatable: d.IsRepeatable, + } +} diff --git a/graphql/introspection/schema_test.go b/graphql/introspection/schema_test.go new file mode 100644 index 0000000..92022b1 --- /dev/null +++ b/graphql/introspection/schema_test.go @@ -0,0 +1,68 @@ +package introspection + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/v2/ast" +) + +func TestSchema(t *testing.T) { + query := &ast.Definition{ + Name: "Query", + Kind: ast.Object, + } + + mutation := &ast.Definition{ + Name: "Mutation", + Kind: ast.Object, + } + + subscription := &ast.Definition{ + Name: "Subscription", + Kind: ast.Object, + } + + directive := &ast.Definition{ + Name: "__Directive", + Kind: ast.Object, + } + + schema := &Schema{ + schema: &ast.Schema{ + Query: query, + Mutation: mutation, + Subscription: subscription, + Types: map[string]*ast.Definition{ + "Query": query, + "Mutation": mutation, + "__Directive": directive, + }, + Description: "test description", + }, + } + + t.Run("description", func(t *testing.T) { + require.EqualValues(t, "test description", *schema.Description()) + }) + + t.Run("query type", func(t *testing.T) { + require.Equal(t, "Query", *schema.QueryType().Name()) + }) + + t.Run("mutation type", func(t *testing.T) { + require.Equal(t, "Mutation", *schema.MutationType().Name()) + }) + + t.Run("subscription type", func(t *testing.T) { + require.Equal(t, "Subscription", *schema.SubscriptionType().Name()) + }) + + t.Run("types", func(t *testing.T) { + types := schema.Types() + require.Len(t, types, 3) + require.Equal(t, "Mutation", *types[0].Name()) + require.Equal(t, "Query", *types[1].Name()) + require.Equal(t, "__Directive", *types[2].Name()) + }) +} diff --git a/graphql/introspection/type.go b/graphql/introspection/type.go new file mode 100644 index 0000000..c50733d --- /dev/null +++ b/graphql/introspection/type.go @@ -0,0 +1,191 @@ +package introspection + +import ( + "strings" + + "github.com/vektah/gqlparser/v2/ast" +) + +type Type struct { + schema *ast.Schema + def *ast.Definition + typ *ast.Type +} + +func WrapTypeFromDef(s *ast.Schema, def *ast.Definition) *Type { + if def == nil { + return nil + } + return &Type{schema: s, def: def} +} + +func WrapTypeFromType(s *ast.Schema, typ *ast.Type) *Type { + if typ == nil { + return nil + } + + if !typ.NonNull && typ.NamedType != "" { + return &Type{schema: s, def: s.Types[typ.NamedType]} + } + return &Type{schema: s, typ: typ} +} + +func (t *Type) Kind() string { + if t.typ != nil { + if t.typ.NonNull { + return "NON_NULL" + } + + if t.typ.Elem != nil { + return "LIST" + } + } else { + return string(t.def.Kind) + } + + panic("UNKNOWN") +} + +func (t *Type) Name() *string { + if t.def == nil { + return nil + } + return &t.def.Name +} + +func (t *Type) Description() *string { + if t.def == nil || t.def.Description == "" { + return nil + } + return &t.def.Description +} + +func (t *Type) Fields(includeDeprecated bool) []Field { + if t.def == nil || (t.def.Kind != ast.Object && t.def.Kind != ast.Interface) { + return []Field{} + } + fields := []Field{} + for _, f := range t.def.Fields { + if strings.HasPrefix(f.Name, "__") { + continue + } + + if !includeDeprecated && f.Directives.ForName("deprecated") != nil { + continue + } + + var args []InputValue + for _, arg := range f.Arguments { + args = append(args, InputValue{ + Type: WrapTypeFromType(t.schema, arg.Type), + Name: arg.Name, + description: arg.Description, + DefaultValue: defaultValue(arg.DefaultValue), + }) + } + + fields = append(fields, Field{ + Name: f.Name, + description: f.Description, + Args: args, + Type: WrapTypeFromType(t.schema, f.Type), + deprecation: f.Directives.ForName("deprecated"), + }) + } + return fields +} + +func (t *Type) InputFields() []InputValue { + if t.def == nil || t.def.Kind != ast.InputObject { + return []InputValue{} + } + + res := []InputValue{} + for _, f := range t.def.Fields { + res = append(res, InputValue{ + Name: f.Name, + description: f.Description, + Type: WrapTypeFromType(t.schema, f.Type), + DefaultValue: defaultValue(f.DefaultValue), + }) + } + return res +} + +func defaultValue(value *ast.Value) *string { + if value == nil { + return nil + } + val := value.String() + return &val +} + +func (t *Type) Interfaces() []Type { + if t.def == nil || t.def.Kind != ast.Object { + return []Type{} + } + + res := []Type{} + for _, intf := range t.def.Interfaces { + res = append(res, *WrapTypeFromDef(t.schema, t.schema.Types[intf])) + } + + return res +} + +func (t *Type) PossibleTypes() []Type { + if t.def == nil || (t.def.Kind != ast.Interface && t.def.Kind != ast.Union) { + return []Type{} + } + + res := []Type{} + for _, pt := range t.schema.GetPossibleTypes(t.def) { + res = append(res, *WrapTypeFromDef(t.schema, pt)) + } + return res +} + +func (t *Type) EnumValues(includeDeprecated bool) []EnumValue { + if t.def == nil || t.def.Kind != ast.Enum { + return []EnumValue{} + } + + res := []EnumValue{} + for _, val := range t.def.EnumValues { + if !includeDeprecated && val.Directives.ForName("deprecated") != nil { + continue + } + + res = append(res, EnumValue{ + Name: val.Name, + description: val.Description, + deprecation: val.Directives.ForName("deprecated"), + }) + } + return res +} + +func (t *Type) OfType() *Type { + if t.typ == nil { + return nil + } + if t.typ.NonNull { + // fake non null nodes + cpy := *t.typ + cpy.NonNull = false + + return WrapTypeFromType(t.schema, &cpy) + } + return WrapTypeFromType(t.schema, t.typ.Elem) +} + +func (t *Type) SpecifiedByURL() *string { + directive := t.def.Directives.ForName("specifiedBy") + if t.def.Kind != ast.Scalar || directive == nil { + return nil + } + // def: directive @specifiedBy(url: String!) on SCALAR + // the argument "url" is required. + url := directive.Arguments.ForName("url") + return &url.Value.Raw +} diff --git a/graphql/introspection/type_test.go b/graphql/introspection/type_test.go new file mode 100644 index 0000000..f7ae14b --- /dev/null +++ b/graphql/introspection/type_test.go @@ -0,0 +1,46 @@ +package introspection + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/v2/ast" +) + +func TestType(t *testing.T) { + schemaType := Type{ + def: &ast.Definition{ + Name: "Query", + Description: "test description", + Fields: ast.FieldList{ + &ast.FieldDefinition{Name: "__schema"}, + &ast.FieldDefinition{Name: "test"}, + &ast.FieldDefinition{Name: "deprecated", Directives: ast.DirectiveList{ + &ast.Directive{Name: "deprecated"}, + }}, + }, + Kind: ast.Object, + }, + } + + t.Run("name", func(t *testing.T) { + require.Equal(t, "Query", *schemaType.Name()) + }) + + t.Run("description", func(t *testing.T) { + require.Equal(t, "test description", *schemaType.Description()) + }) + + t.Run("fields", func(t *testing.T) { + fields := schemaType.Fields(false) + require.Len(t, fields, 1) + require.Equal(t, "test", fields[0].Name) + }) + + t.Run("fields includeDepricated", func(t *testing.T) { + fields := schemaType.Fields(true) + require.Len(t, fields, 2) + require.Equal(t, "test", fields[0].Name) + require.Equal(t, "deprecated", fields[1].Name) + }) +} diff --git a/graphql/jsonw.go b/graphql/jsonw.go new file mode 100644 index 0000000..54e293f --- /dev/null +++ b/graphql/jsonw.go @@ -0,0 +1,93 @@ +package graphql + +import ( + "context" + "io" +) + +var ( + nullLit = []byte(`null`) + trueLit = []byte(`true`) + falseLit = []byte(`false`) + openBrace = []byte(`{`) + closeBrace = []byte(`}`) + openBracket = []byte(`[`) + closeBracket = []byte(`]`) + colon = []byte(`:`) + comma = []byte(`,`) +) + +var ( + Null = &lit{nullLit} + True = &lit{trueLit} + False = &lit{falseLit} +) + +type Marshaler interface { + MarshalGQL(w io.Writer) +} + +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) { + writer.Write(openBracket) + for i, val := range a { + if i != 0 { + writer.Write(comma) + } + val.MarshalGQL(writer) + } + writer.Write(closeBracket) +} + +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/jsonw_test.go b/graphql/jsonw_test.go new file mode 100644 index 0000000..1bba9fc --- /dev/null +++ b/graphql/jsonw_test.go @@ -0,0 +1,48 @@ +package graphql + +import ( + "bytes" + "testing" + + "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/v2/ast" +) + +func TestJsonWriter(t *testing.T) { + obj := NewFieldSet([]CollectedField{ + {Field: &ast.Field{Alias: "test"}}, + {Field: &ast.Field{Alias: "array"}}, + {Field: &ast.Field{Alias: "emptyArray"}}, + {Field: &ast.Field{Alias: "child"}}, + }) + obj.Values[0] = MarshalInt(10) + + obj.Values[1] = &Array{ + MarshalInt(1), + MarshalString("2"), + MarshalBoolean(true), + False, + Null, + MarshalFloat(1.3), + True, + } + + obj.Values[2] = &Array{} + + child2 := NewFieldSet([]CollectedField{ + {Field: &ast.Field{Alias: "child"}}, + }) + child2.Values[0] = Null + + child1 := NewFieldSet([]CollectedField{ + {Field: &ast.Field{Alias: "child"}}, + }) + child1.Values[0] = child2 + + obj.Values[3] = child1 + + b := &bytes.Buffer{} + obj.MarshalGQL(b) + + require.Equal(t, `{"test":10,"array":[1,"2",true,false,null,1.3,true],"emptyArray":[],"child":{"child":{"child":null}}}`, b.String()) +} diff --git a/graphql/map.go b/graphql/map.go new file mode 100644 index 0000000..1e91d1d --- /dev/null +++ b/graphql/map.go @@ -0,0 +1,24 @@ +package graphql + +import ( + "encoding/json" + "fmt" + "io" +) + +func MarshalMap(val map[string]interface{}) Marshaler { + return WriterFunc(func(w io.Writer) { + err := json.NewEncoder(w).Encode(val) + if err != nil { + panic(err) + } + }) +} + +func UnmarshalMap(v interface{}) (map[string]interface{}, error) { + if m, ok := v.(map[string]interface{}); ok { + return m, nil + } + + return nil, fmt.Errorf("%T is not a map", v) +} diff --git a/graphql/omittable.go b/graphql/omittable.go new file mode 100644 index 0000000..8971640 --- /dev/null +++ b/graphql/omittable.go @@ -0,0 +1,58 @@ +package graphql + +import "encoding/json" + +// Omittable is a wrapper around a value that also stores whether it is set +// or not. +type Omittable[T any] struct { + value T + set bool +} + +var ( + _ json.Marshaler = Omittable[struct{}]{} + _ json.Unmarshaler = (*Omittable[struct{}])(nil) +) + +func OmittableOf[T any](value T) Omittable[T] { + return Omittable[T]{ + value: value, + set: true, + } +} + +func (o Omittable[T]) Value() T { + if !o.set { + var zero T + return zero + } + return o.value +} + +func (o Omittable[T]) ValueOK() (T, bool) { + if !o.set { + var zero T + return zero, false + } + return o.value, true +} + +func (o Omittable[T]) IsSet() bool { + return o.set +} + +func (o Omittable[T]) MarshalJSON() ([]byte, error) { + if !o.set { + return []byte("null"), nil + } + return json.Marshal(o.value) +} + +func (o *Omittable[T]) UnmarshalJSON(bytes []byte) error { + err := json.Unmarshal(bytes, &o.value) + if err != nil { + return err + } + o.set = true + return nil +} diff --git a/graphql/omittable_test.go b/graphql/omittable_test.go new file mode 100644 index 0000000..79c5917 --- /dev/null +++ b/graphql/omittable_test.go @@ -0,0 +1,88 @@ +package graphql + +import ( + "encoding/json" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestOmittable_MarshalJSON(t *testing.T) { + s := "test" + testCases := []struct { + name string + input any + expectedJSON string + }{ + { + name: "simple string", + input: struct{ Value Omittable[string] }{Value: OmittableOf("simple string")}, + expectedJSON: `{"Value": "simple string"}`, + }, + { + name: "string pointer", + input: struct{ Value Omittable[*string] }{Value: OmittableOf(&s)}, + expectedJSON: `{"Value": "test"}`, + }, + { + name: "omitted integer", + input: struct{ Value Omittable[int] }{}, + expectedJSON: `{"Value": null}`, + }, + { + name: "omittable omittable", + input: struct{ Value Omittable[Omittable[uint64]] }{Value: OmittableOf(OmittableOf(uint64(42)))}, + expectedJSON: `{"Value": 42}`, + }, + { + name: "omittable struct", + input: struct { + Value Omittable[struct{ Inner string }] + }{Value: OmittableOf(struct{ Inner string }{})}, + expectedJSON: `{"Value": {"Inner": ""}}`, + }, + { + name: "omitted struct", + input: struct { + Value Omittable[struct{ Inner string }] + }{}, + expectedJSON: `{"Value": null}`, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + data, err := json.Marshal(tc.input) + require.NoError(t, err) + assert.JSONEq(t, tc.expectedJSON, string(data)) + }) + } +} + +func TestOmittable_UnmarshalJSON(t *testing.T) { + var s struct { + String Omittable[string] + OmittedString Omittable[string] + StringPointer Omittable[*string] + NullInt Omittable[int] + } + + err := json.Unmarshal([]byte(` + { + "String": "simple string", + "StringPointer": "string pointer", + "NullInt": null + }`), &s) + + require.NoError(t, err) + assert.Equal(t, "simple string", s.String.Value()) + assert.True(t, s.String.IsSet()) + assert.False(t, s.OmittedString.IsSet()) + assert.True(t, s.StringPointer.IsSet()) + if assert.NotNil(t, s.StringPointer.Value()) { + assert.EqualValues(t, "string pointer", *s.StringPointer.Value()) + } + assert.True(t, s.NullInt.IsSet()) + assert.Zero(t, s.NullInt.Value()) +} diff --git a/graphql/oneshot.go b/graphql/oneshot.go new file mode 100644 index 0000000..01fa15f --- /dev/null +++ b/graphql/oneshot.go @@ -0,0 +1,16 @@ +package graphql + +import "context" + +func OneShot(resp *Response) ResponseHandler { + var oneshot bool + + return func(context context.Context) *Response { + if oneshot { + return nil + } + oneshot = true + + return resp + } +} diff --git a/graphql/playground/altair_playground.go b/graphql/playground/altair_playground.go new file mode 100644 index 0000000..6928828 --- /dev/null +++ b/graphql/playground/altair_playground.go @@ -0,0 +1,84 @@ +package playground + +import ( + "html/template" + "net/http" +) + +var altairPage = template.Must(template.New("altair").Parse(` + + + + + {{.title}} + + + + + + + + + +
+
+
+ Altair +
+
+ + + +
+
+
+
+ + + + + + + + +`)) + +// AltairHandler responsible for setting up the altair playground +func AltairHandler(title, endpoint string) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + err := altairPage.Execute(w, map[string]interface{}{ + "title": title, + "endpoint": endpoint, + "endpointIsAbsolute": endpointHasScheme(endpoint), + "subscriptionEndpoint": getSubscriptionEndpoint(endpoint), + "version": "5.0.5", + "cssSRI": "sha256-kZ35e5mdMYN5ALEbnsrA2CLn85Oe4hBodfsih9BqNxs=", + "mainSRI": "sha256-nWdVTcGTlBDV1L04UQnqod+AJedzBCnKHv6Ct65liHE=", + "polyfillsSRI": "sha256-1aVEg2sROcCQ/RxU3AlcPaRZhZdIWA92q2M+mdd/R4c=", + "runtimeSRI": "sha256-cK2XhXqQr0WS1Z5eKNdac0rJxTD6miC3ubd+aEVMQDk=", + }) + if err != nil { + panic(err) + } + } +} diff --git a/graphql/playground/altair_playground_test.go b/graphql/playground/altair_playground_test.go new file mode 100644 index 0000000..d38af9b --- /dev/null +++ b/graphql/playground/altair_playground_test.go @@ -0,0 +1,9 @@ +package playground + +import ( + "testing" +) + +func TestAltairHandler_Integrity(t *testing.T) { + testResourceIntegrity(t, AltairHandler) +} diff --git a/graphql/playground/apollo_sandbox_playground.go b/graphql/playground/apollo_sandbox_playground.go new file mode 100644 index 0000000..750420b --- /dev/null +++ b/graphql/playground/apollo_sandbox_playground.go @@ -0,0 +1,186 @@ +package playground + +import ( + "encoding/json" + "fmt" + "html/template" + "net/http" +) + +// NOTE: New version available at https://embeddable-sandbox.cdn.apollographql.com/ --> +var apolloSandboxPage = template.Must(template.New("ApolloSandbox").Parse(` + + + + + {{.title}} + + + + + + +
+ + + +`)) + +// ApolloSandboxHandler responsible for setting up the apollo sandbox playground +func ApolloSandboxHandler(title, endpoint string, opts ...ApolloSandboxOption) http.HandlerFunc { + options := &apolloSandboxOptions{ + HideCookieToggle: true, + InitialState: apolloSandboxInitialState{ + IncludeCookies: true, + PollForSchemaUpdates: false, + }, + } + + for _, opt := range opts { + opt(options) + } + + optionsBytes, err := json.Marshal(options) + if err != nil { + panic(fmt.Errorf("failed to marshal apollo sandbox options: %w", err)) + } + + return func(w http.ResponseWriter, r *http.Request) { + err := apolloSandboxPage.Execute(w, map[string]interface{}{ + "title": title, + "endpoint": endpoint, + "endpointIsAbsolute": endpointHasScheme(endpoint), + "mainSRI": "sha256-pYhw/8TGkZxk960PMMpDtjhw9YtKXUzGv6XQQaMJSh8=", + "options": string(optionsBytes), + }) + if err != nil { + panic(err) + } + } +} + +// See https://www.apollographql.com/docs/graphos/explorer/sandbox/#options --> +type apolloSandboxOptions struct { + HideCookieToggle bool `json:"hideCookieToggle"` + EndpointIsEditable bool `json:"endpointIsEditable"` + InitialState apolloSandboxInitialState `json:"initialState,omitempty"` +} + +type apolloSandboxInitialState struct { + IncludeCookies bool `json:"includeCookies"` + Document string `json:"document,omitempty"` + Variables map[string]any `json:"variables,omitempty"` + Headers map[string]any `json:"headers,omitempty"` + CollectionId string `json:"collectionId,omitempty"` + OperationId string `json:"operationId,omitempty"` + PollForSchemaUpdates bool `json:"pollForSchemaUpdates"` + SharedHeaders map[string]any `json:"sharedHeaders,omitempty"` +} + +type ApolloSandboxOption func(options *apolloSandboxOptions) + +// WithApolloSandboxHideCookieToggle By default, the embedded Sandbox does not show the Include cookies toggle in its connection settings. +// +// Set hideCookieToggle to false to enable users of your embedded Sandbox instance to toggle the Include cookies setting. +func WithApolloSandboxHideCookieToggle(hideCookieToggle bool) ApolloSandboxOption { + return func(options *apolloSandboxOptions) { + options.HideCookieToggle = hideCookieToggle + } +} + +// WithApolloSandboxEndpointIsEditable By default, the embedded Sandbox has a URL input box that is editable by users. +// +// Set endpointIsEditable to false to prevent users of your embedded Sandbox instance from changing the endpoint URL. +func WithApolloSandboxEndpointIsEditable(endpointIsEditable bool) ApolloSandboxOption { + return func(options *apolloSandboxOptions) { + options.EndpointIsEditable = endpointIsEditable + } +} + +// WithApolloSandboxInitialStateIncludeCookies Set this value to true if you want the Sandbox to pass { credentials: 'include' } for its requests by default. +// +// If you set hideCookieToggle to false, users can override this default setting with the Include cookies toggle. (By default, the embedded Sandbox does not show the Include cookies toggle in its connection settings.) +// +// If you also pass the handleRequest option, this option is ignored. +// +// Read more about the fetch API and credentials here https://developer.mozilla.org/en-US/docs/Web/API/fetch#credentials +func WithApolloSandboxInitialStateIncludeCookies(includeCookies bool) ApolloSandboxOption { + return func(options *apolloSandboxOptions) { + options.InitialState.IncludeCookies = includeCookies + } +} + +// WithApolloSandboxInitialStateDocument Document operation to populate in the Sandbox's editor on load. +// +// If you omit this, the Sandbox initially loads an example query based on your schema. +func WithApolloSandboxInitialStateDocument(document string) ApolloSandboxOption { + return func(options *apolloSandboxOptions) { + options.InitialState.Document = document + } +} + +// WithApolloSandboxInitialStateVariables Variables containing initial variable values to populate in the Sandbox on load. +// +// If provided, these variables should apply to the initial query you provide for document. +func WithApolloSandboxInitialStateVariables(variables map[string]any) ApolloSandboxOption { + return func(options *apolloSandboxOptions) { + options.InitialState.Variables = variables + } +} + +// WithApolloSandboxInitialStateHeaders Headers containing initial variable values to populate in the Sandbox on load. +// +// If provided, these variables should apply to the initial query you provide for document. +func WithApolloSandboxInitialStateHeaders(headers map[string]any) ApolloSandboxOption { + return func(options *apolloSandboxOptions) { + options.InitialState.Headers = headers + } +} + +// WithApolloSandboxInitialStateCollectionIdAndOperationId The ID of a collection, paired with an operation ID to populate in the Sandbox on load. +// +// You can find these values from a registered graph in Studio by clicking the ... menu next to an operation in the Explorer of that graph and selecting View operation details. +func WithApolloSandboxInitialStateCollectionIdAndOperationId(collectionId, operationId string) ApolloSandboxOption { + return func(options *apolloSandboxOptions) { + options.InitialState.CollectionId = collectionId + options.InitialState.OperationId = operationId + } +} + +// WithApolloSandboxInitialStatePollForSchemaUpdates If true, the embedded Sandbox periodically polls your initialEndpoint for schema updates. +// +// The default value is false. +func WithApolloSandboxInitialStatePollForSchemaUpdates(pollForSchemaUpdates bool) ApolloSandboxOption { + return func(options *apolloSandboxOptions) { + options.InitialState.PollForSchemaUpdates = pollForSchemaUpdates + } +} + +// WithApolloSandboxInitialStateSharedHeaders Headers that are applied by default to every operation executed by the embedded Sandbox. +// +// Users can disable the application of these headers, but they can't modify their values. +// +// The embedded Sandbox always includes these headers in its introspection queries to your initialEndpoint. +func WithApolloSandboxInitialStateSharedHeaders(sharedHeaders map[string]any) ApolloSandboxOption { + return func(options *apolloSandboxOptions) { + options.InitialState.SharedHeaders = sharedHeaders + } +} diff --git a/graphql/playground/apollo_sandbox_playground_test.go b/graphql/playground/apollo_sandbox_playground_test.go new file mode 100644 index 0000000..5d0f915 --- /dev/null +++ b/graphql/playground/apollo_sandbox_playground_test.go @@ -0,0 +1,12 @@ +package playground + +import ( + "net/http" + "testing" +) + +func TestApolloSandboxHandler_Integrity(t *testing.T) { + testResourceIntegrity(t, func(title, endpoint string) http.HandlerFunc { + return ApolloSandboxHandler(title, endpoint) + }) +} diff --git a/graphql/playground/helper_test.go b/graphql/playground/helper_test.go new file mode 100644 index 0000000..ad11971 --- /dev/null +++ b/graphql/playground/helper_test.go @@ -0,0 +1,70 @@ +package playground + +import ( + "crypto/sha256" + "encoding/base64" + "io" + "net/http" + "net/http/httptest" + "strings" + "testing" + + "github.com/PuerkitoBio/goquery" + "github.com/stretchr/testify/assert" +) + +func testResourceIntegrity(t *testing.T, handler func(title, endpoint string) http.HandlerFunc) { + recorder := httptest.NewRecorder() + request := httptest.NewRequest(http.MethodGet, "http://localhost:8080/", nil) + handler("example.org API", "/query").ServeHTTP(recorder, request) + + res := recorder.Result() + defer assert.NoError(t, res.Body.Close()) + + assert.Equal(t, http.StatusOK, res.StatusCode) + assert.True(t, strings.HasPrefix(res.Header.Get("Content-Type"), "text/html")) + + doc, err := goquery.NewDocumentFromReader(res.Body) + assert.NoError(t, err) + assert.NotNil(t, doc) + + var baseUrl string + if base := doc.Find("base"); len(base.Nodes) != 0 { + if value, exists := base.Attr("href"); exists { + baseUrl = value + } + } + + assertNodesIntegrity(t, baseUrl, doc, "script", "src", "integrity") + assertNodesIntegrity(t, baseUrl, doc, "link", "href", "integrity") +} + +func assertNodesIntegrity(t *testing.T, baseUrl string, doc *goquery.Document, selector string, urlAttrKey, integrityAttrKey string) { + selection := doc.Find(selector) + for _, node := range selection.Nodes { + var url string + var integrity string + for _, attribute := range node.Attr { + if attribute.Key == urlAttrKey { + url = attribute.Val + } else if attribute.Key == integrityAttrKey { + integrity = attribute.Val + } + } + + if len(integrity) != 0 { + assert.NotEmpty(t, url) + } + + if len(url) != 0 && len(integrity) != 0 { + resp, err := http.Get(baseUrl + url) + assert.NoError(t, err) + hasher := sha256.New() + _, err = io.Copy(hasher, resp.Body) + assert.NoError(t, err) + assert.NoError(t, resp.Body.Close()) + actual := "sha256-" + base64.StdEncoding.EncodeToString(hasher.Sum(nil)) + assert.Equal(t, integrity, actual) + } + } +} diff --git a/graphql/playground/playground.go b/graphql/playground/playground.go new file mode 100644 index 0000000..05ad023 --- /dev/null +++ b/graphql/playground/playground.go @@ -0,0 +1,139 @@ +package playground + +import ( + "html/template" + "net/http" + "net/url" +) + +var page = template.Must(template.New("graphiql").Parse(` + + + + {{.title}} + + + + + + +
Loading...
+ + + + + + +`)) + +// Handler responsible for setting up the playground +func Handler(title string, endpoint string) http.HandlerFunc { + return HandlerWithHeaders(title, endpoint, nil, nil) +} + +// HandlerWithHeaders sets up the playground. +// fetcherHeaders are used by the playground's fetcher instance and will not be visible in the UI. +// uiHeaders are default headers that will show up in the UI headers editor. +func HandlerWithHeaders(title string, endpoint string, fetcherHeaders map[string]string, uiHeaders map[string]string) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + w.Header().Add("Content-Type", "text/html; charset=UTF-8") + err := page.Execute(w, map[string]interface{}{ + "title": title, + "endpoint": endpoint, + "fetcherHeaders": fetcherHeaders, + "uiHeaders": uiHeaders, + "endpointIsAbsolute": endpointHasScheme(endpoint), + "subscriptionEndpoint": getSubscriptionEndpoint(endpoint), + "version": "3.0.6", + "cssSRI": "sha256-wTzfn13a+pLMB5rMeysPPR1hO7x0SwSeQI+cnw7VdbE=", + "jsSRI": "sha256-eNxH+Ah7Z9up9aJYTQycgyNuy953zYZwE9Rqf5rH+r4=", + "reactSRI": "sha256-S0lp+k7zWUMk2ixteM6HZvu8L9Eh//OVrt+ZfbCpmgY=", + "reactDOMSRI": "sha256-IXWO0ITNDjfnNXIu5POVfqlgYoop36bDzhodR6LW5Pc=", + }) + if err != nil { + panic(err) + } + } +} + +// endpointHasScheme checks if the endpoint has a scheme. +func endpointHasScheme(endpoint string) bool { + u, err := url.Parse(endpoint) + return err == nil && u.Scheme != "" +} + +// getSubscriptionEndpoint returns the subscription endpoint for the given +// endpoint if it is parsable as a URL, or an empty string. +func getSubscriptionEndpoint(endpoint string) string { + u, err := url.Parse(endpoint) + if err != nil { + return "" + } + + switch u.Scheme { + case "https": + u.Scheme = "wss" + default: + u.Scheme = "ws" + } + + return u.String() +} diff --git a/graphql/playground/playground_test.go b/graphql/playground/playground_test.go new file mode 100644 index 0000000..7350f2b --- /dev/null +++ b/graphql/playground/playground_test.go @@ -0,0 +1,77 @@ +package playground + +import ( + "fmt" + "io" + "net/http" + "net/http/httptest" + "regexp" + "testing" +) + +func TestHandler_createsAbsoluteURLs(t *testing.T) { + rec := httptest.NewRecorder() + req := httptest.NewRequest(http.MethodGet, "https://example.org/query", nil) + h := Handler("example.org API", "https://example.org/query") + h.ServeHTTP(rec, req) + + res := rec.Result() + defer res.Body.Close() + if res.StatusCode != http.StatusOK { + t.Errorf("res.StatusCode = %d; want %d", res.StatusCode, http.StatusOK) + } + + b, err := io.ReadAll(res.Body) + if err != nil { + panic(fmt.Errorf("reading res.Body: %w", err)) + } + + want := regexp.MustCompile(`(?m)^.*url\s*=\s*['"]https:\/\/example\.org\/query["'].*$`) + if !want.Match(b) { + t.Errorf("no match for %s in response body", want.String()) + } + + wantSubURL := regexp.MustCompile(`(?m)^.*subscriptionUrl\s*=\s*['"]wss:\/\/example\.org\/query["'].*$`) + if !wantSubURL.Match(b) { + t.Errorf("no match for %s in response body", wantSubURL.String()) + } + + wantMetaCharsetElement := regexp.MustCompile(`\n\s{0,}\n\s{0,}.*`) // <meta> element must be in <head> and before <title> + if !wantMetaCharsetElement.Match(b) { + t.Errorf("no match for %s in response body", wantMetaCharsetElement.String()) + } +} + +func TestHandler_createsRelativeURLs(t *testing.T) { + rec := httptest.NewRecorder() + req := httptest.NewRequest(http.MethodGet, "http://localhost:8080/query", nil) + h := Handler("example.org API", "/customquery") + h.ServeHTTP(rec, req) + + res := rec.Result() + defer res.Body.Close() + if res.StatusCode != http.StatusOK { + t.Errorf("res.StatusCode = %d; want %d", res.StatusCode, http.StatusOK) + } + if res.Header.Get("Content-Type") != "text/html; charset=UTF-8" { + t.Errorf("res.Header.Get(\"Content-Type\") = %q; want %q", res.Header.Get("Content-Type"), "text/html; charset=UTF-8") + } + + b, err := io.ReadAll(res.Body) + if err != nil { + panic(fmt.Errorf("reading res.Body: %w", err)) + } + + wantURL := regexp.MustCompile(`(?m)^.*url\s*=\s*location\.protocol.*$`) + if !wantURL.Match(b) { + t.Errorf("no match for %s in response body", wantURL.String()) + } + wantSubURL := regexp.MustCompile(`(?m)^.*subscriptionUrl\s*=\s*wsProto.*['"]\/customquery['"].*$`) + if !wantSubURL.Match(b) { + t.Errorf("no match for %s in response body", wantSubURL.String()) + } +} + +func TestHandler_Integrity(t *testing.T) { + testResourceIntegrity(t, Handler) +} diff --git a/graphql/recovery.go b/graphql/recovery.go new file mode 100644 index 0000000..9bc0e47 --- /dev/null +++ b/graphql/recovery.go @@ -0,0 +1,20 @@ +package graphql + +import ( + "context" + "fmt" + "os" + "runtime/debug" + + "github.com/vektah/gqlparser/v2/gqlerror" +) + +type RecoverFunc func(ctx context.Context, err interface{}) (userMessage error) + +func DefaultRecover(ctx context.Context, err interface{}) error { + fmt.Fprintln(os.Stderr, err) + fmt.Fprintln(os.Stderr) + debug.PrintStack() + + return gqlerror.Errorf("internal system error") +} diff --git a/graphql/response.go b/graphql/response.go new file mode 100644 index 0000000..a82f27e --- /dev/null +++ b/graphql/response.go @@ -0,0 +1,28 @@ +package graphql + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/vektah/gqlparser/v2/ast" + "github.com/vektah/gqlparser/v2/gqlerror" +) + +// Errors are intentionally serialized first based on the advice in +// https://github.com/facebook/graphql/commit/7b40390d48680b15cb93e02d46ac5eb249689876#diff-757cea6edf0288677a9eea4cfc801d87R107 +// and https://github.com/facebook/graphql/pull/384 +type Response struct { + Errors gqlerror.List `json:"errors,omitempty"` + Data json.RawMessage `json:"data"` + Label string `json:"label,omitempty"` + Path ast.Path `json:"path,omitempty"` + HasNext *bool `json:"hasNext,omitempty"` + Extensions map[string]interface{} `json:"extensions,omitempty"` +} + +func ErrorResponse(ctx context.Context, messagef string, args ...interface{}) *Response { + return &Response{ + Errors: gqlerror.List{{Message: fmt.Sprintf(messagef, args...)}}, + } +} diff --git a/graphql/root.go b/graphql/root.go new file mode 100644 index 0000000..3405d18 --- /dev/null +++ b/graphql/root.go @@ -0,0 +1,7 @@ +package graphql + +type Query struct{} + +type Mutation struct{} + +type Subscription struct{} diff --git a/graphql/stats.go b/graphql/stats.go new file mode 100644 index 0000000..31b9e60 --- /dev/null +++ b/graphql/stats.go @@ -0,0 +1,60 @@ +package graphql + +import ( + "context" + "fmt" + "time" +) + +type Stats struct { + OperationStart time.Time + Read TraceTiming + Parsing TraceTiming + Validation TraceTiming + + // Stats collected by handler extensions. Don't use directly, the extension should provide a type safe way to + // access this. + extension map[string]interface{} +} + +type TraceTiming struct { + Start time.Time + End time.Time +} + +var ctxTraceStart key = "trace_start" + +// StartOperationTrace captures the current time and stores it in context. This will eventually be added to request +// context but we want to grab it as soon as possible. For transports that can only handle a single graphql query +// per http requests you don't need to call this at all, the server will do it for you. For transports that handle +// multiple (eg batching, subscriptions) this should be called before decoding each request. +func StartOperationTrace(ctx context.Context) context.Context { + return context.WithValue(ctx, ctxTraceStart, Now()) +} + +// GetStartTime should only be called by the handler package, it will be set into request context +// as Stats.Start +func GetStartTime(ctx context.Context) time.Time { + t, ok := ctx.Value(ctxTraceStart).(time.Time) + if !ok { + panic(fmt.Sprintf("missing start time: %T", ctx.Value(ctxTraceStart))) + } + return t +} + +func (c *Stats) SetExtension(name string, data interface{}) { + if c.extension == nil { + c.extension = map[string]interface{}{} + } + c.extension[name] = data +} + +func (c *Stats) GetExtension(name string) interface{} { + if c.extension == nil { + return nil + } + return c.extension[name] +} + +// Now is time.Now, except in tests. Then it can be whatever you want it to be. +var Now = time.Now diff --git a/graphql/string.go b/graphql/string.go new file mode 100644 index 0000000..4da4706 --- /dev/null +++ b/graphql/string.go @@ -0,0 +1,73 @@ +package graphql + +import ( + "encoding/json" + "fmt" + "io" + "strconv" +) + +const encodeHex = "0123456789ABCDEF" + +func MarshalString(s string) Marshaler { + return WriterFunc(func(w io.Writer) { + writeQuotedString(w, s) + }) +} + +func writeQuotedString(w io.Writer, s string) { + start := 0 + io.WriteString(w, `"`) + + for i, c := range s { + if c < 0x20 || c == '\\' || c == '"' { + io.WriteString(w, s[start:i]) + + switch c { + case '\t': + io.WriteString(w, `\t`) + case '\r': + io.WriteString(w, `\r`) + case '\n': + io.WriteString(w, `\n`) + case '\\': + io.WriteString(w, `\\`) + case '"': + io.WriteString(w, `\"`) + default: + io.WriteString(w, `\u00`) + w.Write([]byte{encodeHex[c>>4], encodeHex[c&0xf]}) + } + + start = i + 1 + } + } + + io.WriteString(w, s[start:]) + io.WriteString(w, `"`) +} + +func UnmarshalString(v interface{}) (string, error) { + switch v := v.(type) { + case string: + return v, nil + case int: + return strconv.Itoa(v), nil + case int64: + return strconv.FormatInt(v, 10), nil + case float64: + return strconv.FormatFloat(v, 'f', -1, 64), nil + case json.Number: + return string(v), nil + case bool: + if v { + return "true", nil + } else { + return "false", nil + } + case nil: + return "null", nil + default: + return "", fmt.Errorf("%T is not a string", v) + } +} diff --git a/graphql/string_test.go b/graphql/string_test.go new file mode 100644 index 0000000..3a29cde --- /dev/null +++ b/graphql/string_test.go @@ -0,0 +1,42 @@ +package graphql + +import ( + "encoding/json" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestString(t *testing.T) { + t.Run("marshal", func(t *testing.T) { + assert.Equal(t, `"hello"`, m2s(MarshalString("hello"))) + assert.Equal(t, `"he\tllo"`, m2s(MarshalString("he\tllo"))) + assert.Equal(t, `"he\tllo"`, m2s(MarshalString("he llo"))) + assert.Equal(t, `"he\nllo"`, m2s(MarshalString("he\nllo"))) + assert.Equal(t, `"he\r\nllo"`, m2s(MarshalString("he\r\nllo"))) + assert.Equal(t, `"he\\llo"`, m2s(MarshalString(`he\llo`))) + assert.Equal(t, `"quotes\"nested\"in\"quotes\""`, m2s(MarshalString(`quotes"nested"in"quotes"`))) + assert.Equal(t, `"\u0000"`, m2s(MarshalString("\u0000"))) + assert.Equal(t, `"\u0000"`, m2s(MarshalString("\u0000"))) + assert.Equal(t, "\"\U000fe4ed\"", m2s(MarshalString("\U000fe4ed"))) + }) + + t.Run("unmarshal", func(t *testing.T) { + assert.Equal(t, "123", mustUnmarshalString("123")) + assert.Equal(t, "123", mustUnmarshalString(123)) + assert.Equal(t, "123", mustUnmarshalString(int64(123))) + assert.Equal(t, "123", mustUnmarshalString(float64(123))) + assert.Equal(t, "123", mustUnmarshalString(json.Number("123"))) + assert.Equal(t, "true", mustUnmarshalString(true)) + assert.Equal(t, "false", mustUnmarshalString(false)) + assert.Equal(t, "null", mustUnmarshalString(nil)) + }) +} + +func mustUnmarshalString(v interface{}) string { + res, err := UnmarshalString(v) + if err != nil { + panic(err) + } + return res +} diff --git a/graphql/time.go b/graphql/time.go new file mode 100644 index 0000000..ef3d17d --- /dev/null +++ b/graphql/time.go @@ -0,0 +1,25 @@ +package graphql + +import ( + "errors" + "io" + "strconv" + "time" +) + +func MarshalTime(t time.Time) Marshaler { + if t.IsZero() { + return Null + } + + return WriterFunc(func(w io.Writer) { + io.WriteString(w, strconv.Quote(t.Format(time.RFC3339Nano))) + }) +} + +func UnmarshalTime(v interface{}) (time.Time, error) { + if tmpStr, ok := v.(string); ok { + return time.Parse(time.RFC3339Nano, tmpStr) + } + return time.Time{}, errors.New("time should be RFC3339Nano formatted string") +} diff --git a/graphql/time_test.go b/graphql/time_test.go new file mode 100644 index 0000000..3287643 --- /dev/null +++ b/graphql/time_test.go @@ -0,0 +1,25 @@ +package graphql + +import ( + "bytes" + "strconv" + "testing" + "time" + + "github.com/stretchr/testify/require" +) + +func TestTime(t *testing.T) { + t.Run("symmetry", func(t *testing.T) { + initialTime := time.Now() + buf := bytes.NewBuffer([]byte{}) + MarshalTime(initialTime).MarshalGQL(buf) + + str, err := strconv.Unquote(buf.String()) + require.Nil(t, err) + newTime, err := UnmarshalTime(str) + require.Nil(t, err) + + require.True(t, initialTime.Equal(newTime), "expected times %v and %v to equal", initialTime, newTime) + }) +} diff --git a/graphql/uint.go b/graphql/uint.go new file mode 100644 index 0000000..26e6aa6 --- /dev/null +++ b/graphql/uint.go @@ -0,0 +1,81 @@ +package graphql + +import ( + "encoding/json" + "fmt" + "io" + "strconv" +) + +func MarshalUint(i uint) Marshaler { + return WriterFunc(func(w io.Writer) { + _, _ = io.WriteString(w, strconv.FormatUint(uint64(i), 10)) + }) +} + +func UnmarshalUint(v interface{}) (uint, error) { + switch v := v.(type) { + case string: + u64, err := strconv.ParseUint(v, 10, 64) + return uint(u64), err + case int: + return uint(v), nil + case int64: + return uint(v), nil + case json.Number: + u64, err := strconv.ParseUint(string(v), 10, 64) + return uint(u64), err + default: + return 0, fmt.Errorf("%T is not an uint", v) + } +} + +func MarshalUint64(i uint64) Marshaler { + return WriterFunc(func(w io.Writer) { + _, _ = io.WriteString(w, strconv.FormatUint(i, 10)) + }) +} + +func UnmarshalUint64(v interface{}) (uint64, error) { + switch v := v.(type) { + case string: + return strconv.ParseUint(v, 10, 64) + case int: + return uint64(v), nil + case int64: + return uint64(v), nil + case json.Number: + return strconv.ParseUint(string(v), 10, 64) + default: + return 0, fmt.Errorf("%T is not an uint", v) + } +} + +func MarshalUint32(i uint32) Marshaler { + return WriterFunc(func(w io.Writer) { + _, _ = io.WriteString(w, strconv.FormatUint(uint64(i), 10)) + }) +} + +func UnmarshalUint32(v interface{}) (uint32, error) { + switch v := v.(type) { + case string: + iv, err := strconv.ParseUint(v, 10, 32) + if err != nil { + return 0, err + } + return uint32(iv), nil + case int: + return uint32(v), nil + case int64: + return uint32(v), nil + case json.Number: + iv, err := strconv.ParseUint(string(v), 10, 32) + if err != nil { + return 0, err + } + return uint32(iv), nil + default: + return 0, fmt.Errorf("%T is not an uint", v) + } +} diff --git a/graphql/uint_test.go b/graphql/uint_test.go new file mode 100644 index 0000000..3f497ad --- /dev/null +++ b/graphql/uint_test.go @@ -0,0 +1,74 @@ +package graphql + +import ( + "encoding/json" + "math" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestUint(t *testing.T) { + t.Run("marshal", func(t *testing.T) { + assert.Equal(t, "123", m2s(MarshalUint(123))) + }) + + t.Run("unmarshal", func(t *testing.T) { + assert.Equal(t, uint(123), mustUnmarshalUint(123)) + assert.Equal(t, uint(123), mustUnmarshalUint(int64(123))) + assert.Equal(t, uint(123), mustUnmarshalUint(json.Number("123"))) + assert.Equal(t, uint(123), mustUnmarshalUint("123")) + }) +} + +func mustUnmarshalUint(v interface{}) uint { + res, err := UnmarshalUint(v) + if err != nil { + panic(err) + } + return res +} + +func TestUint32(t *testing.T) { + t.Run("marshal", func(t *testing.T) { + assert.Equal(t, "123", m2s(MarshalUint32(123))) + assert.Equal(t, "4294967295", m2s(MarshalUint32(math.MaxUint32))) + }) + + t.Run("unmarshal", func(t *testing.T) { + assert.Equal(t, uint32(123), mustUnmarshalUint32(123)) + assert.Equal(t, uint32(123), mustUnmarshalUint32(int64(123))) + assert.Equal(t, uint32(123), mustUnmarshalUint32(json.Number("123"))) + assert.Equal(t, uint32(123), mustUnmarshalUint32("123")) + assert.Equal(t, uint32(4294967295), mustUnmarshalUint32("4294967295")) + }) +} + +func mustUnmarshalUint32(v interface{}) uint32 { + res, err := UnmarshalUint32(v) + if err != nil { + panic(err) + } + return res +} + +func TestUint64(t *testing.T) { + t.Run("marshal", func(t *testing.T) { + assert.Equal(t, "123", m2s(MarshalUint64(123))) + }) + + t.Run("unmarshal", func(t *testing.T) { + assert.Equal(t, uint64(123), mustUnmarshalUint64(123)) + assert.Equal(t, uint64(123), mustUnmarshalUint64(int64(123))) + assert.Equal(t, uint64(123), mustUnmarshalUint64(json.Number("123"))) + assert.Equal(t, uint64(123), mustUnmarshalUint64("123")) + }) +} + +func mustUnmarshalUint64(v interface{}) uint64 { + res, err := UnmarshalUint64(v) + if err != nil { + panic(err) + } + return res +} diff --git a/graphql/upload.go b/graphql/upload.go new file mode 100644 index 0000000..dafbde6 --- /dev/null +++ b/graphql/upload.go @@ -0,0 +1,27 @@ +package graphql + +import ( + "fmt" + "io" +) + +type Upload struct { + File io.ReadSeeker + Filename string + Size int64 + ContentType string +} + +func MarshalUpload(f Upload) Marshaler { + return WriterFunc(func(w io.Writer) { + io.Copy(w, f.File) + }) +} + +func UnmarshalUpload(v interface{}) (Upload, error) { + upload, ok := v.(Upload) + if !ok { + return Upload{}, fmt.Errorf("%T is not an Upload", v) + } + return upload, nil +} diff --git a/graphql/uuid.go b/graphql/uuid.go new file mode 100644 index 0000000..e9f22dc --- /dev/null +++ b/graphql/uuid.go @@ -0,0 +1,25 @@ +package graphql + +import ( + "fmt" + + "github.com/google/uuid" +) + +func MarshalUUID(id uuid.UUID) Marshaler { + if id == uuid.Nil { + return Null + } + return MarshalString(id.String()) +} + +func UnmarshalUUID(v any) (uuid.UUID, error) { + switch v := v.(type) { + case string: + return uuid.Parse(v) + case []byte: + return uuid.ParseBytes(v) + default: + return uuid.Nil, fmt.Errorf("%T is not a uuid", v) + } +} diff --git a/graphql/uuid_test.go b/graphql/uuid_test.go new file mode 100644 index 0000000..1d20996 --- /dev/null +++ b/graphql/uuid_test.go @@ -0,0 +1,56 @@ +package graphql + +import ( + "testing" + + "github.com/google/uuid" + "github.com/stretchr/testify/assert" +) + +func TestMarshalUUID(t *testing.T) { + t.Run("Null Values", func(t *testing.T) { + assert.Equal(t, "null", m2s(MarshalUUID(uuid.Nil))) + }) + + t.Run("Valid Values", func(t *testing.T) { + + var values = []struct { + input uuid.UUID + expected string + }{ + {uuid.MustParse("fd5343a9-0372-11ee-9fb2-0242ac160014"), "\"fd5343a9-0372-11ee-9fb2-0242ac160014\""}, + } + for _, v := range values { + assert.Equal(t, v.expected, m2s(MarshalUUID(v.input))) + } + }) +} + +func TestUnmarshalUUID(t *testing.T) { + t.Run("Invalid Non-String Values", func(t *testing.T) { + var values = []interface{}{123, 1.2345678901, 1.2e+20, 1.2e-20, true, false, nil} + for _, v := range values { + result, err := UnmarshalUUID(v) + assert.Equal(t, uuid.Nil, result) + assert.ErrorContains(t, err, "is not a uuid") + } + }) + + t.Run("Invalid String Values", func(t *testing.T) { + var values = []struct { + input string + expected string + }{ + {"X50e8400-e29b-41d4-a716-446655440000", "invalid UUID format"}, + {"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "invalid UUID format"}, + {"F50e8400-e29b-41d4-a716-44665544000", "invalid UUID length: 35"}, + {"aaa", "invalid UUID length: 3"}, + {"", "invalid UUID length: 0"}, + } + for _, v := range values { + result, err := UnmarshalUUID(v.input) + assert.Equal(t, uuid.Nil, result) + assert.ErrorContains(t, err, v.expected) + } + }) +} diff --git a/graphql/version.go b/graphql/version.go new file mode 100644 index 0000000..1a9bd4d --- /dev/null +++ b/graphql/version.go @@ -0,0 +1,3 @@ +package graphql + +const Version = "v0.17.42-dev" diff --git a/handler/handler.go b/handler/handler.go new file mode 100644 index 0000000..e80b0a5 --- /dev/null +++ b/handler/handler.go @@ -0,0 +1,257 @@ +package handler + +import ( + "context" + "net/http" + "time" + + "github.com/gorilla/websocket" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/handler/extension" + "github.com/niko0xdev/gqlgen/graphql/handler/lru" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" + "github.com/niko0xdev/gqlgen/graphql/playground" +) + +// Deprecated: switch to graphql/handler.New +func GraphQL(exec graphql.ExecutableSchema, options ...Option) http.HandlerFunc { + var cfg Config + cfg.cacheSize = 1000 + + for _, option := range options { + option(&cfg) + } + + srv := handler.New(exec) + + srv.AddTransport(transport.Websocket{ + Upgrader: cfg.upgrader, + InitFunc: cfg.websocketInitFunc, + KeepAlivePingInterval: cfg.connectionKeepAlivePingInterval, + PingPongInterval: cfg.connectionPingPongInterval, + }) + srv.AddTransport(transport.Options{}) + srv.AddTransport(transport.GET{}) + srv.AddTransport(transport.POST{}) + srv.AddTransport(transport.MultipartForm{ + MaxUploadSize: cfg.uploadMaxSize, + MaxMemory: cfg.uploadMaxMemory, + }) + + if cfg.cacheSize != 0 { + srv.SetQueryCache(lru.New(cfg.cacheSize)) + } + if cfg.recover != nil { + srv.SetRecoverFunc(cfg.recover) + } + if cfg.errorPresenter != nil { + srv.SetErrorPresenter(cfg.errorPresenter) + } + for _, hook := range cfg.fieldHooks { + srv.AroundFields(hook) + } + for _, hook := range cfg.requestHooks { + srv.AroundResponses(hook) + } + if cfg.complexityLimit != 0 { + srv.Use(extension.FixedComplexityLimit(cfg.complexityLimit)) + } else if cfg.complexityLimitFunc != nil { + srv.Use(&extension.ComplexityLimit{ + Func: func(ctx context.Context, rc *graphql.OperationContext) int { + return cfg.complexityLimitFunc(graphql.WithOperationContext(ctx, rc)) + }, + }) + } + if !cfg.disableIntrospection { + srv.Use(extension.Introspection{}) + } + if cfg.apqCache != nil { + srv.Use(extension.AutomaticPersistedQuery{Cache: apqAdapter{cfg.apqCache}}) + } + return srv.ServeHTTP +} + +// Deprecated: switch to graphql/handler.New +type Config struct { + cacheSize int + upgrader websocket.Upgrader + websocketInitFunc transport.WebsocketInitFunc + connectionKeepAlivePingInterval time.Duration + connectionPingPongInterval time.Duration + recover graphql.RecoverFunc + errorPresenter graphql.ErrorPresenterFunc + fieldHooks []graphql.FieldMiddleware + requestHooks []graphql.ResponseMiddleware + complexityLimit int + complexityLimitFunc func(ctx context.Context) int + disableIntrospection bool + uploadMaxMemory int64 + uploadMaxSize int64 + apqCache PersistedQueryCache +} + +// Deprecated: switch to graphql/handler.New +type Option func(cfg *Config) + +// Deprecated: switch to graphql/handler.New +func WebsocketUpgrader(upgrader websocket.Upgrader) Option { + return func(cfg *Config) { + cfg.upgrader = upgrader + } +} + +// Deprecated: switch to graphql/handler.New +func RecoverFunc(recover graphql.RecoverFunc) Option { + return func(cfg *Config) { + cfg.recover = recover + } +} + +// ErrorPresenter transforms errors found while resolving into errors that will be returned to the user. It provides +// a good place to add any extra fields, like error.type, that might be desired by your frontend. Check the default +// implementation in graphql.DefaultErrorPresenter for an example. +// Deprecated: switch to graphql/handler.New +func ErrorPresenter(f graphql.ErrorPresenterFunc) Option { + return func(cfg *Config) { + cfg.errorPresenter = f + } +} + +// IntrospectionEnabled = false will forbid clients from calling introspection endpoints. Can be useful in prod when you don't +// want clients introspecting the full schema. +// Deprecated: switch to graphql/handler.New +func IntrospectionEnabled(enabled bool) Option { + return func(cfg *Config) { + cfg.disableIntrospection = !enabled + } +} + +// ComplexityLimit sets a maximum query complexity that is allowed to be executed. +// If a query is submitted that exceeds the limit, a 422 status code will be returned. +// Deprecated: switch to graphql/handler.New +func ComplexityLimit(limit int) Option { + return func(cfg *Config) { + cfg.complexityLimit = limit + } +} + +// ComplexityLimitFunc allows you to define a function to dynamically set the maximum query complexity that is allowed +// to be executed. +// If a query is submitted that exceeds the limit, a 422 status code will be returned. +// Deprecated: switch to graphql/handler.New +func ComplexityLimitFunc(complexityLimitFunc func(ctx context.Context) int) Option { + return func(cfg *Config) { + cfg.complexityLimitFunc = complexityLimitFunc + } +} + +// ResolverMiddleware allows you to define a function that will be called around every resolver, +// useful for logging. +// Deprecated: switch to graphql/handler.New +func ResolverMiddleware(middleware graphql.FieldMiddleware) Option { + return func(cfg *Config) { + cfg.fieldHooks = append(cfg.fieldHooks, middleware) + } +} + +// RequestMiddleware allows you to define a function that will be called around the root request, +// after the query has been parsed. This is useful for logging +// Deprecated: switch to graphql/handler.New +func RequestMiddleware(middleware graphql.ResponseMiddleware) Option { + return func(cfg *Config) { + cfg.requestHooks = append(cfg.requestHooks, middleware) + } +} + +// WebsocketInitFunc is called when the server receives connection init message from the client. +// This can be used to check initial payload to see whether to accept the websocket connection. +// Deprecated: switch to graphql/handler.New +func WebsocketInitFunc(websocketInitFunc transport.WebsocketInitFunc) Option { + return func(cfg *Config) { + cfg.websocketInitFunc = websocketInitFunc + } +} + +// CacheSize sets the maximum size of the query cache. +// If size is less than or equal to 0, the cache is disabled. +// Deprecated: switch to graphql/handler.New +func CacheSize(size int) Option { + return func(cfg *Config) { + cfg.cacheSize = size + } +} + +// UploadMaxSize sets the maximum number of bytes used to parse a request body +// as multipart/form-data. +// Deprecated: switch to graphql/handler.New +func UploadMaxSize(size int64) Option { + return func(cfg *Config) { + cfg.uploadMaxSize = size + } +} + +// UploadMaxMemory sets the maximum number of bytes used to parse a request body +// as multipart/form-data in memory, with the remainder stored on disk in +// temporary files. +// Deprecated: switch to graphql/handler.New +func UploadMaxMemory(size int64) Option { + return func(cfg *Config) { + cfg.uploadMaxMemory = size + } +} + +// WebsocketKeepAliveDuration allows you to reconfigure the keepalive behavior. +// By default, keepalive is enabled with a DefaultConnectionKeepAlivePingInterval +// duration. Set handler.connectionKeepAlivePingInterval = 0 to disable keepalive +// altogether. +// Deprecated: switch to graphql/handler.New +func WebsocketKeepAliveDuration(duration time.Duration) Option { + return func(cfg *Config) { + cfg.connectionKeepAlivePingInterval = duration + } +} + +func WebsocketPingPongDuration(duration time.Duration) Option { + return func(cfg *Config) { + cfg.connectionPingPongInterval = duration + } +} + +// Add cache that will hold queries for automatic persisted queries (APQ) +// Deprecated: switch to graphql/handler.New +func EnablePersistedQueryCache(cache PersistedQueryCache) Option { + return func(cfg *Config) { + cfg.apqCache = cache + } +} + +func GetInitPayload(ctx context.Context) transport.InitPayload { + return transport.GetInitPayload(ctx) +} + +type apqAdapter struct { + PersistedQueryCache +} + +func (a apqAdapter) Get(ctx context.Context, key string) (value interface{}, ok bool) { + return a.PersistedQueryCache.Get(ctx, key) +} + +func (a apqAdapter) Add(ctx context.Context, key string, value interface{}) { + a.PersistedQueryCache.Add(ctx, key, value.(string)) +} + +type PersistedQueryCache interface { + Add(ctx context.Context, hash string, query string) + Get(ctx context.Context, hash string) (string, bool) +} + +// Deprecated: use playground.Handler instead +func Playground(title string, endpoint string) http.HandlerFunc { + return playground.Handler(title, endpoint) +} + +// Deprecated: use transport.InitPayload instead +type InitPayload = transport.InitPayload diff --git a/init-templates/gqlgen.yml.gotmpl b/init-templates/gqlgen.yml.gotmpl new file mode 100644 index 0000000..ee333d7 --- /dev/null +++ b/init-templates/gqlgen.yml.gotmpl @@ -0,0 +1,87 @@ +# Where are all the schema files located? globs are supported eg src/**/*.graphqls +schema: + - graph/*.graphqls + +# Where should the generated server code go? +exec: + filename: graph/generated.go + package: graph + +# Uncomment to enable federation +# federation: +# filename: graph/federation.go +# package: graph + +# Where should any generated models go? +model: + filename: graph/model/models_gen.go + package: model + +# Where should the resolver implementations go? +resolver: + layout: follow-schema + dir: graph + package: graph + filename_template: "{name}.resolvers.go" + # Optional: turn on to not generate template comments above resolvers + # omit_template_comment: false + +# Optional: turn on use ` + "`" + `gqlgen:"fieldName"` + "`" + ` tags in your models +# struct_tag: json + +# Optional: turn on to use []Thing instead of []*Thing +# omit_slice_element_pointers: false + +# Optional: turn on to omit Is<Name>() methods to interface and unions +# omit_interface_checks : true + +# Optional: turn on to skip generation of ComplexityRoot struct content and Complexity function +# omit_complexity: false + +# Optional: turn on to not generate any file notice comments in generated files +# omit_gqlgen_file_notice: false + +# Optional: turn on to exclude the gqlgen version in the generated file notice. No effect if `omit_gqlgen_file_notice` is true. +# omit_gqlgen_version_in_file_notice: false + +# Optional: turn off to make struct-type struct fields not use pointers +# e.g. type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing } +# struct_fields_always_pointers: true + +# Optional: turn off to make resolvers return values instead of pointers for structs +# resolvers_always_return_pointers: true + +# Optional: turn on to return pointers instead of values in unmarshalInput +# return_pointers_in_unmarshalinput: false + +# Optional: wrap nullable input fields with Omittable +# nullable_input_omittable: true + +# 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: +# - "{{.}}/graph/model" + +# This section declares type mapping between the GraphQL and go type systems +# +# The first line in each type will be used as defaults for resolver arguments and +# modelgen, the others will be allowed when binding to fields. Configure them to +# your liking +models: + ID: + model: + - github.com/niko0xdev/gqlgen/graphql.ID + - github.com/niko0xdev/gqlgen/graphql.Int + - github.com/niko0xdev/gqlgen/graphql.Int64 + - github.com/niko0xdev/gqlgen/graphql.Int32 + Int: + model: + - github.com/niko0xdev/gqlgen/graphql.Int + - github.com/niko0xdev/gqlgen/graphql.Int64 + - github.com/niko0xdev/gqlgen/graphql.Int32 diff --git a/init-templates/schema.graphqls b/init-templates/schema.graphqls new file mode 100644 index 0000000..c6a91bb --- /dev/null +++ b/init-templates/schema.graphqls @@ -0,0 +1,28 @@ +# GraphQL schema example +# +# https://gqlgen.com/getting-started/ + +type Todo { + id: ID! + text: String! + done: Boolean! + user: User! +} + +type User { + id: ID! + name: String! +} + +type Query { + todos: [Todo!]! +} + +input NewTodo { + text: String! + userId: String! +} + +type Mutation { + createTodo(input: NewTodo!): Todo! +} diff --git a/integration/.gitignore b/integration/.gitignore new file mode 100644 index 0000000..a547bf3 --- /dev/null +++ b/integration/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/integration/README.md b/integration/README.md new file mode 100644 index 0000000..a57ea9d --- /dev/null +++ b/integration/README.md @@ -0,0 +1,15 @@ +# Integration tests + +These tests run a gqlgen server against the apollo client to test real world connectivity. + +First start the go server +```bash +go run server/cmd/integration/server.go +``` + +And in another terminal: +```bash +cd integration +npm ci +npm run test +``` diff --git a/integration/codegen.ts b/integration/codegen.ts new file mode 100644 index 0000000..389228c --- /dev/null +++ b/integration/codegen.ts @@ -0,0 +1,20 @@ +import type { CodegenConfig } from '@graphql-codegen/cli'; + +const config: CodegenConfig = { + overwrite: true, + schema: process.env.VITE_SERVER_URL ?? 'http://localhost:8080/query', + documents: 'src/**/*.graphql', + generates: { + 'src/generated/': { + preset: 'client-preset' + }, + 'src/generated/schema-fetched.graphql': { + plugins: ['schema-ast'], + }, + 'src/generated/schema-introspection.json': { + plugins: ['introspection'], + } + }, +}; + +export default config; diff --git a/integration/graphql.config.yml b/integration/graphql.config.yml new file mode 100644 index 0000000..da54c77 --- /dev/null +++ b/integration/graphql.config.yml @@ -0,0 +1,7 @@ +name: Schema +schema: src/generated/schema-expected.graphql +extensions: + endpoints: + dev: + url: http://localhost:8080/query + introspect: true diff --git a/integration/package-lock.json b/integration/package-lock.json new file mode 100644 index 0000000..21e629b --- /dev/null +++ b/integration/package-lock.json @@ -0,0 +1,7256 @@ +{ + "name": "integration", + "version": "0.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "integration", + "version": "0.0.0", + "devDependencies": { + "@apollo/client": "^3.7.14", + "@graphql-codegen/cli": "^4.0.0", + "@graphql-codegen/client-preset": "^4.0.0", + "@graphql-codegen/introspection": "^4.0.0", + "@graphql-codegen/schema-ast": "^4.0.0", + "graphql": "^16.6.0", + "graphql-codegen": "^0.4.0", + "graphql-sse": "^2.1.4", + "graphql-ws": "^5.13.1", + "typescript": "^5.0.2", + "urql": "^4.0.3", + "vite": "^4.3.9", + "vitest": "^0.32.0" + } + }, + "node_modules/@0no-co/graphql.web": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@0no-co/graphql.web/-/graphql.web-1.0.4.tgz", + "integrity": "sha512-W3ezhHGfO0MS1PtGloaTpg0PbaT8aZSmmaerL7idtU5F7oCI+uu25k+MsMS31BVFlp4aMkHSrNRxiD72IlK8TA==", + "dev": true, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0" + }, + "peerDependenciesMeta": { + "graphql": { + "optional": true + } + } + }, + "node_modules/@ampproject/remapping": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", + "integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==", + "dev": true, + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@apollo/client": { + "version": "3.7.15", + "resolved": "https://registry.npmjs.org/@apollo/client/-/client-3.7.15.tgz", + "integrity": "sha512-pLScjo4GAQRWKWyEg2J3FlQr9fbUAuADT0EI2+JlLf2BjaU9I7WUaZVD9w+0qNPE8BZqs53MRQq0OCm1QCW+eg==", + "dev": true, + "dependencies": { + "@graphql-typed-document-node/core": "^3.1.1", + "@wry/context": "^0.7.0", + "@wry/equality": "^0.5.0", + "@wry/trie": "^0.4.0", + "graphql-tag": "^2.12.6", + "hoist-non-react-statics": "^3.3.2", + "optimism": "^0.16.2", + "prop-types": "^15.7.2", + "response-iterator": "^0.2.6", + "symbol-observable": "^4.0.0", + "ts-invariant": "^0.10.3", + "tslib": "^2.3.0", + "zen-observable-ts": "^1.2.5" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0", + "graphql-ws": "^5.5.5", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0", + "subscriptions-transport-ws": "^0.9.0 || ^0.11.0" + }, + "peerDependenciesMeta": { + "graphql-ws": { + "optional": true + }, + "react": { + "optional": true + }, + "react-dom": { + "optional": true + }, + "subscriptions-transport-ws": { + "optional": true + } + } + }, + "node_modules/@ardatan/relay-compiler": { + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/@ardatan/relay-compiler/-/relay-compiler-12.0.0.tgz", + "integrity": "sha512-9anThAaj1dQr6IGmzBMcfzOQKTa5artjuPmw8NYK/fiGEMjADbSguBY2FMDykt+QhilR3wc9VA/3yVju7JHg7Q==", + "dev": true, + "dependencies": { + "@babel/core": "^7.14.0", + "@babel/generator": "^7.14.0", + "@babel/parser": "^7.14.0", + "@babel/runtime": "^7.0.0", + "@babel/traverse": "^7.14.0", + "@babel/types": "^7.0.0", + "babel-preset-fbjs": "^3.4.0", + "chalk": "^4.0.0", + "fb-watchman": "^2.0.0", + "fbjs": "^3.0.0", + "glob": "^7.1.1", + "immutable": "~3.7.6", + "invariant": "^2.2.4", + "nullthrows": "^1.1.1", + "relay-runtime": "12.0.0", + "signedsource": "^1.0.0", + "yargs": "^15.3.1" + }, + "bin": { + "relay-compiler": "bin/relay-compiler" + }, + "peerDependencies": { + "graphql": "*" + } + }, + "node_modules/@ardatan/relay-compiler/node_modules/cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "node_modules/@ardatan/relay-compiler/node_modules/wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@ardatan/relay-compiler/node_modules/y18n": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", + "dev": true + }, + "node_modules/@ardatan/relay-compiler/node_modules/yargs": { + "version": "15.4.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "dev": true, + "dependencies": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@ardatan/relay-compiler/node_modules/yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "dev": true, + "dependencies": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/@ardatan/sync-fetch": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/@ardatan/sync-fetch/-/sync-fetch-0.0.1.tgz", + "integrity": "sha512-xhlTqH0m31mnsG0tIP4ETgfSB6gXDaYYsUWTrlUV93fFQPI9dd8hE0Ot6MHLCtqgB32hwJAC3YZMWlXZw7AleA==", + "dev": true, + "dependencies": { + "node-fetch": "^2.6.1" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.22.13", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz", + "integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==", + "dev": true, + "dependencies": { + "@babel/highlight": "^7.22.13", + "chalk": "^2.4.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/code-frame/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/@babel/code-frame/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, + "node_modules/@babel/code-frame/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.22.5.tgz", + "integrity": "sha512-4Jc/YuIaYqKnDDz892kPIledykKg12Aw1PYX5i/TY28anJtacvM1Rrr8wbieB9GfEJwlzqT0hUEao0CxEebiDA==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.22.5.tgz", + "integrity": "sha512-SBuTAjg91A3eKOvD+bPEz3LlhHZRNu1nFOVts9lzDJTXshHTjII0BAtDS3Y2DAkdZdDKWVZGVwkDfc4Clxn1dg==", + "dev": true, + "dependencies": { + "@ampproject/remapping": "^2.2.0", + "@babel/code-frame": "^7.22.5", + "@babel/generator": "^7.22.5", + "@babel/helper-compilation-targets": "^7.22.5", + "@babel/helper-module-transforms": "^7.22.5", + "@babel/helpers": "^7.22.5", + "@babel/parser": "^7.22.5", + "@babel/template": "^7.22.5", + "@babel/traverse": "^7.22.5", + "@babel/types": "^7.22.5", + "convert-source-map": "^1.7.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.2", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/generator": { + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.0.tgz", + "integrity": "sha512-lN85QRR+5IbYrMWM6Y4pE/noaQtg4pNiqeNGX60eqOfo6gtEj6uw/JagelB8vVztSd7R6M5n1+PQkDbHbBRU4g==", + "dev": true, + "dependencies": { + "@babel/types": "^7.23.0", + "@jridgewell/gen-mapping": "^0.3.2", + "@jridgewell/trace-mapping": "^0.3.17", + "jsesc": "^2.5.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-annotate-as-pure": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.22.5.tgz", + "integrity": "sha512-LvBTxu8bQSQkcyKOU+a1btnNFQ1dMAd0R6PyW3arXes06F6QLWLIrd681bxRPIXlrMGR3XYnW9JyML7dP3qgxg==", + "dev": true, + "dependencies": { + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.22.5.tgz", + "integrity": "sha512-Ji+ywpHeuqxB8WDxraCiqR0xfhYjiDE/e6k7FuIaANnoOFxAHskHChz4vA1mJC9Lbm01s1PVAGhQY4FUKSkGZw==", + "dev": true, + "dependencies": { + "@babel/compat-data": "^7.22.5", + "@babel/helper-validator-option": "^7.22.5", + "browserslist": "^4.21.3", + "lru-cache": "^5.1.1", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-create-class-features-plugin": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.22.5.tgz", + "integrity": "sha512-xkb58MyOYIslxu3gKmVXmjTtUPvBU4odYzbiIQbWwLKIHCsx6UGZGX6F1IznMFVnDdirseUZopzN+ZRt8Xb33Q==", + "dev": true, + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.22.5", + "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-function-name": "^7.22.5", + "@babel/helper-member-expression-to-functions": "^7.22.5", + "@babel/helper-optimise-call-expression": "^7.22.5", + "@babel/helper-replace-supers": "^7.22.5", + "@babel/helper-skip-transparent-expression-wrappers": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.5", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-environment-visitor": { + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-function-name": { + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz", + "integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==", + "dev": true, + "dependencies": { + "@babel/template": "^7.22.15", + "@babel/types": "^7.23.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-hoist-variables": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz", + "integrity": "sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==", + "dev": true, + "dependencies": { + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-member-expression-to-functions": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.22.5.tgz", + "integrity": "sha512-aBiH1NKMG0H2cGZqspNvsaBe6wNGjbJjuLy29aU+eDZjSbbN53BaxlpB02xm9v34pLTZ1nIQPFYn2qMZoa5BQQ==", + "dev": true, + "dependencies": { + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.22.5.tgz", + "integrity": "sha512-8Dl6+HD/cKifutF5qGd/8ZJi84QeAKh+CEe1sBzz8UayBBGg1dAIJrdHOcOM5b2MpzWL2yuotJTtGjETq0qjXg==", + "dev": true, + "dependencies": { + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.22.5.tgz", + "integrity": "sha512-+hGKDt/Ze8GFExiVHno/2dvG5IdstpzCq0y4Qc9OJ25D4q3pKfiIP/4Vp3/JvhDkLKsDK2api3q3fpIgiIF5bw==", + "dev": true, + "dependencies": { + "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-module-imports": "^7.22.5", + "@babel/helper-simple-access": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.5", + "@babel/template": "^7.22.5", + "@babel/traverse": "^7.22.5", + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-optimise-call-expression": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.22.5.tgz", + "integrity": "sha512-HBwaojN0xFRx4yIvpwGqxiV2tUfl7401jlok564NgB9EHS1y6QT17FmKWm4ztqjeVdXLuC4fSvHc5ePpQjoTbw==", + "dev": true, + "dependencies": { + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.22.5.tgz", + "integrity": "sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-replace-supers": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.22.5.tgz", + "integrity": "sha512-aLdNM5I3kdI/V9xGNyKSF3X/gTyMUBohTZ+/3QdQKAA9vxIiy12E+8E2HoOP1/DjeqU+g6as35QHJNMDDYpuCg==", + "dev": true, + "dependencies": { + "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-member-expression-to-functions": "^7.22.5", + "@babel/helper-optimise-call-expression": "^7.22.5", + "@babel/template": "^7.22.5", + "@babel/traverse": "^7.22.5", + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-simple-access": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.22.5.tgz", + "integrity": "sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w==", + "dev": true, + "dependencies": { + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-skip-transparent-expression-wrappers": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.22.5.tgz", + "integrity": "sha512-tK14r66JZKiC43p8Ki33yLBVJKlQDFoA8GYN67lWCDCqoL6EMMSuM9b+Iff2jHaM/RRFYl7K+iiru7hbRqNx8Q==", + "dev": true, + "dependencies": { + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-split-export-declaration": { + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz", + "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==", + "dev": true, + "dependencies": { + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz", + "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", + "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.22.5.tgz", + "integrity": "sha512-R3oB6xlIVKUnxNUxbmgq7pKjxpru24zlimpE8WK47fACIlM0II/Hm1RS8IaOI7NgCr6LNS+jl5l75m20npAziw==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.22.5.tgz", + "integrity": "sha512-pSXRmfE1vzcUIDFQcSGA5Mr+GxBV9oiRKDuDxXvWQQBCh8HoIjs/2DlDB7H8smac1IVrB9/xdXj2N3Wol9Cr+Q==", + "dev": true, + "dependencies": { + "@babel/template": "^7.22.5", + "@babel/traverse": "^7.22.5", + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight": { + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.20.tgz", + "integrity": "sha512-dkdMCN3py0+ksCgYmGG8jKeGA/8Tk+gJwSYYlFGxG5lmhfKNoAy004YpLxpS1W2J8m/EK2Ew+yOs9pVRwO89mg==", + "dev": true, + "dependencies": { + "@babel/helper-validator-identifier": "^7.22.20", + "chalk": "^2.4.2", + "js-tokens": "^4.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/@babel/highlight/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, + "node_modules/@babel/highlight/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/parser": { + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz", + "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==", + "dev": true, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/plugin-proposal-class-properties": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.18.6.tgz", + "integrity": "sha512-cumfXOF0+nzZrrN8Rf0t7M+tF6sZc7vhQwYQck9q1/5w2OExlD+b4v4RpMJFaV1Z7WcDRgO6FqvxqxGlwo+RHQ==", + "dev": true, + "dependencies": { + "@babel/helper-create-class-features-plugin": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-object-rest-spread": { + "version": "7.20.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.20.7.tgz", + "integrity": "sha512-d2S98yCiLxDVmBmE8UjGcfPvNEUbA1U5q5WxaWFUGRzJSVAZqm5W6MbPct0jxnegUZ0niLeNX+IOzEs7wYg9Dg==", + "dev": true, + "dependencies": { + "@babel/compat-data": "^7.20.5", + "@babel/helper-compilation-targets": "^7.20.7", + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/plugin-syntax-object-rest-spread": "^7.8.3", + "@babel/plugin-transform-parameters": "^7.20.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-class-properties": { + "version": "7.12.13", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", + "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.12.13" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-flow": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.22.5.tgz", + "integrity": "sha512-9RdCl0i+q0QExayk2nOS7853w08yLucnnPML6EN9S8fgMPVtdLDCdx/cOQ/i44Lb9UeQX9A35yaqBBOMMZxPxQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-import-assertions": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.22.5.tgz", + "integrity": "sha512-rdV97N7KqsRzeNGoWUOK6yUsWarLjE5Su/Snk9IYPU9CwkWHs4t+rTGOvffTR8XGkJMTAdLfO0xVnXm8wugIJg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-jsx": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.22.5.tgz", + "integrity": "sha512-gvyP4hZrgrs/wWMaocvxZ44Hw0b3W8Pe+cMxc8V1ULQ07oh8VNbIRaoD1LRZVTvD+0nieDKjfgKg89sD7rrKrg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-object-rest-spread": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", + "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-arrow-functions": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.22.5.tgz", + "integrity": "sha512-26lTNXoVRdAnsaDXPpvCNUq+OVWEVC6bx7Vvz9rC53F2bagUWW4u4ii2+h8Fejfh7RYqPxn+libeFBBck9muEw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-block-scoped-functions": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.22.5.tgz", + "integrity": "sha512-tdXZ2UdknEKQWKJP1KMNmuF5Lx3MymtMN/pvA+p/VEkhK8jVcQ1fzSy8KM9qRYhAf2/lV33hoMPKI/xaI9sADA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-block-scoping": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.22.5.tgz", + "integrity": "sha512-EcACl1i5fSQ6bt+YGuU/XGCeZKStLmyVGytWkpyhCLeQVA0eu6Wtiw92V+I1T/hnezUv7j74dA/Ro69gWcU+hg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-classes": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.22.5.tgz", + "integrity": "sha512-2edQhLfibpWpsVBx2n/GKOz6JdGQvLruZQfGr9l1qes2KQaWswjBzhQF7UDUZMNaMMQeYnQzxwOMPsbYF7wqPQ==", + "dev": true, + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.22.5", + "@babel/helper-compilation-targets": "^7.22.5", + "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-function-name": "^7.22.5", + "@babel/helper-optimise-call-expression": "^7.22.5", + "@babel/helper-plugin-utils": "^7.22.5", + "@babel/helper-replace-supers": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.5", + "globals": "^11.1.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-computed-properties": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.22.5.tgz", + "integrity": "sha512-4GHWBgRf0krxPX+AaPtgBAlTgTeZmqDynokHOX7aqqAB4tHs3U2Y02zH6ETFdLZGcg9UQSD1WCmkVrE9ErHeOg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5", + "@babel/template": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-destructuring": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.22.5.tgz", + "integrity": "sha512-GfqcFuGW8vnEqTUBM7UtPd5A4q797LTvvwKxXTgRsFjoqaJiEg9deBG6kWeQYkVEL569NpnmpC0Pkr/8BLKGnQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-flow-strip-types": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-flow-strip-types/-/plugin-transform-flow-strip-types-7.22.5.tgz", + "integrity": "sha512-tujNbZdxdG0/54g/oua8ISToaXTFBf8EnSb5PgQSciIXWOWKX3S4+JR7ZE9ol8FZwf9kxitzkGQ+QWeov/mCiA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5", + "@babel/plugin-syntax-flow": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-for-of": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.22.5.tgz", + "integrity": "sha512-3kxQjX1dU9uudwSshyLeEipvrLjBCVthCgeTp6CzE/9JYrlAIaeekVxRpCWsDDfYTfRZRoCeZatCQvwo+wvK8A==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-function-name": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.22.5.tgz", + "integrity": "sha512-UIzQNMS0p0HHiQm3oelztj+ECwFnj+ZRV4KnguvlsD2of1whUeM6o7wGNj6oLwcDoAXQ8gEqfgC24D+VdIcevg==", + "dev": true, + "dependencies": { + "@babel/helper-compilation-targets": "^7.22.5", + "@babel/helper-function-name": "^7.22.5", + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-literals": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-literals/-/plugin-transform-literals-7.22.5.tgz", + "integrity": "sha512-fTLj4D79M+mepcw3dgFBTIDYpbcB9Sm0bpm4ppXPaO+U+PKFFyV9MGRvS0gvGw62sd10kT5lRMKXAADb9pWy8g==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-member-expression-literals": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.22.5.tgz", + "integrity": "sha512-RZEdkNtzzYCFl9SE9ATaUMTj2hqMb4StarOJLrZRbqqU4HSBE7UlBw9WBWQiDzrJZJdUWiMTVDI6Gv/8DPvfew==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-modules-commonjs": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.22.5.tgz", + "integrity": "sha512-B4pzOXj+ONRmuaQTg05b3y/4DuFz3WcCNAXPLb2Q0GT0TrGKGxNKV4jwsXts+StaM0LQczZbOpj8o1DLPDJIiA==", + "dev": true, + "dependencies": { + "@babel/helper-module-transforms": "^7.22.5", + "@babel/helper-plugin-utils": "^7.22.5", + "@babel/helper-simple-access": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-object-super": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.22.5.tgz", + "integrity": "sha512-klXqyaT9trSjIUrcsYIfETAzmOEZL3cBYqOYLJxBHfMFFggmXOv+NYSX/Jbs9mzMVESw/WycLFPRx8ba/b2Ipw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5", + "@babel/helper-replace-supers": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-parameters": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.22.5.tgz", + "integrity": "sha512-AVkFUBurORBREOmHRKo06FjHYgjrabpdqRSwq6+C7R5iTCZOsM4QbcB27St0a4U6fffyAOqh3s/qEfybAhfivg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-property-literals": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.22.5.tgz", + "integrity": "sha512-TiOArgddK3mK/x1Qwf5hay2pxI6wCZnvQqrFSqbtg1GLl2JcNMitVH/YnqjP+M31pLUeTfzY1HAXFDnUBV30rQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-react-display-name": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-display-name/-/plugin-transform-react-display-name-7.22.5.tgz", + "integrity": "sha512-PVk3WPYudRF5z4GKMEYUrLjPl38fJSKNaEOkFuoprioowGuWN6w2RKznuFNSlJx7pzzXXStPUnNSOEO0jL5EVw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.22.5.tgz", + "integrity": "sha512-rog5gZaVbUip5iWDMTYbVM15XQq+RkUKhET/IHR6oizR+JEoN6CAfTTuHcK4vwUyzca30qqHqEpzBOnaRMWYMA==", + "dev": true, + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.22.5", + "@babel/helper-module-imports": "^7.22.5", + "@babel/helper-plugin-utils": "^7.22.5", + "@babel/plugin-syntax-jsx": "^7.22.5", + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-shorthand-properties": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.22.5.tgz", + "integrity": "sha512-vM4fq9IXHscXVKzDv5itkO1X52SmdFBFcMIBZ2FRn2nqVYqw6dBexUgMvAjHW+KXpPPViD/Yo3GrDEBaRC0QYA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-spread": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-spread/-/plugin-transform-spread-7.22.5.tgz", + "integrity": "sha512-5ZzDQIGyvN4w8+dMmpohL6MBo+l2G7tfC/O2Dg7/hjpgeWvUx8FzfeOKxGog9IimPa4YekaQ9PlDqTLOljkcxg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5", + "@babel/helper-skip-transparent-expression-wrappers": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-template-literals": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.22.5.tgz", + "integrity": "sha512-5ciOehRNf+EyUeewo8NkbQiUs4d6ZxiHo6BcBcnFlgiJfu16q0bQUw9Jvo0b0gBKFG1SMhDSjeKXSYuJLeFSMA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/runtime": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.5.tgz", + "integrity": "sha512-ecjvYlnAaZ/KVneE/OdKYBYfgXV3Ptu6zQWmgEF7vwKhQnvVS6bjMD2XYgj+SNvQ1GfK/pjgokfPkC/2CO8CuA==", + "dev": true, + "dependencies": { + "regenerator-runtime": "^0.13.11" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/template": { + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", + "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.22.13", + "@babel/parser": "^7.22.15", + "@babel/types": "^7.22.15" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.23.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz", + "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.22.13", + "@babel/generator": "^7.23.0", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-function-name": "^7.23.0", + "@babel/helper-hoist-variables": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/parser": "^7.23.0", + "@babel/types": "^7.23.0", + "debug": "^4.1.0", + "globals": "^11.1.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz", + "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==", + "dev": true, + "dependencies": { + "@babel/helper-string-parser": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.20", + "to-fast-properties": "^2.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.19.tgz", + "integrity": "sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.17.19.tgz", + "integrity": "sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.17.19.tgz", + "integrity": "sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz", + "integrity": "sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.19.tgz", + "integrity": "sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.19.tgz", + "integrity": "sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.17.19.tgz", + "integrity": "sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.17.19.tgz", + "integrity": "sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz", + "integrity": "sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.17.19.tgz", + "integrity": "sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.17.19.tgz", + "integrity": "sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.17.19.tgz", + "integrity": "sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A==", + "cpu": [ + "mips64el" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.17.19.tgz", + "integrity": "sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.17.19.tgz", + "integrity": "sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.17.19.tgz", + "integrity": "sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz", + "integrity": "sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.17.19.tgz", + "integrity": "sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz", + "integrity": "sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.17.19.tgz", + "integrity": "sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz", + "integrity": "sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.17.19.tgz", + "integrity": "sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz", + "integrity": "sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@graphql-codegen/add": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@graphql-codegen/add/-/add-5.0.0.tgz", + "integrity": "sha512-ynWDOsK2yxtFHwcJTB9shoSkUd7YXd6ZE57f0nk7W5cu/nAgxZZpEsnTPEpZB/Mjf14YRGe2uJHQ7AfElHjqUQ==", + "dev": true, + "dependencies": { + "@graphql-codegen/plugin-helpers": "^5.0.0", + "tslib": "~2.5.0" + }, + "peerDependencies": { + "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" + } + }, + "node_modules/@graphql-codegen/cli": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@graphql-codegen/cli/-/cli-4.0.1.tgz", + "integrity": "sha512-/H4imnGOl3hoPXLKmIiGUnXpmBmeIClSZie/YHDzD5N59cZlGGJlIOOrUlOTDpJx5JNU1MTQcRjyTToOYM5IfA==", + "dev": true, + "dependencies": { + "@babel/generator": "^7.18.13", + "@babel/template": "^7.18.10", + "@babel/types": "^7.18.13", + "@graphql-codegen/core": "^4.0.0", + "@graphql-codegen/plugin-helpers": "^5.0.0", + "@graphql-tools/apollo-engine-loader": "^8.0.0", + "@graphql-tools/code-file-loader": "^8.0.0", + "@graphql-tools/git-loader": "^8.0.0", + "@graphql-tools/github-loader": "^8.0.0", + "@graphql-tools/graphql-file-loader": "^8.0.0", + "@graphql-tools/json-file-loader": "^8.0.0", + "@graphql-tools/load": "^8.0.0", + "@graphql-tools/prisma-loader": "^8.0.0", + "@graphql-tools/url-loader": "^8.0.0", + "@graphql-tools/utils": "^10.0.0", + "@parcel/watcher": "^2.1.0", + "@whatwg-node/fetch": "^0.8.0", + "chalk": "^4.1.0", + "cosmiconfig": "^8.1.3", + "debounce": "^1.2.0", + "detect-indent": "^6.0.0", + "graphql-config": "^5.0.2", + "inquirer": "^8.0.0", + "is-glob": "^4.0.1", + "jiti": "^1.17.1", + "json-to-pretty-yaml": "^1.2.2", + "listr2": "^4.0.5", + "log-symbols": "^4.0.0", + "micromatch": "^4.0.5", + "shell-quote": "^1.7.3", + "string-env-interpolation": "^1.0.1", + "ts-log": "^2.2.3", + "tslib": "^2.4.0", + "yaml": "^1.10.0", + "yargs": "^17.0.0" + }, + "bin": { + "gql-gen": "cjs/bin.js", + "graphql-code-generator": "cjs/bin.js", + "graphql-codegen": "cjs/bin.js", + "graphql-codegen-esm": "esm/bin.js" + }, + "peerDependencies": { + "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" + } + }, + "node_modules/@graphql-codegen/client-preset": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@graphql-codegen/client-preset/-/client-preset-4.0.0.tgz", + "integrity": "sha512-A96Vc+ZHMoBTO7bH/I/iIqCBsDiXblKqhyMQsSfq79Muvtmhjx4E9Xt4s++/zpBbe4M+46EYLlde2ZIrymSqDw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/template": "^7.20.7", + "@graphql-codegen/add": "^5.0.0", + "@graphql-codegen/gql-tag-operations": "4.0.0", + "@graphql-codegen/plugin-helpers": "^5.0.0", + "@graphql-codegen/typed-document-node": "^5.0.0", + "@graphql-codegen/typescript": "^4.0.0", + "@graphql-codegen/typescript-operations": "^4.0.0", + "@graphql-codegen/visitor-plugin-common": "^4.0.0", + "@graphql-tools/documents": "^1.0.0", + "@graphql-tools/utils": "^10.0.0", + "@graphql-typed-document-node/core": "3.2.0", + "tslib": "~2.5.0" + }, + "peerDependencies": { + "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" + } + }, + "node_modules/@graphql-codegen/core": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@graphql-codegen/core/-/core-4.0.0.tgz", + "integrity": "sha512-JAGRn49lEtSsZVxeIlFVIRxts2lWObR+OQo7V2LHDJ7ohYYw3ilv7nJ8pf8P4GTg/w6ptcYdSdVVdkI8kUHB/Q==", + "dev": true, + "dependencies": { + "@graphql-codegen/plugin-helpers": "^5.0.0", + "@graphql-tools/schema": "^10.0.0", + "@graphql-tools/utils": "^10.0.0", + "tslib": "~2.5.0" + }, + "peerDependencies": { + "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" + } + }, + "node_modules/@graphql-codegen/gql-tag-operations": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@graphql-codegen/gql-tag-operations/-/gql-tag-operations-4.0.0.tgz", + "integrity": "sha512-LLbyxjdtK5e78xmcQiy4aXzsttR+3VE8EsiGy9++ih8/JGsqxMcXEy4MtsVGh8KGdP+LCR+jA1o6grzm2tI3cw==", + "dev": true, + "dependencies": { + "@graphql-codegen/plugin-helpers": "^5.0.0", + "@graphql-codegen/visitor-plugin-common": "4.0.0", + "@graphql-tools/utils": "^10.0.0", + "auto-bind": "~4.0.0", + "tslib": "~2.5.0" + }, + "peerDependencies": { + "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" + } + }, + "node_modules/@graphql-codegen/introspection": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@graphql-codegen/introspection/-/introspection-4.0.0.tgz", + "integrity": "sha512-t9g3AkK99dfHblMWtG4ynUM9+A7JrWq5110zSpNV2wlSnv0+bRKagDW8gozwgXfR5i1IIG8QDjJZ6VgXQVqCZw==", + "dev": true, + "dependencies": { + "@graphql-codegen/plugin-helpers": "^5.0.0", + "@graphql-codegen/visitor-plugin-common": "^4.0.0", + "tslib": "~2.5.0" + }, + "peerDependencies": { + "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" + } + }, + "node_modules/@graphql-codegen/plugin-helpers": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@graphql-codegen/plugin-helpers/-/plugin-helpers-5.0.0.tgz", + "integrity": "sha512-suL2ZMkBAU2a4YbBHaZvUPsV1z0q3cW6S96Z/eYYfkRIsJoe2vN+wNZ9Xdzmqx0JLmeeFCBSoBGC0imFyXlkDQ==", + "dev": true, + "dependencies": { + "@graphql-tools/utils": "^10.0.0", + "change-case-all": "1.0.15", + "common-tags": "1.8.2", + "import-from": "4.0.0", + "lodash": "~4.17.0", + "tslib": "~2.5.0" + }, + "peerDependencies": { + "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" + } + }, + "node_modules/@graphql-codegen/schema-ast": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@graphql-codegen/schema-ast/-/schema-ast-4.0.0.tgz", + "integrity": "sha512-WIzkJFa9Gz28FITAPILbt+7A8+yzOyd1NxgwFh7ie+EmO9a5zQK6UQ3U/BviirguXCYnn+AR4dXsoDrSrtRA1g==", + "dev": true, + "dependencies": { + "@graphql-codegen/plugin-helpers": "^5.0.0", + "@graphql-tools/utils": "^10.0.0", + "tslib": "~2.5.0" + }, + "peerDependencies": { + "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" + } + }, + "node_modules/@graphql-codegen/typed-document-node": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@graphql-codegen/typed-document-node/-/typed-document-node-5.0.0.tgz", + "integrity": "sha512-B5zSs9i9IOBX1Y4E2EduP8Q5qnG5SVcoTgTEx2SY3Jm3GKSbxs+ANawXXuf9G9/5plhJD9nHc53WuNLJ1xyIcg==", + "dev": true, + "dependencies": { + "@graphql-codegen/plugin-helpers": "^5.0.0", + "@graphql-codegen/visitor-plugin-common": "4.0.0", + "auto-bind": "~4.0.0", + "change-case-all": "1.0.15", + "tslib": "~2.5.0" + }, + "peerDependencies": { + "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" + } + }, + "node_modules/@graphql-codegen/typescript": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@graphql-codegen/typescript/-/typescript-4.0.0.tgz", + "integrity": "sha512-9Wv050+a4O/c3RRDbXKVnm0e45mhmb8XuW3ICsmmwPUVJ5oX8NOLYIMU8ie1/gNTTCfJNwOtZr5EwX2yhXYUfQ==", + "dev": true, + "dependencies": { + "@graphql-codegen/plugin-helpers": "^5.0.0", + "@graphql-codegen/schema-ast": "^4.0.0", + "@graphql-codegen/visitor-plugin-common": "4.0.0", + "auto-bind": "~4.0.0", + "tslib": "~2.5.0" + }, + "peerDependencies": { + "graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" + } + }, + "node_modules/@graphql-codegen/typescript-operations": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@graphql-codegen/typescript-operations/-/typescript-operations-4.0.0.tgz", + "integrity": "sha512-4juN+rCeyXx97zHg5FF2s6u9lfgVHY2ee+5S+P3X+nr2X0m93yFKJhbbEYKYMdE0d/nPPl5mxUiUGb/vzrDCig==", + "dev": true, + "dependencies": { + "@graphql-codegen/plugin-helpers": "^5.0.0", + "@graphql-codegen/typescript": "^4.0.0", + "@graphql-codegen/visitor-plugin-common": "4.0.0", + "auto-bind": "~4.0.0", + "tslib": "~2.5.0" + }, + "peerDependencies": { + "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" + } + }, + "node_modules/@graphql-codegen/visitor-plugin-common": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@graphql-codegen/visitor-plugin-common/-/visitor-plugin-common-4.0.0.tgz", + "integrity": "sha512-OFWr5tkrG4nCcE7AI9BSAwuA0VLP16uNCLssbmXpBa1rKR6b4mX+rJTQCoz47TFV5hii8yp8xaWfXVUcsNY39w==", + "dev": true, + "dependencies": { + "@graphql-codegen/plugin-helpers": "^5.0.0", + "@graphql-tools/optimize": "^2.0.0", + "@graphql-tools/relay-operation-optimizer": "^7.0.0", + "@graphql-tools/utils": "^10.0.0", + "auto-bind": "~4.0.0", + "change-case-all": "1.0.15", + "dependency-graph": "^0.11.0", + "graphql-tag": "^2.11.0", + "parse-filepath": "^1.0.2", + "tslib": "~2.5.0" + }, + "peerDependencies": { + "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" + } + }, + "node_modules/@graphql-tools/apollo-engine-loader": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@graphql-tools/apollo-engine-loader/-/apollo-engine-loader-8.0.0.tgz", + "integrity": "sha512-axQTbN5+Yxs1rJ6cWQBOfw3AEeC+fvIuZSfJLPLLvFJLj4pUm9fhxey/g6oQZAAQJqKPfw+tLDUQvnfvRK8Kmg==", + "dev": true, + "dependencies": { + "@ardatan/sync-fetch": "^0.0.1", + "@graphql-tools/utils": "^10.0.0", + "@whatwg-node/fetch": "^0.9.0", + "tslib": "^2.4.0" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-tools/apollo-engine-loader/node_modules/@whatwg-node/events": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@whatwg-node/events/-/events-0.1.1.tgz", + "integrity": "sha512-AyQEn5hIPV7Ze+xFoXVU3QTHXVbWPrzaOkxtENMPMuNL6VVHrp4hHfDt9nrQpjO7BgvuM95dMtkycX5M/DZR3w==", + "dev": true, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@graphql-tools/apollo-engine-loader/node_modules/@whatwg-node/fetch": { + "version": "0.9.6", + "resolved": "https://registry.npmjs.org/@whatwg-node/fetch/-/fetch-0.9.6.tgz", + "integrity": "sha512-IyaAIkK5cIOvHUdh5iu6ONCRQyRF8n6Hc2pqzYleGk9KPuRAdS0eqNZm1RJJL652pSCflDaxrxV0XQzlqavkEg==", + "dev": true, + "dependencies": { + "@whatwg-node/node-fetch": "^0.4.5", + "urlpattern-polyfill": "^9.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@graphql-tools/apollo-engine-loader/node_modules/@whatwg-node/node-fetch": { + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/@whatwg-node/node-fetch/-/node-fetch-0.4.5.tgz", + "integrity": "sha512-J/PJWSa2irO365+Lh9KjATwRVLBG2MFCewS3JVCTIlPjtKFQrkhmL3o9EDp/7vEMyTWIqI0kMvZAudmKei8o0Q==", + "dev": true, + "dependencies": { + "@whatwg-node/events": "^0.1.0", + "busboy": "^1.6.0", + "fast-querystring": "^1.1.1", + "fast-url-parser": "^1.1.3", + "tslib": "^2.3.1" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@graphql-tools/apollo-engine-loader/node_modules/urlpattern-polyfill": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/urlpattern-polyfill/-/urlpattern-polyfill-9.0.0.tgz", + "integrity": "sha512-WHN8KDQblxd32odxeIgo83rdVDE2bvdkb86it7bMhYZwWKJz0+O0RK/eZiHYnM+zgt/U7hAHOlCQGfjjvSkw2g==", + "dev": true + }, + "node_modules/@graphql-tools/batch-execute": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/@graphql-tools/batch-execute/-/batch-execute-9.0.0.tgz", + "integrity": "sha512-lT9/1XmPSYzBcEybXPLsuA6C5E0t8438PVUELABcqdvwHgZ3VOOx29MLBEqhr2oewOlDChH6PXNkfxoOoAuzRg==", + "dev": true, + "dependencies": { + "@graphql-tools/utils": "^10.0.0", + "dataloader": "^2.2.2", + "tslib": "^2.4.0", + "value-or-promise": "^1.0.12" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-tools/code-file-loader": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/@graphql-tools/code-file-loader/-/code-file-loader-8.0.1.tgz", + "integrity": "sha512-pmg81lsIXGW3uW+nFSCIG0lFQIxWVbgDjeBkSWlnP8CZsrHTQEkB53DT7t4BHLryoxDS4G4cPxM52yNINDSL8w==", + "dev": true, + "dependencies": { + "@graphql-tools/graphql-tag-pluck": "8.0.1", + "@graphql-tools/utils": "^10.0.0", + "globby": "^11.0.3", + "tslib": "^2.4.0", + "unixify": "^1.0.0" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-tools/delegate": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@graphql-tools/delegate/-/delegate-10.0.0.tgz", + "integrity": "sha512-ZW5/7Q0JqUM+guwn8/cM/1Hz16Zvj6WR6r3gnOwoPO7a9bCbe8QTCk4itT/EO+RiGT8RLUPYaunWR9jxfNqqOA==", + "dev": true, + "dependencies": { + "@graphql-tools/batch-execute": "^9.0.0", + "@graphql-tools/executor": "^1.0.0", + "@graphql-tools/schema": "^10.0.0", + "@graphql-tools/utils": "^10.0.0", + "dataloader": "^2.2.2", + "tslib": "^2.5.0", + "value-or-promise": "^1.0.12" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-tools/documents": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@graphql-tools/documents/-/documents-1.0.0.tgz", + "integrity": "sha512-rHGjX1vg/nZ2DKqRGfDPNC55CWZBMldEVcH+91BThRa6JeT80NqXknffLLEZLRUxyikCfkwMsk6xR3UNMqG0Rg==", + "dev": true, + "dependencies": { + "lodash.sortby": "^4.7.0", + "tslib": "^2.4.0" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-tools/executor": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@graphql-tools/executor/-/executor-1.1.0.tgz", + "integrity": "sha512-+1wmnaUHETSYxiK/ELsT60x584Rw3QKBB7F/7fJ83HKPnLifmE2Dm/K9Eyt6L0Ppekf1jNUbWBpmBGb8P5hAeg==", + "dev": true, + "dependencies": { + "@graphql-tools/utils": "^10.0.0", + "@graphql-typed-document-node/core": "3.2.0", + "@repeaterjs/repeater": "^3.0.4", + "tslib": "^2.4.0", + "value-or-promise": "^1.0.12" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-tools/executor-graphql-ws": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@graphql-tools/executor-graphql-ws/-/executor-graphql-ws-1.0.0.tgz", + "integrity": "sha512-voczXmNcEzZKk6dS4pCwN0XCXvDiAVm9rj+54oz7X04IsHBJmTUul1YhCbJie1xUvN1jmgEJ14lfD92tMMMTmQ==", + "dev": true, + "dependencies": { + "@graphql-tools/utils": "^10.0.0", + "@repeaterjs/repeater": "3.0.4", + "@types/ws": "^8.0.0", + "graphql-ws": "5.13.1", + "isomorphic-ws": "5.0.0", + "tslib": "^2.4.0", + "ws": "8.13.0" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-tools/executor-http": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@graphql-tools/executor-http/-/executor-http-1.0.0.tgz", + "integrity": "sha512-7R9IWRN1Iszyayd4qgguITLLTmRUZ3wSS5umK0xwShB8mFQ5cSsVx6rewPhGIwGEenN6e9ahwcGX9ytuLlw55g==", + "dev": true, + "dependencies": { + "@graphql-tools/utils": "^10.0.0", + "@repeaterjs/repeater": "^3.0.4", + "@whatwg-node/fetch": "^0.9.0", + "dset": "^3.1.2", + "extract-files": "^11.0.0", + "meros": "^1.2.1", + "tslib": "^2.4.0", + "value-or-promise": "^1.0.12" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-tools/executor-http/node_modules/@whatwg-node/events": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@whatwg-node/events/-/events-0.1.1.tgz", + "integrity": "sha512-AyQEn5hIPV7Ze+xFoXVU3QTHXVbWPrzaOkxtENMPMuNL6VVHrp4hHfDt9nrQpjO7BgvuM95dMtkycX5M/DZR3w==", + "dev": true, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@graphql-tools/executor-http/node_modules/@whatwg-node/fetch": { + "version": "0.9.6", + "resolved": "https://registry.npmjs.org/@whatwg-node/fetch/-/fetch-0.9.6.tgz", + "integrity": "sha512-IyaAIkK5cIOvHUdh5iu6ONCRQyRF8n6Hc2pqzYleGk9KPuRAdS0eqNZm1RJJL652pSCflDaxrxV0XQzlqavkEg==", + "dev": true, + "dependencies": { + "@whatwg-node/node-fetch": "^0.4.5", + "urlpattern-polyfill": "^9.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@graphql-tools/executor-http/node_modules/@whatwg-node/node-fetch": { + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/@whatwg-node/node-fetch/-/node-fetch-0.4.5.tgz", + "integrity": "sha512-J/PJWSa2irO365+Lh9KjATwRVLBG2MFCewS3JVCTIlPjtKFQrkhmL3o9EDp/7vEMyTWIqI0kMvZAudmKei8o0Q==", + "dev": true, + "dependencies": { + "@whatwg-node/events": "^0.1.0", + "busboy": "^1.6.0", + "fast-querystring": "^1.1.1", + "fast-url-parser": "^1.1.3", + "tslib": "^2.3.1" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@graphql-tools/executor-http/node_modules/urlpattern-polyfill": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/urlpattern-polyfill/-/urlpattern-polyfill-9.0.0.tgz", + "integrity": "sha512-WHN8KDQblxd32odxeIgo83rdVDE2bvdkb86it7bMhYZwWKJz0+O0RK/eZiHYnM+zgt/U7hAHOlCQGfjjvSkw2g==", + "dev": true + }, + "node_modules/@graphql-tools/executor-legacy-ws": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@graphql-tools/executor-legacy-ws/-/executor-legacy-ws-1.0.1.tgz", + "integrity": "sha512-PQrTJ+ncHMEQspBARc2lhwiQFfRAX/z/CsOdZTFjIljOHgRWGAA1DAx7pEN0j6PflbLCfZ3NensNq2jCBwF46w==", + "dev": true, + "dependencies": { + "@graphql-tools/utils": "^10.0.0", + "@types/ws": "^8.0.0", + "isomorphic-ws": "5.0.0", + "tslib": "^2.4.0", + "ws": "8.13.0" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-tools/git-loader": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/@graphql-tools/git-loader/-/git-loader-8.0.1.tgz", + "integrity": "sha512-ivNtxD+iEfpPONYKip0kbpZMRdMCNR3HrIui8NCURmUdvBYGaGcbB3VrGMhxwZuzc+ybhs2ralPt1F8Oxq2jLA==", + "dev": true, + "dependencies": { + "@graphql-tools/graphql-tag-pluck": "8.0.1", + "@graphql-tools/utils": "^10.0.0", + "is-glob": "4.0.3", + "micromatch": "^4.0.4", + "tslib": "^2.4.0", + "unixify": "^1.0.0" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-tools/github-loader": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@graphql-tools/github-loader/-/github-loader-8.0.0.tgz", + "integrity": "sha512-VuroArWKcG4yaOWzV0r19ElVIV6iH6UKDQn1MXemND0xu5TzrFme0kf3U9o0YwNo0kUYEk9CyFM0BYg4he17FA==", + "dev": true, + "dependencies": { + "@ardatan/sync-fetch": "^0.0.1", + "@graphql-tools/executor-http": "^1.0.0", + "@graphql-tools/graphql-tag-pluck": "^8.0.0", + "@graphql-tools/utils": "^10.0.0", + "@whatwg-node/fetch": "^0.9.0", + "tslib": "^2.4.0", + "value-or-promise": "^1.0.12" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-tools/github-loader/node_modules/@whatwg-node/events": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@whatwg-node/events/-/events-0.1.1.tgz", + "integrity": "sha512-AyQEn5hIPV7Ze+xFoXVU3QTHXVbWPrzaOkxtENMPMuNL6VVHrp4hHfDt9nrQpjO7BgvuM95dMtkycX5M/DZR3w==", + "dev": true, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@graphql-tools/github-loader/node_modules/@whatwg-node/fetch": { + "version": "0.9.6", + "resolved": "https://registry.npmjs.org/@whatwg-node/fetch/-/fetch-0.9.6.tgz", + "integrity": "sha512-IyaAIkK5cIOvHUdh5iu6ONCRQyRF8n6Hc2pqzYleGk9KPuRAdS0eqNZm1RJJL652pSCflDaxrxV0XQzlqavkEg==", + "dev": true, + "dependencies": { + "@whatwg-node/node-fetch": "^0.4.5", + "urlpattern-polyfill": "^9.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@graphql-tools/github-loader/node_modules/@whatwg-node/node-fetch": { + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/@whatwg-node/node-fetch/-/node-fetch-0.4.5.tgz", + "integrity": "sha512-J/PJWSa2irO365+Lh9KjATwRVLBG2MFCewS3JVCTIlPjtKFQrkhmL3o9EDp/7vEMyTWIqI0kMvZAudmKei8o0Q==", + "dev": true, + "dependencies": { + "@whatwg-node/events": "^0.1.0", + "busboy": "^1.6.0", + "fast-querystring": "^1.1.1", + "fast-url-parser": "^1.1.3", + "tslib": "^2.3.1" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@graphql-tools/github-loader/node_modules/urlpattern-polyfill": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/urlpattern-polyfill/-/urlpattern-polyfill-9.0.0.tgz", + "integrity": "sha512-WHN8KDQblxd32odxeIgo83rdVDE2bvdkb86it7bMhYZwWKJz0+O0RK/eZiHYnM+zgt/U7hAHOlCQGfjjvSkw2g==", + "dev": true + }, + "node_modules/@graphql-tools/graphql-file-loader": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@graphql-tools/graphql-file-loader/-/graphql-file-loader-8.0.0.tgz", + "integrity": "sha512-wRXj9Z1IFL3+zJG1HWEY0S4TXal7+s1vVhbZva96MSp0kbb/3JBF7j0cnJ44Eq0ClccMgGCDFqPFXty4JlpaPg==", + "dev": true, + "dependencies": { + "@graphql-tools/import": "7.0.0", + "@graphql-tools/utils": "^10.0.0", + "globby": "^11.0.3", + "tslib": "^2.4.0", + "unixify": "^1.0.0" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-tools/graphql-tag-pluck": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/@graphql-tools/graphql-tag-pluck/-/graphql-tag-pluck-8.0.1.tgz", + "integrity": "sha512-4sfBJSoXxVB4rRCCp2GTFhAYsUJgAPSKxSV+E3Voc600mK52JO+KsHCCTnPgCeyJFMNR9l94J6+tqxVKmlqKvw==", + "dev": true, + "dependencies": { + "@babel/parser": "^7.16.8", + "@babel/plugin-syntax-import-assertions": "^7.20.0", + "@babel/traverse": "^7.16.8", + "@babel/types": "^7.16.8", + "@graphql-tools/utils": "^10.0.0", + "tslib": "^2.4.0" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-tools/import": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@graphql-tools/import/-/import-7.0.0.tgz", + "integrity": "sha512-NVZiTO8o1GZs6OXzNfjB+5CtQtqsZZpQOq+Uu0w57kdUkT4RlQKlwhT8T81arEsbV55KpzkpFsOZP7J1wdmhBw==", + "dev": true, + "dependencies": { + "@graphql-tools/utils": "^10.0.0", + "resolve-from": "5.0.0", + "tslib": "^2.4.0" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-tools/json-file-loader": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@graphql-tools/json-file-loader/-/json-file-loader-8.0.0.tgz", + "integrity": "sha512-ki6EF/mobBWJjAAC84xNrFMhNfnUFD6Y0rQMGXekrUgY0NdeYXHU0ZUgHzC9O5+55FslqUmAUHABePDHTyZsLg==", + "dev": true, + "dependencies": { + "@graphql-tools/utils": "^10.0.0", + "globby": "^11.0.3", + "tslib": "^2.4.0", + "unixify": "^1.0.0" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-tools/load": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@graphql-tools/load/-/load-8.0.0.tgz", + "integrity": "sha512-Cy874bQJH0FP2Az7ELPM49iDzOljQmK1PPH6IuxsWzLSTxwTqd8dXA09dcVZrI7/LsN26heTY2R8q2aiiv0GxQ==", + "dev": true, + "dependencies": { + "@graphql-tools/schema": "^10.0.0", + "@graphql-tools/utils": "^10.0.0", + "p-limit": "3.1.0", + "tslib": "^2.4.0" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-tools/merge": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/@graphql-tools/merge/-/merge-9.0.0.tgz", + "integrity": "sha512-J7/xqjkGTTwOJmaJQJ2C+VDBDOWJL3lKrHJN4yMaRLAJH3PosB7GiPRaSDZdErs0+F77sH2MKs2haMMkywzx7Q==", + "dev": true, + "dependencies": { + "@graphql-tools/utils": "^10.0.0", + "tslib": "^2.4.0" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-tools/optimize": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@graphql-tools/optimize/-/optimize-2.0.0.tgz", + "integrity": "sha512-nhdT+CRGDZ+bk68ic+Jw1OZ99YCDIKYA5AlVAnBHJvMawSx9YQqQAIj4refNc1/LRieGiuWvhbG3jvPVYho0Dg==", + "dev": true, + "dependencies": { + "tslib": "^2.4.0" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-tools/prisma-loader": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/@graphql-tools/prisma-loader/-/prisma-loader-8.0.1.tgz", + "integrity": "sha512-bl6e5sAYe35Z6fEbgKXNrqRhXlCJYeWKBkarohgYA338/SD9eEhXtg3Cedj7fut3WyRLoQFpHzfiwxKs7XrgXg==", + "dev": true, + "dependencies": { + "@graphql-tools/url-loader": "^8.0.0", + "@graphql-tools/utils": "^10.0.0", + "@types/js-yaml": "^4.0.0", + "@types/json-stable-stringify": "^1.0.32", + "@whatwg-node/fetch": "^0.9.0", + "chalk": "^4.1.0", + "debug": "^4.3.1", + "dotenv": "^16.0.0", + "graphql-request": "^6.0.0", + "http-proxy-agent": "^7.0.0", + "https-proxy-agent": "^7.0.0", + "jose": "^4.11.4", + "js-yaml": "^4.0.0", + "json-stable-stringify": "^1.0.1", + "lodash": "^4.17.20", + "scuid": "^1.1.0", + "tslib": "^2.4.0", + "yaml-ast-parser": "^0.0.43" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-tools/prisma-loader/node_modules/@whatwg-node/events": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@whatwg-node/events/-/events-0.1.1.tgz", + "integrity": "sha512-AyQEn5hIPV7Ze+xFoXVU3QTHXVbWPrzaOkxtENMPMuNL6VVHrp4hHfDt9nrQpjO7BgvuM95dMtkycX5M/DZR3w==", + "dev": true, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@graphql-tools/prisma-loader/node_modules/@whatwg-node/fetch": { + "version": "0.9.6", + "resolved": "https://registry.npmjs.org/@whatwg-node/fetch/-/fetch-0.9.6.tgz", + "integrity": "sha512-IyaAIkK5cIOvHUdh5iu6ONCRQyRF8n6Hc2pqzYleGk9KPuRAdS0eqNZm1RJJL652pSCflDaxrxV0XQzlqavkEg==", + "dev": true, + "dependencies": { + "@whatwg-node/node-fetch": "^0.4.5", + "urlpattern-polyfill": "^9.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@graphql-tools/prisma-loader/node_modules/@whatwg-node/node-fetch": { + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/@whatwg-node/node-fetch/-/node-fetch-0.4.5.tgz", + "integrity": "sha512-J/PJWSa2irO365+Lh9KjATwRVLBG2MFCewS3JVCTIlPjtKFQrkhmL3o9EDp/7vEMyTWIqI0kMvZAudmKei8o0Q==", + "dev": true, + "dependencies": { + "@whatwg-node/events": "^0.1.0", + "busboy": "^1.6.0", + "fast-querystring": "^1.1.1", + "fast-url-parser": "^1.1.3", + "tslib": "^2.3.1" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@graphql-tools/prisma-loader/node_modules/urlpattern-polyfill": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/urlpattern-polyfill/-/urlpattern-polyfill-9.0.0.tgz", + "integrity": "sha512-WHN8KDQblxd32odxeIgo83rdVDE2bvdkb86it7bMhYZwWKJz0+O0RK/eZiHYnM+zgt/U7hAHOlCQGfjjvSkw2g==", + "dev": true + }, + "node_modules/@graphql-tools/relay-operation-optimizer": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@graphql-tools/relay-operation-optimizer/-/relay-operation-optimizer-7.0.0.tgz", + "integrity": "sha512-UNlJi5y3JylhVWU4MBpL0Hun4Q7IoJwv9xYtmAz+CgRa066szzY7dcuPfxrA7cIGgG/Q6TVsKsYaiF4OHPs1Fw==", + "dev": true, + "dependencies": { + "@ardatan/relay-compiler": "12.0.0", + "@graphql-tools/utils": "^10.0.0", + "tslib": "^2.4.0" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-tools/schema": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@graphql-tools/schema/-/schema-10.0.0.tgz", + "integrity": "sha512-kf3qOXMFcMs2f/S8Y3A8fm/2w+GaHAkfr3Gnhh2LOug/JgpY/ywgFVxO3jOeSpSEdoYcDKLcXVjMigNbY4AdQg==", + "dev": true, + "dependencies": { + "@graphql-tools/merge": "^9.0.0", + "@graphql-tools/utils": "^10.0.0", + "tslib": "^2.4.0", + "value-or-promise": "^1.0.12" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-tools/url-loader": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@graphql-tools/url-loader/-/url-loader-8.0.0.tgz", + "integrity": "sha512-rPc9oDzMnycvz+X+wrN3PLrhMBQkG4+sd8EzaFN6dypcssiefgWKToXtRKI8HHK68n2xEq1PyrOpkjHFJB+GwA==", + "dev": true, + "dependencies": { + "@ardatan/sync-fetch": "^0.0.1", + "@graphql-tools/delegate": "^10.0.0", + "@graphql-tools/executor-graphql-ws": "^1.0.0", + "@graphql-tools/executor-http": "^1.0.0", + "@graphql-tools/executor-legacy-ws": "^1.0.0", + "@graphql-tools/utils": "^10.0.0", + "@graphql-tools/wrap": "^10.0.0", + "@types/ws": "^8.0.0", + "@whatwg-node/fetch": "^0.9.0", + "isomorphic-ws": "^5.0.0", + "tslib": "^2.4.0", + "value-or-promise": "^1.0.11", + "ws": "^8.12.0" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-tools/url-loader/node_modules/@whatwg-node/events": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@whatwg-node/events/-/events-0.1.1.tgz", + "integrity": "sha512-AyQEn5hIPV7Ze+xFoXVU3QTHXVbWPrzaOkxtENMPMuNL6VVHrp4hHfDt9nrQpjO7BgvuM95dMtkycX5M/DZR3w==", + "dev": true, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@graphql-tools/url-loader/node_modules/@whatwg-node/fetch": { + "version": "0.9.6", + "resolved": "https://registry.npmjs.org/@whatwg-node/fetch/-/fetch-0.9.6.tgz", + "integrity": "sha512-IyaAIkK5cIOvHUdh5iu6ONCRQyRF8n6Hc2pqzYleGk9KPuRAdS0eqNZm1RJJL652pSCflDaxrxV0XQzlqavkEg==", + "dev": true, + "dependencies": { + "@whatwg-node/node-fetch": "^0.4.5", + "urlpattern-polyfill": "^9.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@graphql-tools/url-loader/node_modules/@whatwg-node/node-fetch": { + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/@whatwg-node/node-fetch/-/node-fetch-0.4.5.tgz", + "integrity": "sha512-J/PJWSa2irO365+Lh9KjATwRVLBG2MFCewS3JVCTIlPjtKFQrkhmL3o9EDp/7vEMyTWIqI0kMvZAudmKei8o0Q==", + "dev": true, + "dependencies": { + "@whatwg-node/events": "^0.1.0", + "busboy": "^1.6.0", + "fast-querystring": "^1.1.1", + "fast-url-parser": "^1.1.3", + "tslib": "^2.3.1" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@graphql-tools/url-loader/node_modules/urlpattern-polyfill": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/urlpattern-polyfill/-/urlpattern-polyfill-9.0.0.tgz", + "integrity": "sha512-WHN8KDQblxd32odxeIgo83rdVDE2bvdkb86it7bMhYZwWKJz0+O0RK/eZiHYnM+zgt/U7hAHOlCQGfjjvSkw2g==", + "dev": true + }, + "node_modules/@graphql-tools/utils": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-10.0.1.tgz", + "integrity": "sha512-i1FozbDGHgdsFA47V/JvQZ0FE8NAy0Eiz7HGCJO2MkNdZAKNnwei66gOq0JWYVFztwpwbVQ09GkKhq7Kjcq5Cw==", + "dev": true, + "dependencies": { + "@graphql-typed-document-node/core": "^3.1.1", + "tslib": "^2.4.0" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-tools/wrap": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@graphql-tools/wrap/-/wrap-10.0.0.tgz", + "integrity": "sha512-HDOeUUh6UhpiH0WPJUQl44ODt1x5pnMUbOJZ7GjTdGQ7LK0AgVt3ftaAQ9duxLkiAtYJmu5YkULirfZGj4HzDg==", + "dev": true, + "dependencies": { + "@graphql-tools/delegate": "^10.0.0", + "@graphql-tools/schema": "^10.0.0", + "@graphql-tools/utils": "^10.0.0", + "tslib": "^2.4.0", + "value-or-promise": "^1.0.12" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@graphql-typed-document-node/core": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@graphql-typed-document-node/core/-/core-3.2.0.tgz", + "integrity": "sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ==", + "dev": true, + "peerDependencies": { + "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", + "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", + "dev": true, + "dependencies": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.18", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz", + "integrity": "sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "3.1.0", + "@jridgewell/sourcemap-codec": "1.4.14" + } + }, + "node_modules/@jridgewell/trace-mapping/node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "dev": true + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@parcel/watcher": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.1.0.tgz", + "integrity": "sha512-8s8yYjd19pDSsBpbkOHnT6Z2+UJSuLQx61pCFM0s5wSRvKCEMDjd/cHY3/GI1szHIWbpXpsJdg3V6ISGGx9xDw==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "is-glob": "^4.0.3", + "micromatch": "^4.0.5", + "node-addon-api": "^3.2.1", + "node-gyp-build": "^4.3.0" + }, + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@peculiar/asn1-schema": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/@peculiar/asn1-schema/-/asn1-schema-2.3.6.tgz", + "integrity": "sha512-izNRxPoaeJeg/AyH8hER6s+H7p4itk+03QCa4sbxI3lNdseQYCuxzgsuNK8bTXChtLTjpJz6NmXKA73qLa3rCA==", + "dev": true, + "dependencies": { + "asn1js": "^3.0.5", + "pvtsutils": "^1.3.2", + "tslib": "^2.4.0" + } + }, + "node_modules/@peculiar/json-schema": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/@peculiar/json-schema/-/json-schema-1.1.12.tgz", + "integrity": "sha512-coUfuoMeIB7B8/NMekxaDzLhaYmp0HZNPEjYRm9goRou8UZIC3z21s0sL9AWoCw4EG876QyO3kYrc61WNF9B/w==", + "dev": true, + "dependencies": { + "tslib": "^2.0.0" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/@peculiar/webcrypto": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/@peculiar/webcrypto/-/webcrypto-1.4.3.tgz", + "integrity": "sha512-VtaY4spKTdN5LjJ04im/d/joXuvLbQdgy5Z4DXF4MFZhQ+MTrejbNMkfZBp1Bs3O5+bFqnJgyGdPuZQflvIa5A==", + "dev": true, + "dependencies": { + "@peculiar/asn1-schema": "^2.3.6", + "@peculiar/json-schema": "^1.1.12", + "pvtsutils": "^1.3.2", + "tslib": "^2.5.0", + "webcrypto-core": "^1.7.7" + }, + "engines": { + "node": ">=10.12.0" + } + }, + "node_modules/@repeaterjs/repeater": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@repeaterjs/repeater/-/repeater-3.0.4.tgz", + "integrity": "sha512-AW8PKd6iX3vAZ0vA43nOUOnbq/X5ihgU+mSXXqunMkeQADGiqw/PY0JNeYtD5sr0PAy51YPgAPbDoeapv9r8WA==", + "dev": true + }, + "node_modules/@types/chai": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.5.tgz", + "integrity": "sha512-mEo1sAde+UCE6b2hxn332f1g1E8WfYRu6p5SvTKr2ZKC1f7gFJXk4h5PyGP9Dt6gCaG8y8XhwnXWC6Iy2cmBng==", + "dev": true + }, + "node_modules/@types/chai-subset": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@types/chai-subset/-/chai-subset-1.3.3.tgz", + "integrity": "sha512-frBecisrNGz+F4T6bcc+NLeolfiojh5FxW2klu669+8BARtyQv2C/GkNW6FUodVe4BroGMP/wER/YDGc7rEllw==", + "dev": true, + "dependencies": { + "@types/chai": "*" + } + }, + "node_modules/@types/js-yaml": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.5.tgz", + "integrity": "sha512-FhpRzf927MNQdRZP0J5DLIdTXhjLYzeUTmLAu69mnVksLH9CJY3IuSeEgbKUki7GQZm0WqDkGzyxju2EZGD2wA==", + "dev": true + }, + "node_modules/@types/json-stable-stringify": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/@types/json-stable-stringify/-/json-stable-stringify-1.0.34.tgz", + "integrity": "sha512-s2cfwagOQAS8o06TcwKfr9Wx11dNGbH2E9vJz1cqV+a/LOyhWNLUNd6JSRYNzvB4d29UuJX2M0Dj9vE1T8fRXw==", + "dev": true + }, + "node_modules/@types/node": { + "version": "20.3.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.3.1.tgz", + "integrity": "sha512-EhcH/wvidPy1WeML3TtYFGR83UzjxeWRen9V402T8aUGYsCHOmfoisV3ZSg03gAFIbLq8TnWOJ0f4cALtnSEUg==", + "dev": true + }, + "node_modules/@types/ws": { + "version": "8.5.5", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.5.tgz", + "integrity": "sha512-lwhs8hktwxSjf9UaZ9tG5M03PGogvFaH8gUgLNbN9HKIg0dvv6q+gkSuJ8HN4/VbyxkuLzCjlN7GquQ0gUJfIg==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@urql/core": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/@urql/core/-/core-4.0.10.tgz", + "integrity": "sha512-Vs3nOSAnYftqOCg034Ostp/uSqWlQg5ryLIzcOrm8+O43s4M+Ew4GQAuemIH7ZDB8dek6h61zzWI3ujd8FH3NA==", + "dev": true, + "dependencies": { + "@0no-co/graphql.web": "^1.0.1", + "wonka": "^6.3.2" + } + }, + "node_modules/@vitest/expect": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-0.32.0.tgz", + "integrity": "sha512-VxVHhIxKw9Lux+O9bwLEEk2gzOUe93xuFHy9SzYWnnoYZFYg1NfBtnfnYWiJN7yooJ7KNElCK5YtA7DTZvtXtg==", + "dev": true, + "dependencies": { + "@vitest/spy": "0.32.0", + "@vitest/utils": "0.32.0", + "chai": "^4.3.7" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-0.32.0.tgz", + "integrity": "sha512-QpCmRxftHkr72xt5A08xTEs9I4iWEXIOCHWhQQguWOKE4QH7DXSKZSOFibuwEIMAD7G0ERvtUyQn7iPWIqSwmw==", + "dev": true, + "dependencies": { + "@vitest/utils": "0.32.0", + "concordance": "^5.0.4", + "p-limit": "^4.0.0", + "pathe": "^1.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner/node_modules/p-limit": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz", + "integrity": "sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^1.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@vitest/runner/node_modules/yocto-queue": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz", + "integrity": "sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==", + "dev": true, + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@vitest/snapshot": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-0.32.0.tgz", + "integrity": "sha512-yCKorPWjEnzpUxQpGlxulujTcSPgkblwGzAUEL+z01FTUg/YuCDZ8dxr9sHA08oO2EwxzHXNLjQKWJ2zc2a19Q==", + "dev": true, + "dependencies": { + "magic-string": "^0.30.0", + "pathe": "^1.1.0", + "pretty-format": "^27.5.1" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-0.32.0.tgz", + "integrity": "sha512-MruAPlM0uyiq3d53BkwTeShXY0rYEfhNGQzVO5GHBmmX3clsxcWp79mMnkOVcV244sNTeDcHbcPFWIjOI4tZvw==", + "dev": true, + "dependencies": { + "tinyspy": "^2.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-0.32.0.tgz", + "integrity": "sha512-53yXunzx47MmbuvcOPpLaVljHaeSu1G2dHdmy7+9ngMnQIkBQcvwOcoclWFnxDMxFbnq8exAfh3aKSZaK71J5A==", + "dev": true, + "dependencies": { + "concordance": "^5.0.4", + "loupe": "^2.3.6", + "pretty-format": "^27.5.1" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@whatwg-node/events": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/@whatwg-node/events/-/events-0.0.3.tgz", + "integrity": "sha512-IqnKIDWfXBJkvy/k6tzskWTc2NK3LcqHlb+KHGCrjOCH4jfQckRX0NAiIcC/vIqQkzLYw2r2CTSwAxcrtcD6lA==", + "dev": true + }, + "node_modules/@whatwg-node/fetch": { + "version": "0.8.8", + "resolved": "https://registry.npmjs.org/@whatwg-node/fetch/-/fetch-0.8.8.tgz", + "integrity": "sha512-CdcjGC2vdKhc13KKxgsc6/616BQ7ooDIgPeTuAiE8qfCnS0mGzcfCOoZXypQSz73nxI+GWc7ZReIAVhxoE1KCg==", + "dev": true, + "dependencies": { + "@peculiar/webcrypto": "^1.4.0", + "@whatwg-node/node-fetch": "^0.3.6", + "busboy": "^1.6.0", + "urlpattern-polyfill": "^8.0.0", + "web-streams-polyfill": "^3.2.1" + } + }, + "node_modules/@whatwg-node/node-fetch": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/@whatwg-node/node-fetch/-/node-fetch-0.3.6.tgz", + "integrity": "sha512-w9wKgDO4C95qnXZRwZTfCmLWqyRnooGjcIwG0wADWjw9/HN0p7dtvtgSvItZtUyNteEvgTrd8QojNEqV6DAGTA==", + "dev": true, + "dependencies": { + "@whatwg-node/events": "^0.0.3", + "busboy": "^1.6.0", + "fast-querystring": "^1.1.1", + "fast-url-parser": "^1.1.3", + "tslib": "^2.3.1" + } + }, + "node_modules/@wry/context": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/@wry/context/-/context-0.7.3.tgz", + "integrity": "sha512-Nl8WTesHp89RF803Se9X3IiHjdmLBrIvPMaJkl+rKVJAYyPsz1TEUbu89943HpvujtSJgDUx9W4vZw3K1Mr3sA==", + "dev": true, + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@wry/equality": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@wry/equality/-/equality-0.5.6.tgz", + "integrity": "sha512-D46sfMTngaYlrH+OspKf8mIJETntFnf6Hsjb0V41jAXJ7Bx2kB8Rv8RCUujuVWYttFtHkUNp7g+FwxNQAr6mXA==", + "dev": true, + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@wry/trie": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@wry/trie/-/trie-0.4.3.tgz", + "integrity": "sha512-I6bHwH0fSf6RqQcnnXLJKhkSXG45MFral3GxPaY4uAl0LYDZM+YDVDAiU9bYwjTuysy1S0IeecWtmq1SZA3M1w==", + "dev": true, + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/acorn": { + "version": "8.8.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", + "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-walk": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/agent-base": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz", + "integrity": "sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==", + "dev": true, + "dependencies": { + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/aggregate-error": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", + "integrity": "sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==", + "dev": true, + "dependencies": { + "clean-stack": "^2.0.0", + "indent-string": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-escapes": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", + "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", + "dev": true, + "dependencies": { + "type-fest": "^0.21.3" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, + "node_modules/array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==", + "dev": true + }, + "node_modules/asn1js": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/asn1js/-/asn1js-3.0.5.tgz", + "integrity": "sha512-FVnvrKJwpt9LP2lAMl8qZswRNm3T4q9CON+bxldk2iwk3FFpuwhx2FfinyitizWHsVYyaY+y5JzDR0rCMV5yTQ==", + "dev": true, + "dependencies": { + "pvtsutils": "^1.3.2", + "pvutils": "^1.1.3", + "tslib": "^2.4.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/astral-regex": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", + "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/auto-bind": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/auto-bind/-/auto-bind-4.0.0.tgz", + "integrity": "sha512-Hdw8qdNiqdJ8LqT0iK0sVzkFbzg6fhnQqqfWhBDxcHZvU75+B+ayzTy8x+k5Ix0Y92XOhOUlx74ps+bA6BeYMQ==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/babel-plugin-syntax-trailing-function-commas": { + "version": "7.0.0-beta.0", + "resolved": "https://registry.npmjs.org/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-7.0.0-beta.0.tgz", + "integrity": "sha512-Xj9XuRuz3nTSbaTXWv3itLOcxyF4oPD8douBBmj7U9BBC6nEBYfyOJYQMf/8PJAFotC62UY5dFfIGEPr7WswzQ==", + "dev": true + }, + "node_modules/babel-preset-fbjs": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/babel-preset-fbjs/-/babel-preset-fbjs-3.4.0.tgz", + "integrity": "sha512-9ywCsCvo1ojrw0b+XYk7aFvTH6D9064t0RIL1rtMf3nsa02Xw41MS7sZw216Im35xj/UY0PDBQsa1brUDDF1Ow==", + "dev": true, + "dependencies": { + "@babel/plugin-proposal-class-properties": "^7.0.0", + "@babel/plugin-proposal-object-rest-spread": "^7.0.0", + "@babel/plugin-syntax-class-properties": "^7.0.0", + "@babel/plugin-syntax-flow": "^7.0.0", + "@babel/plugin-syntax-jsx": "^7.0.0", + "@babel/plugin-syntax-object-rest-spread": "^7.0.0", + "@babel/plugin-transform-arrow-functions": "^7.0.0", + "@babel/plugin-transform-block-scoped-functions": "^7.0.0", + "@babel/plugin-transform-block-scoping": "^7.0.0", + "@babel/plugin-transform-classes": "^7.0.0", + "@babel/plugin-transform-computed-properties": "^7.0.0", + "@babel/plugin-transform-destructuring": "^7.0.0", + "@babel/plugin-transform-flow-strip-types": "^7.0.0", + "@babel/plugin-transform-for-of": "^7.0.0", + "@babel/plugin-transform-function-name": "^7.0.0", + "@babel/plugin-transform-literals": "^7.0.0", + "@babel/plugin-transform-member-expression-literals": "^7.0.0", + "@babel/plugin-transform-modules-commonjs": "^7.0.0", + "@babel/plugin-transform-object-super": "^7.0.0", + "@babel/plugin-transform-parameters": "^7.0.0", + "@babel/plugin-transform-property-literals": "^7.0.0", + "@babel/plugin-transform-react-display-name": "^7.0.0", + "@babel/plugin-transform-react-jsx": "^7.0.0", + "@babel/plugin-transform-shorthand-properties": "^7.0.0", + "@babel/plugin-transform-spread": "^7.0.0", + "@babel/plugin-transform-template-literals": "^7.0.0", + "babel-plugin-syntax-trailing-function-commas": "^7.0.0-beta.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g==", + "dev": true, + "dependencies": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" + } + }, + "node_modules/babel-runtime/node_modules/regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", + "dev": true + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "dev": true, + "dependencies": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "node_modules/blueimp-md5": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.19.0.tgz", + "integrity": "sha512-DRQrD6gJyy8FbiE4s+bDoXS9hiW3Vbx5uCdwvcCf3zLHL+Iv7LtGHLpr+GZV8rHG8tK766FGYBwRbu8pELTt+w==", + "dev": true + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browserslist": { + "version": "4.21.8", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.8.tgz", + "integrity": "sha512-j+7xYe+v+q2Id9qbBeCI8WX5NmZSRe8es1+0xntD/+gaWXznP8tFEkv5IgSaHf5dS1YwVMbX/4W6m937mj+wQw==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "caniuse-lite": "^1.0.30001502", + "electron-to-chromium": "^1.4.428", + "node-releases": "^2.0.12", + "update-browserslist-db": "^1.0.11" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/bser": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", + "integrity": "sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==", + "dev": true, + "dependencies": { + "node-int64": "^0.4.0" + } + }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "node_modules/busboy": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", + "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", + "dev": true, + "dependencies": { + "streamsearch": "^1.1.0" + }, + "engines": { + "node": ">=10.16.0" + } + }, + "node_modules/cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/camel-case": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz", + "integrity": "sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==", + "dev": true, + "dependencies": { + "pascal-case": "^3.1.2", + "tslib": "^2.0.3" + } + }, + "node_modules/camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001503", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001503.tgz", + "integrity": "sha512-Sf9NiF+wZxPfzv8Z3iS0rXM1Do+iOy2Lxvib38glFX+08TCYYYGR5fRJXk4d77C4AYwhUjgYgMsMudbh2TqCKw==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ] + }, + "node_modules/capital-case": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/capital-case/-/capital-case-1.0.4.tgz", + "integrity": "sha512-ds37W8CytHgwnhGGTi88pcPyR15qoNkOpYwmMMfnWqqWgESapLqvDx6huFjQ5vqWSn2Z06173XNA7LtMOeUh1A==", + "dev": true, + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3", + "upper-case-first": "^2.0.2" + } + }, + "node_modules/chai": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.7.tgz", + "integrity": "sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==", + "dev": true, + "dependencies": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^4.1.2", + "get-func-name": "^2.0.0", + "loupe": "^2.3.1", + "pathval": "^1.1.1", + "type-detect": "^4.0.5" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/change-case": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/change-case/-/change-case-4.1.2.tgz", + "integrity": "sha512-bSxY2ws9OtviILG1EiY5K7NNxkqg/JnRnFxLtKQ96JaviiIxi7djMrSd0ECT9AC+lttClmYwKw53BWpOMblo7A==", + "dev": true, + "dependencies": { + "camel-case": "^4.1.2", + "capital-case": "^1.0.4", + "constant-case": "^3.0.4", + "dot-case": "^3.0.4", + "header-case": "^2.0.4", + "no-case": "^3.0.4", + "param-case": "^3.0.4", + "pascal-case": "^3.1.2", + "path-case": "^3.0.4", + "sentence-case": "^3.0.4", + "snake-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/change-case-all": { + "version": "1.0.15", + "resolved": "https://registry.npmjs.org/change-case-all/-/change-case-all-1.0.15.tgz", + "integrity": "sha512-3+GIFhk3sNuvFAJKU46o26OdzudQlPNBCu1ZQi3cMeMHhty1bhDxu2WrEilVNYaGvqUtR1VSigFcJOiS13dRhQ==", + "dev": true, + "dependencies": { + "change-case": "^4.1.2", + "is-lower-case": "^2.0.2", + "is-upper-case": "^2.0.2", + "lower-case": "^2.0.2", + "lower-case-first": "^2.0.2", + "sponge-case": "^1.0.1", + "swap-case": "^2.0.2", + "title-case": "^3.0.3", + "upper-case": "^2.0.2", + "upper-case-first": "^2.0.2" + } + }, + "node_modules/chardet": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", + "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", + "dev": true + }, + "node_modules/check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/clean-stack": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", + "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/cli-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", + "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", + "dev": true, + "dependencies": { + "restore-cursor": "^3.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cli-spinners": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.0.tgz", + "integrity": "sha512-4/aL9X3Wh0yiMQlE+eeRhWP6vclO3QRtw1JHKIT0FFUs5FjpFmESqtMvYZ0+lbzBw900b95mS0hohy+qn2VK/g==", + "dev": true, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/cli-truncate": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-2.1.0.tgz", + "integrity": "sha512-n8fOixwDD6b/ObinzTrp1ZKFzbgvKZvuz/TvejnLn1aQfC6r52XEx85FmuC+3HI+JM7coBRXUvNqEU2PHVrHpg==", + "dev": true, + "dependencies": { + "slice-ansi": "^3.0.0", + "string-width": "^4.2.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/cli-width": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-3.0.0.tgz", + "integrity": "sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==", + "dev": true, + "engines": { + "node": ">= 10" + } + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/clone": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", + "integrity": "sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==", + "dev": true, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/colorette": { + "version": "2.0.20", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz", + "integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==", + "dev": true + }, + "node_modules/common-tags": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.2.tgz", + "integrity": "sha512-gk/Z852D2Wtb//0I+kRFNKKE9dIIVirjoqPoA1wJU+XePVXZfGeBpk45+A1rKO4Q43prqWBNY/MiIeRLbPWUaA==", + "dev": true, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "node_modules/concordance": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/concordance/-/concordance-5.0.4.tgz", + "integrity": "sha512-OAcsnTEYu1ARJqWVGwf4zh4JDfHZEaSNlNccFmt8YjB2l/n19/PF2viLINHc57vO4FKIAFl2FWASIGZZWZ2Kxw==", + "dev": true, + "dependencies": { + "date-time": "^3.1.0", + "esutils": "^2.0.3", + "fast-diff": "^1.2.0", + "js-string-escape": "^1.0.1", + "lodash": "^4.17.15", + "md5-hex": "^3.0.1", + "semver": "^7.3.2", + "well-known-symbols": "^2.0.0" + }, + "engines": { + "node": ">=10.18.0 <11 || >=12.14.0 <13 || >=14" + } + }, + "node_modules/concordance/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/concordance/node_modules/semver": { + "version": "7.5.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.1.tgz", + "integrity": "sha512-Wvss5ivl8TMRZXXESstBA4uR5iXgEN/VC5/sOcuXdVLzcdkz4HWetIoRfG5gb5X+ij/G9rw9YoGn3QoQ8OCSpw==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/concordance/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/constant-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/constant-case/-/constant-case-3.0.4.tgz", + "integrity": "sha512-I2hSBi7Vvs7BEuJDr5dDHfzb/Ruj3FyvFyh7KLilAjNQw3Be+xgqUBA2W6scVEcL0hL1dwPRtIqEPVUCKkSsyQ==", + "dev": true, + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3", + "upper-case": "^2.0.2" + } + }, + "node_modules/convert-source-map": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", + "dev": true + }, + "node_modules/core-js": { + "version": "2.6.12", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", + "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==", + "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.", + "dev": true, + "hasInstallScript": true + }, + "node_modules/cosmiconfig": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.2.0.tgz", + "integrity": "sha512-3rTMnFJA1tCOPwRxtgF4wd7Ab2qvDbL8jX+3smjIbS4HlZBagTlpERbdN7iAbWlrfxE3M8c27kTwTawQ7st+OQ==", + "dev": true, + "dependencies": { + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "parse-json": "^5.0.0", + "path-type": "^4.0.0" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/d-fischer" + } + }, + "node_modules/cross-fetch": { + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.6.tgz", + "integrity": "sha512-riRvo06crlE8HiqOwIpQhxwdOk4fOeR7FVM/wXoxchFEqMNUjvbs3bfo4OTgMEMHzppd4DxFBDbyySj8Cv781g==", + "dev": true, + "dependencies": { + "node-fetch": "^2.6.11" + } + }, + "node_modules/dataloader": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/dataloader/-/dataloader-2.2.2.tgz", + "integrity": "sha512-8YnDaaf7N3k/q5HnTJVuzSyLETjoZjVmHc4AeKAzOvKHEFQKcn64OKBfzHYtE9zGjctNM7V9I0MfnUVLpi7M5g==", + "dev": true + }, + "node_modules/date-time": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/date-time/-/date-time-3.1.0.tgz", + "integrity": "sha512-uqCUKXE5q1PNBXjPqvwhwJf9SwMoAHBgWJ6DcrnS5o+W2JOiIILl0JEdVD8SGujrNS02GGxgwAg2PN2zONgtjg==", + "dev": true, + "dependencies": { + "time-zone": "^1.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/debounce": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/debounce/-/debounce-1.2.1.tgz", + "integrity": "sha512-XRRe6Glud4rd/ZGQfiV1ruXSfbvfJedlV9Y6zOlP+2K04vBYiJEte6stfFkCP03aMnY5tsipamumUjL14fofug==", + "dev": true + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/deep-eql": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", + "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", + "dev": true, + "dependencies": { + "type-detect": "^4.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/defaults": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", + "integrity": "sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==", + "dev": true, + "dependencies": { + "clone": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/dependency-graph": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/dependency-graph/-/dependency-graph-0.11.0.tgz", + "integrity": "sha512-JeMq7fEshyepOWDfcfHK06N3MhyPhz++vtqWhMT5O9A3K42rdsEDpfdVqjaqaAhsw6a+ZqeDvQVtD0hFHQWrzg==", + "dev": true, + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/detect-indent": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-6.1.0.tgz", + "integrity": "sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/dir-glob": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dev": true, + "dependencies": { + "path-type": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/dot-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", + "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", + "dev": true, + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/dotenv": { + "version": "16.1.4", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.1.4.tgz", + "integrity": "sha512-m55RtE8AsPeJBpOIFKihEmqUcoVncQIwo7x9U8ZwLEZw9ZpXboz2c+rvog+jUaJvVrZ5kBOeYQBX5+8Aa/OZQw==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/motdotla/dotenv?sponsor=1" + } + }, + "node_modules/dset": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/dset/-/dset-3.1.2.tgz", + "integrity": "sha512-g/M9sqy3oHe477Ar4voQxWtaPIFw1jTdKZuomOjhCcBx9nHUNn0pu6NopuFFrTh/TRZIKEj+76vLWFu9BNKk+Q==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/electron-to-chromium": { + "version": "1.4.430", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.430.tgz", + "integrity": "sha512-FytjTbGwz///F+ToZ5XSeXbbSaXalsVRXsz2mHityI5gfxft7ieW3HqFLkU5V1aIrY42aflICqbmFoDxW10etg==", + "dev": true + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/encoding": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", + "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==", + "dev": true, + "dependencies": { + "iconv-lite": "^0.6.2" + } + }, + "node_modules/encoding/node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "dependencies": { + "is-arrayish": "^0.2.1" + } + }, + "node_modules/esbuild": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.19.tgz", + "integrity": "sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw==", + "dev": true, + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/android-arm": "0.17.19", + "@esbuild/android-arm64": "0.17.19", + "@esbuild/android-x64": "0.17.19", + "@esbuild/darwin-arm64": "0.17.19", + "@esbuild/darwin-x64": "0.17.19", + "@esbuild/freebsd-arm64": "0.17.19", + "@esbuild/freebsd-x64": "0.17.19", + "@esbuild/linux-arm": "0.17.19", + "@esbuild/linux-arm64": "0.17.19", + "@esbuild/linux-ia32": "0.17.19", + "@esbuild/linux-loong64": "0.17.19", + "@esbuild/linux-mips64el": "0.17.19", + "@esbuild/linux-ppc64": "0.17.19", + "@esbuild/linux-riscv64": "0.17.19", + "@esbuild/linux-s390x": "0.17.19", + "@esbuild/linux-x64": "0.17.19", + "@esbuild/netbsd-x64": "0.17.19", + "@esbuild/openbsd-x64": "0.17.19", + "@esbuild/sunos-x64": "0.17.19", + "@esbuild/win32-arm64": "0.17.19", + "@esbuild/win32-ia32": "0.17.19", + "@esbuild/win32-x64": "0.17.19" + } + }, + "node_modules/escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/external-editor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", + "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", + "dev": true, + "dependencies": { + "chardet": "^0.7.0", + "iconv-lite": "^0.4.24", + "tmp": "^0.0.33" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/extract-files": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/extract-files/-/extract-files-11.0.0.tgz", + "integrity": "sha512-FuoE1qtbJ4bBVvv94CC7s0oTnKUGvQs+Rjf1L2SJFfS+HTVVjhPFtehPdQ0JiGPqVNfSSZvL5yzHHQq2Z4WNhQ==", + "dev": true, + "engines": { + "node": "^12.20 || >= 14.13" + }, + "funding": { + "url": "https://github.com/sponsors/jaydenseric" + } + }, + "node_modules/fast-decode-uri-component": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/fast-decode-uri-component/-/fast-decode-uri-component-1.0.1.tgz", + "integrity": "sha512-WKgKWg5eUxvRZGwW8FvfbaH7AXSh2cL+3j5fMGzUMCxWBJ3dV3a7Wz8y2f/uQ0e3B6WmodD3oS54jTQ9HVTIIg==", + "dev": true + }, + "node_modules/fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", + "dev": true + }, + "node_modules/fast-glob": { + "version": "3.2.12", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", + "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fast-querystring": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/fast-querystring/-/fast-querystring-1.1.2.tgz", + "integrity": "sha512-g6KuKWmFXc0fID8WWH0jit4g0AGBoJhCkJMb1RmbsSEUNvQ+ZC8D6CUZ+GtF8nMzSPXnhiePyyqqipzNNEnHjg==", + "dev": true, + "dependencies": { + "fast-decode-uri-component": "^1.0.1" + } + }, + "node_modules/fast-url-parser": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/fast-url-parser/-/fast-url-parser-1.1.3.tgz", + "integrity": "sha512-5jOCVXADYNuRkKFzNJ0dCCewsZiYo0dz8QNYljkOpFC6r2U4OBmKtvm/Tsuh4w1YYdDqDb31a8TVhBJ2OJKdqQ==", + "dev": true, + "dependencies": { + "punycode": "^1.3.2" + } + }, + "node_modules/fastq": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", + "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", + "dev": true, + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/fb-watchman": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.2.tgz", + "integrity": "sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==", + "dev": true, + "dependencies": { + "bser": "2.1.1" + } + }, + "node_modules/fbjs": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/fbjs/-/fbjs-3.0.5.tgz", + "integrity": "sha512-ztsSx77JBtkuMrEypfhgc3cI0+0h+svqeie7xHbh1k/IKdcydnvadp/mUaGgjAOXQmQSxsqgaRhS3q9fy+1kxg==", + "dev": true, + "dependencies": { + "cross-fetch": "^3.1.5", + "fbjs-css-vars": "^1.0.0", + "loose-envify": "^1.0.0", + "object-assign": "^4.1.0", + "promise": "^7.1.1", + "setimmediate": "^1.0.5", + "ua-parser-js": "^1.0.35" + } + }, + "node_modules/fbjs-css-vars": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/fbjs-css-vars/-/fbjs-css-vars-1.0.2.tgz", + "integrity": "sha512-b2XGFAFdWZWg0phtAWLHCk836A1Xann+I+Dgd3Gk64MHKZO44FfoD1KxyvbSh0qZsIoXQGGlVztIY+oitJPpRQ==", + "dev": true + }, + "node_modules/figures": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", + "integrity": "sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==", + "dev": true, + "dependencies": { + "escape-string-regexp": "^1.0.5" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/globby": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", + "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", + "dev": true, + "dependencies": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.9", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true + }, + "node_modules/graphql": { + "version": "16.6.0", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.6.0.tgz", + "integrity": "sha512-KPIBPDlW7NxrbT/eh4qPXz5FiFdL5UbaA0XUNz2Rp3Z3hqBSkbj0GVjwFDztsWVauZUWsbKHgMg++sk8UX0bkw==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" + } + }, + "node_modules/graphql-codegen": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/graphql-codegen/-/graphql-codegen-0.4.0.tgz", + "integrity": "sha512-OnLWOmsg5Wi7Z0rcVBzLr1oWM/sd/CgL65ANcrLxu03KTJt42bTLbgDalRs++oDRg++FuyYXbQXJJCKIV8sHeA==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.11.6", + "change-case": "^3.0.0", + "graphql": "^0.7.0", + "inflected": "^1.1.7", + "mkdirp": "^0.5.1", + "node-fetch": "^1.5.3", + "yargs": "^5.0.0" + }, + "bin": { + "graphql-codegen": "lib/cli.js" + } + }, + "node_modules/graphql-codegen/node_modules/ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/graphql-codegen/node_modules/camel-case": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/camel-case/-/camel-case-3.0.0.tgz", + "integrity": "sha512-+MbKztAYHXPr1jNTSKQF52VpcFjwY5RkR7fxksV8Doo4KAYc5Fl4UJRgthBbTmEx8C54DqahhbLJkDwjI3PI/w==", + "dev": true, + "dependencies": { + "no-case": "^2.2.0", + "upper-case": "^1.1.1" + } + }, + "node_modules/graphql-codegen/node_modules/camelcase": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", + "integrity": "sha512-4nhGqUkc4BqbBBB4Q6zLuD7lzzrHYrjKGeYaEji/3tFR5VdJu9v+LilhGIVe8wxEJPPOeWo7eg8dwY13TZ1BNg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/graphql-codegen/node_modules/change-case": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/change-case/-/change-case-3.1.0.tgz", + "integrity": "sha512-2AZp7uJZbYEzRPsFoa+ijKdvp9zsrnnt6+yFokfwEpeJm0xuJDVoxiRCAaTzyJND8GJkofo2IcKWaUZ/OECVzw==", + "dev": true, + "dependencies": { + "camel-case": "^3.0.0", + "constant-case": "^2.0.0", + "dot-case": "^2.1.0", + "header-case": "^1.0.0", + "is-lower-case": "^1.1.0", + "is-upper-case": "^1.1.0", + "lower-case": "^1.1.1", + "lower-case-first": "^1.0.0", + "no-case": "^2.3.2", + "param-case": "^2.1.0", + "pascal-case": "^2.0.0", + "path-case": "^2.1.0", + "sentence-case": "^2.1.0", + "snake-case": "^2.1.0", + "swap-case": "^1.1.0", + "title-case": "^2.1.0", + "upper-case": "^1.1.1", + "upper-case-first": "^1.1.0" + } + }, + "node_modules/graphql-codegen/node_modules/cliui": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", + "integrity": "sha512-0yayqDxWQbqk3ojkYqUKqaAQ6AfNKeKWRNA8kR0WXzAsdHpP4BIaOmMAG87JGuO6qcobyW4GjxHd9PmhEd+T9w==", + "dev": true, + "dependencies": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wrap-ansi": "^2.0.0" + } + }, + "node_modules/graphql-codegen/node_modules/constant-case": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/constant-case/-/constant-case-2.0.0.tgz", + "integrity": "sha512-eS0N9WwmjTqrOmR3o83F5vW8Z+9R1HnVz3xmzT2PMFug9ly+Au/fxRWlEBSb6LcZwspSsEn9Xs1uw9YgzAg1EQ==", + "dev": true, + "dependencies": { + "snake-case": "^2.1.0", + "upper-case": "^1.1.1" + } + }, + "node_modules/graphql-codegen/node_modules/dot-case": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-2.1.1.tgz", + "integrity": "sha512-HnM6ZlFqcajLsyudHq7LeeLDr2rFAVYtDv/hV5qchQEidSck8j9OPUsXY9KwJv/lHMtYlX4DjRQqwFYa+0r8Ug==", + "dev": true, + "dependencies": { + "no-case": "^2.2.0" + } + }, + "node_modules/graphql-codegen/node_modules/get-caller-file": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", + "dev": true + }, + "node_modules/graphql-codegen/node_modules/graphql": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-0.7.2.tgz", + "integrity": "sha512-qGAO2oBwKdp4wOSBbYF2g5WbITF3Qca62XGEiqAdDkB1WmLI13XZdsqbdcJsIJXMWX9NhOj7ZZ2K+jEyYO0JOQ==", + "dev": true, + "dependencies": { + "iterall": "1.0.2" + } + }, + "node_modules/graphql-codegen/node_modules/header-case": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/header-case/-/header-case-1.0.1.tgz", + "integrity": "sha512-i0q9mkOeSuhXw6bGgiQCCBgY/jlZuV/7dZXyZ9c6LcBrqwvT8eT719E9uxE5LiZftdl+z81Ugbg/VvXV4OJOeQ==", + "dev": true, + "dependencies": { + "no-case": "^2.2.0", + "upper-case": "^1.1.3" + } + }, + "node_modules/graphql-codegen/node_modules/is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha512-1pqUqRjkhPJ9miNq9SwMfdvi6lBJcd6eFxvfaivQhaH3SgisfiuudvFntdKOmxuee/77l+FPjKrQjWvmPjWrRw==", + "dev": true, + "dependencies": { + "number-is-nan": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/graphql-codegen/node_modules/is-lower-case": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/is-lower-case/-/is-lower-case-1.1.3.tgz", + "integrity": "sha512-+5A1e/WJpLLXZEDlgz4G//WYSHyQBD32qa4Jd3Lw06qQlv3fJHnp3YIHjTQSGzHMgzmVKz2ZP3rBxTHkPw/lxA==", + "dev": true, + "dependencies": { + "lower-case": "^1.1.0" + } + }, + "node_modules/graphql-codegen/node_modules/is-upper-case": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/is-upper-case/-/is-upper-case-1.1.2.tgz", + "integrity": "sha512-GQYSJMgfeAmVwh9ixyk888l7OIhNAGKtY6QA+IrWlu9MDTCaXmeozOZ2S9Knj7bQwBO/H6J2kb+pbyTUiMNbsw==", + "dev": true, + "dependencies": { + "upper-case": "^1.1.0" + } + }, + "node_modules/graphql-codegen/node_modules/lower-case": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-1.1.4.tgz", + "integrity": "sha512-2Fgx1Ycm599x+WGpIYwJOvsjmXFzTSc34IwDWALRA/8AopUKAVPwfJ+h5+f85BCp0PWmmJcWzEpxOpoXycMpdA==", + "dev": true + }, + "node_modules/graphql-codegen/node_modules/lower-case-first": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/lower-case-first/-/lower-case-first-1.0.2.tgz", + "integrity": "sha512-UuxaYakO7XeONbKrZf5FEgkantPf5DUqDayzP5VXZrtRPdH86s4kN47I8B3TW10S4QKiE3ziHNf3kRN//okHjA==", + "dev": true, + "dependencies": { + "lower-case": "^1.1.2" + } + }, + "node_modules/graphql-codegen/node_modules/no-case": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.2.tgz", + "integrity": "sha512-rmTZ9kz+f3rCvK2TD1Ue/oZlns7OGoIWP4fc3llxxRXlOkHKoWPPWJOfFYpITabSow43QJbRIoHQXtt10VldyQ==", + "dev": true, + "dependencies": { + "lower-case": "^1.1.1" + } + }, + "node_modules/graphql-codegen/node_modules/node-fetch": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", + "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", + "dev": true, + "dependencies": { + "encoding": "^0.1.11", + "is-stream": "^1.0.1" + } + }, + "node_modules/graphql-codegen/node_modules/param-case": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/param-case/-/param-case-2.1.1.tgz", + "integrity": "sha512-eQE845L6ot89sk2N8liD8HAuH4ca6Vvr7VWAWwt7+kvvG5aBcPmmphQ68JsEG2qa9n1TykS2DLeMt363AAH8/w==", + "dev": true, + "dependencies": { + "no-case": "^2.2.0" + } + }, + "node_modules/graphql-codegen/node_modules/pascal-case": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-2.0.1.tgz", + "integrity": "sha512-qjS4s8rBOJa2Xm0jmxXiyh1+OFf6ekCWOvUaRgAQSktzlTbMotS0nmG9gyYAybCWBcuP4fsBeRCKNwGBnMe2OQ==", + "dev": true, + "dependencies": { + "camel-case": "^3.0.0", + "upper-case-first": "^1.1.0" + } + }, + "node_modules/graphql-codegen/node_modules/path-case": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/path-case/-/path-case-2.1.1.tgz", + "integrity": "sha512-Ou0N05MioItesaLr9q8TtHVWmJ6fxWdqKB2RohFmNWVyJ+2zeKIeDNWAN6B/Pe7wpzWChhZX6nONYmOnMeJQ/Q==", + "dev": true, + "dependencies": { + "no-case": "^2.2.0" + } + }, + "node_modules/graphql-codegen/node_modules/require-main-filename": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha512-IqSUtOVP4ksd1C/ej5zeEh/BIP2ajqpn8c5x+q99gvcIG/Qf0cud5raVnE/Dwd0ua9TXYDoDc0RE5hBSdz22Ug==", + "dev": true + }, + "node_modules/graphql-codegen/node_modules/sentence-case": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/sentence-case/-/sentence-case-2.1.1.tgz", + "integrity": "sha512-ENl7cYHaK/Ktwk5OTD+aDbQ3uC8IByu/6Bkg+HDv8Mm+XnBnppVNalcfJTNsp1ibstKh030/JKQQWglDvtKwEQ==", + "dev": true, + "dependencies": { + "no-case": "^2.2.0", + "upper-case-first": "^1.1.2" + } + }, + "node_modules/graphql-codegen/node_modules/snake-case": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/snake-case/-/snake-case-2.1.0.tgz", + "integrity": "sha512-FMR5YoPFwOLuh4rRz92dywJjyKYZNLpMn1R5ujVpIYkbA9p01fq8RMg0FkO4M+Yobt4MjHeLTJVm5xFFBHSV2Q==", + "dev": true, + "dependencies": { + "no-case": "^2.2.0" + } + }, + "node_modules/graphql-codegen/node_modules/string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha512-0XsVpQLnVCXHJfyEs8tC0zpTVIr5PKKsQtkT29IwupnPTjtPmQ3xT/4yCREF9hYkV/3M3kzcUTSAZT6a6h81tw==", + "dev": true, + "dependencies": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/graphql-codegen/node_modules/strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==", + "dev": true, + "dependencies": { + "ansi-regex": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/graphql-codegen/node_modules/swap-case": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/swap-case/-/swap-case-1.1.2.tgz", + "integrity": "sha512-BAmWG6/bx8syfc6qXPprof3Mn5vQgf5dwdUNJhsNqU9WdPt5P+ES/wQ5bxfijy8zwZgZZHslC3iAsxsuQMCzJQ==", + "dev": true, + "dependencies": { + "lower-case": "^1.1.1", + "upper-case": "^1.1.1" + } + }, + "node_modules/graphql-codegen/node_modules/title-case": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/title-case/-/title-case-2.1.1.tgz", + "integrity": "sha512-EkJoZ2O3zdCz3zJsYCsxyq2OC5hrxR9mfdd5I+w8h/tmFfeOxJ+vvkxsKxdmN0WtS9zLdHEgfgVOiMVgv+Po4Q==", + "dev": true, + "dependencies": { + "no-case": "^2.2.0", + "upper-case": "^1.0.3" + } + }, + "node_modules/graphql-codegen/node_modules/upper-case": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/upper-case/-/upper-case-1.1.3.tgz", + "integrity": "sha512-WRbjgmYzgXkCV7zNVpy5YgrHgbBv126rMALQQMrmzOVC4GM2waQ9x7xtm8VU+1yF2kWyPzI9zbZ48n4vSxwfSA==", + "dev": true + }, + "node_modules/graphql-codegen/node_modules/upper-case-first": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/upper-case-first/-/upper-case-first-1.1.2.tgz", + "integrity": "sha512-wINKYvI3Db8dtjikdAqoBbZoP6Q+PZUyfMR7pmwHzjC2quzSkUq5DmPrTtPEqHaz8AGtmsB4TqwapMTM1QAQOQ==", + "dev": true, + "dependencies": { + "upper-case": "^1.1.1" + } + }, + "node_modules/graphql-codegen/node_modules/which-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-1.0.0.tgz", + "integrity": "sha512-F6+WgncZi/mJDrammbTuHe1q0R5hOXv/mBaiNA2TCNT/LTHusX0V+CJnj9XT8ki5ln2UZyyddDgHfCzyrOH7MQ==", + "dev": true + }, + "node_modules/graphql-codegen/node_modules/wrap-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "integrity": "sha512-vAaEaDM946gbNpH5pLVNR+vX2ht6n0Bt3GXwVB1AuAqZosOvHNF3P7wDnh8KLkSqgUh0uh77le7Owgoz+Z9XBw==", + "dev": true, + "dependencies": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/graphql-codegen/node_modules/y18n": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.2.tgz", + "integrity": "sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ==", + "dev": true + }, + "node_modules/graphql-codegen/node_modules/yargs": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-5.0.0.tgz", + "integrity": "sha512-krgVLGNhMWUVY1EJkM/bgbvn3yCIRrsZp6KaeX8hx8ztT+jBtX7/flTQcSHe5089xIDQRUsEr2mzlZVNe/7P5w==", + "dev": true, + "dependencies": { + "cliui": "^3.2.0", + "decamelize": "^1.1.1", + "get-caller-file": "^1.0.1", + "lodash.assign": "^4.2.0", + "os-locale": "^1.4.0", + "read-pkg-up": "^1.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^1.0.2", + "which-module": "^1.0.0", + "window-size": "^0.2.0", + "y18n": "^3.2.1", + "yargs-parser": "^3.2.0" + } + }, + "node_modules/graphql-codegen/node_modules/yargs-parser": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-3.2.0.tgz", + "integrity": "sha512-eANlJIqYwhwS/asi4ybKxkeJYUIjNMZXL36C/KICV5jyudUZWp+/lEfBHM0PuJcQjBfs00HwqePEQjtLJd+Kyw==", + "dev": true, + "dependencies": { + "camelcase": "^3.0.0", + "lodash.assign": "^4.1.0" + } + }, + "node_modules/graphql-config": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/graphql-config/-/graphql-config-5.0.2.tgz", + "integrity": "sha512-7TPxOrlbiG0JplSZYCyxn2XQtqVhXomEjXUmWJVSS5ET1nPhOJSsIb/WTwqWhcYX6G0RlHXSj9PLtGTKmxLNGg==", + "dev": true, + "dependencies": { + "@graphql-tools/graphql-file-loader": "^8.0.0", + "@graphql-tools/json-file-loader": "^8.0.0", + "@graphql-tools/load": "^8.0.0", + "@graphql-tools/merge": "^9.0.0", + "@graphql-tools/url-loader": "^8.0.0", + "@graphql-tools/utils": "^10.0.0", + "cosmiconfig": "^8.1.0", + "jiti": "^1.18.2", + "minimatch": "^4.2.3", + "string-env-interpolation": "^1.0.1", + "tslib": "^2.4.0" + }, + "engines": { + "node": ">= 16.0.0" + }, + "peerDependencies": { + "cosmiconfig-toml-loader": "^1.0.0", + "graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" + }, + "peerDependenciesMeta": { + "cosmiconfig-toml-loader": { + "optional": true + } + } + }, + "node_modules/graphql-config/node_modules/minimatch": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-4.2.3.tgz", + "integrity": "sha512-lIUdtK5hdofgCTu3aT0sOaHsYR37viUuIc0rwnnDXImbwFRcumyLMeZaM0t0I/fgxS6s6JMfu0rLD1Wz9pv1ng==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/graphql-request": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/graphql-request/-/graphql-request-6.1.0.tgz", + "integrity": "sha512-p+XPfS4q7aIpKVcgmnZKhMNqhltk20hfXtkaIkTfjjmiKMJ5xrt5c743cL03y/K7y1rg3WrIC49xGiEQ4mxdNw==", + "dev": true, + "dependencies": { + "@graphql-typed-document-node/core": "^3.2.0", + "cross-fetch": "^3.1.5" + }, + "peerDependencies": { + "graphql": "14 - 16" + } + }, + "node_modules/graphql-sse": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/graphql-sse/-/graphql-sse-2.1.4.tgz", + "integrity": "sha512-R+8BdofdcmHOfRt0QnCDq3FtE+CbcD81BO+vW1ZxmzW3XKYRtFNxD4WEL/3j9wF5xXvp133FHw1TtxiS454/4Q==", + "dev": true, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "graphql": ">=0.11 <=16" + } + }, + "node_modules/graphql-tag": { + "version": "2.12.6", + "resolved": "https://registry.npmjs.org/graphql-tag/-/graphql-tag-2.12.6.tgz", + "integrity": "sha512-FdSNcu2QQcWnM2VNvSCCDCVS5PpPqpzgFT8+GXzqJuoDd0CBncxCY278u4mhRO7tMgo2JjgJA5aZ+nWSQ/Z+xg==", + "dev": true, + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "graphql": "^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" + } + }, + "node_modules/graphql-ws": { + "version": "5.13.1", + "resolved": "https://registry.npmjs.org/graphql-ws/-/graphql-ws-5.13.1.tgz", + "integrity": "sha512-eiX7ES/ZQr0q7hSM5UBOEIFfaAUmAY9/CSDyAnsETuybByU7l/v46drRg9DQoTvVABEHp3QnrvwgTRMhqy7zxQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "graphql": ">=0.11 <=16" + } + }, + "node_modules/has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/header-case": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/header-case/-/header-case-2.0.4.tgz", + "integrity": "sha512-H/vuk5TEEVZwrR0lp2zed9OCo1uAILMlx0JEMgC26rzyJJ3N1v6XkwHHXJQdR2doSjcGPM6OKPYoJgf0plJ11Q==", + "dev": true, + "dependencies": { + "capital-case": "^1.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/hoist-non-react-statics": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", + "integrity": "sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==", + "dev": true, + "dependencies": { + "react-is": "^16.7.0" + } + }, + "node_modules/hosted-git-info": { + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", + "dev": true + }, + "node_modules/http-proxy-agent": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.0.tgz", + "integrity": "sha512-+ZT+iBxVUQ1asugqnD6oWoRiS25AkjNfG085dKJGtGxkdwLQrMKU5wJr2bOOFAXzKcTuqq+7fZlTMgG3SRfIYQ==", + "dev": true, + "dependencies": { + "agent-base": "^7.1.0", + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/https-proxy-agent": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.0.tgz", + "integrity": "sha512-0euwPCRyAPSgGdzD1IVN9nJYHtBhJwb6XPfbpQcYbPCwrBidX6GzxmchnaF4sfF/jPb74Ojx5g4yTg3sixlyPw==", + "dev": true, + "dependencies": { + "agent-base": "^7.0.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/ignore": { + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", + "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/immutable": { + "version": "3.7.6", + "resolved": "https://registry.npmjs.org/immutable/-/immutable-3.7.6.tgz", + "integrity": "sha512-AizQPcaofEtO11RZhPPHBOJRdo/20MKQF9mBLnVkBoyHi1/zXK8fzVdnEpSV9gxqtnh6Qomfp3F0xT5qP/vThw==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/import-fresh/node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/import-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/import-from/-/import-from-4.0.0.tgz", + "integrity": "sha512-P9J71vT5nLlDeV8FHs5nNxaLbrpfAV5cF5srvbZfpwpcJoM/xZR3hiv+q+SAnuSmuGbXMWud063iIMx/V/EWZQ==", + "dev": true, + "engines": { + "node": ">=12.2" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/inflected": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/inflected/-/inflected-1.1.7.tgz", + "integrity": "sha512-3lz7idKIPmKvz0wqlu1PUPSg5strJnCh2v2NldPQy13Fmd6WsWQ5yExDoiIX48lQ9mo8N7ztdDlkZxOauZ/E5g==", + "dev": true + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/inquirer": { + "version": "8.2.5", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-8.2.5.tgz", + "integrity": "sha512-QAgPDQMEgrDssk1XiwwHoOGYF9BAbUcc1+j+FhEvaOt8/cKRqyLn0U5qA6F74fGhTMGxf92pOvPBeh29jQJDTQ==", + "dev": true, + "dependencies": { + "ansi-escapes": "^4.2.1", + "chalk": "^4.1.1", + "cli-cursor": "^3.1.0", + "cli-width": "^3.0.0", + "external-editor": "^3.0.3", + "figures": "^3.0.0", + "lodash": "^4.17.21", + "mute-stream": "0.0.8", + "ora": "^5.4.1", + "run-async": "^2.4.0", + "rxjs": "^7.5.5", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0", + "through": "^2.3.6", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/invariant": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", + "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==", + "dev": true, + "dependencies": { + "loose-envify": "^1.0.0" + } + }, + "node_modules/invert-kv": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", + "integrity": "sha512-xgs2NH9AE66ucSq4cNG1nhSFghr5l6tdL15Pk+jl46bmmBapgoaY/AacXyaDznAqmGL99TiLSQgO/XazFSKYeQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-absolute": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-1.0.0.tgz", + "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==", + "dev": true, + "dependencies": { + "is-relative": "^1.0.0", + "is-windows": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", + "dev": true + }, + "node_modules/is-core-module": { + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.12.1.tgz", + "integrity": "sha512-Q4ZuBAe2FUsKtyQJoQHlvP8OvBERxO3jEmy1I7hcRXcJBGGHFh/aJBswbXuS9sgrDH2QUO8ilkwNPHvHMd8clg==", + "dev": true, + "dependencies": { + "has": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-interactive": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", + "integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-lower-case": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/is-lower-case/-/is-lower-case-2.0.2.tgz", + "integrity": "sha512-bVcMJy4X5Og6VZfdOZstSexlEy20Sr0k/p/b2IlQJlfdKAQuMpiv5w2Ccxb8sKdRUNAG1PnHVHjFSdRDVS6NlQ==", + "dev": true, + "dependencies": { + "tslib": "^2.0.3" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-relative": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-1.0.0.tgz", + "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==", + "dev": true, + "dependencies": { + "is-unc-path": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-unc-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-1.0.0.tgz", + "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==", + "dev": true, + "dependencies": { + "unc-path-regex": "^0.1.2" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-upper-case": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/is-upper-case/-/is-upper-case-2.0.2.tgz", + "integrity": "sha512-44pxmxAvnnAOwBg4tHPnkfvgjPwbc5QIsSstNU+YcJ1ovxVzCWpSGosPJOZh/a1tdl81fbgnLc9LLv+x2ywbPQ==", + "dev": true, + "dependencies": { + "tslib": "^2.0.3" + } + }, + "node_modules/is-utf8": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", + "integrity": "sha512-rMYPYvCzsXywIsldgLaSoPlw5PfoB/ssr7hY4pLfcodrA5M/eArza1a9VmTiNIBNMjOGr1Ow9mTyU2o69U6U9Q==", + "dev": true + }, + "node_modules/is-windows": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/isomorphic-ws": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-5.0.0.tgz", + "integrity": "sha512-muId7Zzn9ywDsyXgTIafTry2sV3nySZeUDe6YedVd1Hvuuep5AsIlqK+XefWpYTyJG5e503F2xIuT2lcU6rCSw==", + "dev": true, + "peerDependencies": { + "ws": "*" + } + }, + "node_modules/iterall": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/iterall/-/iterall-1.0.2.tgz", + "integrity": "sha512-RaKa8RHmSay1GvkTLOYRT8Ju9/Cf0DRK9z7YzS14sID4e2hkP4eknzDhTtzTboO8shZIysbVEEnmjJEHxOVIMQ==", + "dev": true + }, + "node_modules/jiti": { + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-1.18.2.tgz", + "integrity": "sha512-QAdOptna2NYiSSpv0O/BwoHBSmz4YhpzJHyi+fnMRTXFjp7B8i/YG5Z8IfusxB1ufjcD2Sre1F3R+nX3fvy7gg==", + "dev": true, + "bin": { + "jiti": "bin/jiti.js" + } + }, + "node_modules/jose": { + "version": "4.14.4", + "resolved": "https://registry.npmjs.org/jose/-/jose-4.14.4.tgz", + "integrity": "sha512-j8GhLiKmUAh+dsFXlX1aJCbt5KMibuKb+d7j1JaOJG6s2UjX1PQlW+OKB/sD4a/5ZYF4RcmYmLSndOoU3Lt/3g==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/panva" + } + }, + "node_modules/js-string-escape": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/js-string-escape/-/js-string-escape-1.0.1.tgz", + "integrity": "sha512-Smw4xcfIQ5LVjAOuJCvN/zIodzA/BBSsluuoSykP+lUvScIi4U6RJLfwHet5cxFnCswUjISV8oAXaqaJDY3chg==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/jsesc": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "dev": true, + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", + "dev": true + }, + "node_modules/json-stable-stringify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.2.tgz", + "integrity": "sha512-eunSSaEnxV12z+Z73y/j5N37/In40GK4GmsSy+tEHJMxknvqnA7/djeYtAgW0GsWHUfg+847WJjKaEylk2y09g==", + "dev": true, + "dependencies": { + "jsonify": "^0.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/json-to-pretty-yaml": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/json-to-pretty-yaml/-/json-to-pretty-yaml-1.2.2.tgz", + "integrity": "sha512-rvm6hunfCcqegwYaG5T4yKJWxc9FXFgBVrcTZ4XfSVRwa5HA/Xs+vB/Eo9treYYHCeNM0nrSUr82V/M31Urc7A==", + "dev": true, + "dependencies": { + "remedial": "^1.0.7", + "remove-trailing-spaces": "^1.0.6" + }, + "engines": { + "node": ">= 0.2.0" + } + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/jsonc-parser": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", + "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==", + "dev": true + }, + "node_modules/jsonify": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.1.tgz", + "integrity": "sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/lcid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", + "integrity": "sha512-YiGkH6EnGrDGqLMITnGjXtGmNtjoXw9SVUzcaos8RBi7Ps0VBylkq+vOcY9QE5poLasPCR849ucFUkl0UzUyOw==", + "dev": true, + "dependencies": { + "invert-kv": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true + }, + "node_modules/listr2": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/listr2/-/listr2-4.0.5.tgz", + "integrity": "sha512-juGHV1doQdpNT3GSTs9IUN43QJb7KHdF9uqg7Vufs/tG9VTzpFphqF4pm/ICdAABGQxsyNn9CiYA3StkI6jpwA==", + "dev": true, + "dependencies": { + "cli-truncate": "^2.1.0", + "colorette": "^2.0.16", + "log-update": "^4.0.0", + "p-map": "^4.0.0", + "rfdc": "^1.3.0", + "rxjs": "^7.5.5", + "through": "^2.3.8", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "enquirer": ">= 2.3.0 < 3" + }, + "peerDependenciesMeta": { + "enquirer": { + "optional": true + } + } + }, + "node_modules/load-json-file": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "integrity": "sha512-cy7ZdNRXdablkXYNI049pthVeXFurRyb9+hA/dZzerZ0pGTx42z+y+ssxBaVV2l70t1muq5IdKhn4UtcoGUY9A==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0", + "strip-bom": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/load-json-file/node_modules/parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha512-QR/GGaKCkhwk1ePQNYDRKYZ3mwU9ypsKhB0XyFnLQdomyEqk3e8wpW3V5Jp88zbxK4n5ST1nqo+g9juTpownhQ==", + "dev": true, + "dependencies": { + "error-ex": "^1.2.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/local-pkg": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.4.3.tgz", + "integrity": "sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, + "node_modules/lodash.assign": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-4.2.0.tgz", + "integrity": "sha512-hFuH8TY+Yji7Eja3mGiuAxBqLagejScbG8GbG0j6o9vzn0YL14My+ktnqtZgFTosKymC9/44wP6s7xyuLfnClw==", + "dev": true + }, + "node_modules/lodash.sortby": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", + "integrity": "sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==", + "dev": true + }, + "node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dev": true, + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/log-update": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/log-update/-/log-update-4.0.0.tgz", + "integrity": "sha512-9fkkDevMefjg0mmzWFBW8YkFP91OrizzkW3diF7CpG+S2EYdy4+TVfGwz1zeF8x7hCx1ovSPTOE9Ngib74qqUg==", + "dev": true, + "dependencies": { + "ansi-escapes": "^4.3.0", + "cli-cursor": "^3.1.0", + "slice-ansi": "^4.0.0", + "wrap-ansi": "^6.2.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/log-update/node_modules/slice-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz", + "integrity": "sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "astral-regex": "^2.0.0", + "is-fullwidth-code-point": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/slice-ansi?sponsor=1" + } + }, + "node_modules/log-update/node_modules/wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, + "node_modules/loupe": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz", + "integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==", + "dev": true, + "dependencies": { + "get-func-name": "^2.0.0" + } + }, + "node_modules/lower-case": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", + "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", + "dev": true, + "dependencies": { + "tslib": "^2.0.3" + } + }, + "node_modules/lower-case-first": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/lower-case-first/-/lower-case-first-2.0.2.tgz", + "integrity": "sha512-EVm/rR94FJTZi3zefZ82fLWab+GX14LJN4HrWBcuo6Evmsl9hEfnqxgcHCKb9q+mNf6EVdsjx/qucYFIIB84pg==", + "dev": true, + "dependencies": { + "tslib": "^2.0.3" + } + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/magic-string": { + "version": "0.30.0", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.0.tgz", + "integrity": "sha512-LA+31JYDJLs82r2ScLrlz1GjSgu66ZV518eyWT+S8VhyQn/JL0u9MeBOvQMGYiPk1DBiSN9DDMOcXvigJZaViQ==", + "dev": true, + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.13" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/map-cache": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", + "integrity": "sha512-8y/eV9QQZCiyn1SprXSrCmqJN0yNRATe+PO8ztwqrvrbdRLA3eYJF0yaR0YayLWkMbsQSKWS9N2gPcGEc4UsZg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/md5-hex": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/md5-hex/-/md5-hex-3.0.1.tgz", + "integrity": "sha512-BUiRtTtV39LIJwinWBjqVsU9xhdnz7/i889V859IBFpuqGAj6LuOvHv5XLbgZ2R7ptJoJaEcxkv88/h25T7Ciw==", + "dev": true, + "dependencies": { + "blueimp-md5": "^2.10.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/meros": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/meros/-/meros-1.3.0.tgz", + "integrity": "sha512-2BNGOimxEz5hmjUG2FwoxCt5HN7BXdaWyFqEwxPTrJzVdABtrL4TiHTcsWSFAxPQ/tOnEaQEJh3qWq71QRMY+w==", + "dev": true, + "engines": { + "node": ">=13" + }, + "peerDependencies": { + "@types/node": ">=13" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dev": true, + "dependencies": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/mlly": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.3.0.tgz", + "integrity": "sha512-HT5mcgIQKkOrZecOjOX3DJorTikWXwsBfpcr/MGBkhfWcjiqvnaL/9ppxvIUXfjT6xt4DVIAsN9fMUz1ev4bIw==", + "dev": true, + "dependencies": { + "acorn": "^8.8.2", + "pathe": "^1.1.0", + "pkg-types": "^1.0.3", + "ufo": "^1.1.2" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/mute-stream": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", + "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", + "dev": true + }, + "node_modules/nanoid": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/no-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", + "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", + "dev": true, + "dependencies": { + "lower-case": "^2.0.2", + "tslib": "^2.0.3" + } + }, + "node_modules/node-addon-api": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.2.1.tgz", + "integrity": "sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==", + "dev": true + }, + "node_modules/node-fetch": { + "version": "2.6.11", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.11.tgz", + "integrity": "sha512-4I6pdBY1EthSqDmJkiNk3JIT8cswwR9nfeW/cPdUagJYEQG7R95WRH74wpz7ma8Gh/9dI9FP+OU+0E4FvtA55w==", + "dev": true, + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/node-gyp-build": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.6.0.tgz", + "integrity": "sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ==", + "dev": true, + "bin": { + "node-gyp-build": "bin.js", + "node-gyp-build-optional": "optional.js", + "node-gyp-build-test": "build-test.js" + } + }, + "node_modules/node-int64": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", + "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==", + "dev": true + }, + "node_modules/node-releases": { + "version": "2.0.12", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.12.tgz", + "integrity": "sha512-QzsYKWhXTWx8h1kIvqfnC++o0pEmpRQA/aenALsL2F4pqNVr7YzcdMlDij5WBnwftRbJCNJL/O7zdKaxKPHqgQ==", + "dev": true + }, + "node_modules/normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "dependencies": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, + "node_modules/normalize-package-data/node_modules/semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true, + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha512-3pKJwH184Xo/lnH6oyP1q2pMd7HcypqqmRs91/6/i2CGtWwIKGCkOOMTm/zXbgTEWHw1uNpNi/igc3ePOYHb6w==", + "dev": true, + "dependencies": { + "remove-trailing-separator": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/nullthrows": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/nullthrows/-/nullthrows-1.1.1.tgz", + "integrity": "sha512-2vPPEi+Z7WqML2jZYddDIfy5Dqb0r2fze2zTxNNknZaFpVHU3mFB3R+DWeJWGVx0ecvttSGlJTI+WG+8Z4cDWw==", + "dev": true + }, + "node_modules/number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha512-4jbtZXNAsfZbAHiiqjLPBiCl16dES1zI4Hpzzxw61Tk+loF+sBDBKx1ICKKKwIqQ7M0mFn1TmkN7euSncWgHiQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, + "dependencies": { + "mimic-fn": "^2.1.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/optimism": { + "version": "0.16.2", + "resolved": "https://registry.npmjs.org/optimism/-/optimism-0.16.2.tgz", + "integrity": "sha512-zWNbgWj+3vLEjZNIh/okkY2EUfX+vB9TJopzIZwT1xxaMqC5hRLLraePod4c5n4He08xuXNH+zhKFFCu390wiQ==", + "dev": true, + "dependencies": { + "@wry/context": "^0.7.0", + "@wry/trie": "^0.3.0" + } + }, + "node_modules/optimism/node_modules/@wry/trie": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@wry/trie/-/trie-0.3.2.tgz", + "integrity": "sha512-yRTyhWSls2OY/pYLfwff867r8ekooZ4UI+/gxot5Wj8EFwSf2rG+n+Mo/6LoLQm1TKA4GRj2+LCpbfS937dClQ==", + "dev": true, + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/ora": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/ora/-/ora-5.4.1.tgz", + "integrity": "sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==", + "dev": true, + "dependencies": { + "bl": "^4.1.0", + "chalk": "^4.1.0", + "cli-cursor": "^3.1.0", + "cli-spinners": "^2.5.0", + "is-interactive": "^1.0.0", + "is-unicode-supported": "^0.1.0", + "log-symbols": "^4.1.0", + "strip-ansi": "^6.0.0", + "wcwidth": "^1.0.1" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/os-locale": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", + "integrity": "sha512-PRT7ZORmwu2MEFt4/fv3Q+mEfN4zetKxufQrkShY2oGvUms9r8otu5HfdyIFHkYXjO7laNsoVGmM2MANfuTA8g==", + "dev": true, + "dependencies": { + "lcid": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/p-locate/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-map": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-4.0.0.tgz", + "integrity": "sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==", + "dev": true, + "dependencies": { + "aggregate-error": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/param-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.4.tgz", + "integrity": "sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==", + "dev": true, + "dependencies": { + "dot-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/parse-filepath": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.2.tgz", + "integrity": "sha512-FwdRXKCohSVeXqwtYonZTXtbGJKrn+HNyWDYVcp5yuJlesTwNH4rsmRZ+GrKAPJ5bLpRxESMeS+Rl0VCHRvB2Q==", + "dev": true, + "dependencies": { + "is-absolute": "^1.0.0", + "map-cache": "^0.2.0", + "path-root": "^0.1.1" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/parse-json": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/pascal-case": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz", + "integrity": "sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==", + "dev": true, + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/path-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/path-case/-/path-case-3.0.4.tgz", + "integrity": "sha512-qO4qCFjXqVTrcbPt/hQfhTQ+VhFsqNKOPtytgNKkKxSoEp3XPUQ8ObFuePylOIok5gjn69ry8XiULxCwot3Wfg==", + "dev": true, + "dependencies": { + "dot-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "node_modules/path-root": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/path-root/-/path-root-0.1.1.tgz", + "integrity": "sha512-QLcPegTHF11axjfojBIoDygmS2E3Lf+8+jI6wOVmNVenrKSo3mFdSGiIgdSHenczw3wPtlVMQaFVwGmM7BJdtg==", + "dev": true, + "dependencies": { + "path-root-regex": "^0.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-root-regex": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/path-root-regex/-/path-root-regex-0.1.2.tgz", + "integrity": "sha512-4GlJ6rZDhQZFE0DPVKh0e9jmZ5egZfxTkp7bcRDuPlJXbAwhxcl2dINPUAsjLdejqaLsCeg8axcLjIbvBjN4pQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/pathe": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.1.tgz", + "integrity": "sha512-d+RQGp0MAYTIaDBIMmOfMwz3E+LOZnxx1HZd5R18mmCZY0QBlK0LDZfPc8FW8Ed2DlvsuE6PRjroDY+wg4+j/Q==", + "dev": true + }, + "node_modules/pathval": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", + "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", + "dev": true + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha512-MnUuEycAemtSaeFSjXKW/aroV7akBbY+Sv+RkyqFjgAe73F+MR0TBWKBRDkmfWq/HiFmdavfZ1G7h4SPZXaCSg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha512-0Gni6D4UcLTbv9c57DfxDGdr41XfgUjqWZu492f0cIGr16zDU06BWP/RAEvOuo7CQ0CNjHaLlM59YJJFm3NWlw==", + "dev": true, + "dependencies": { + "pinkie": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pkg-types": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.0.3.tgz", + "integrity": "sha512-nN7pYi0AQqJnoLPC9eHFQ8AcyaixBUOwvqc5TDnIKCMEE6I0y8P7OKA7fPexsXGCGxQDl/cmrLAp26LhcwxZ4A==", + "dev": true, + "dependencies": { + "jsonc-parser": "^3.2.0", + "mlly": "^1.2.0", + "pathe": "^1.1.0" + } + }, + "node_modules/postcss": { + "version": "8.4.31", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", + "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "nanoid": "^3.3.6", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/pretty-format": { + "version": "27.5.1", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", + "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1", + "ansi-styles": "^5.0.0", + "react-is": "^17.0.1" + }, + "engines": { + "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + } + }, + "node_modules/pretty-format/node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/pretty-format/node_modules/react-is": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", + "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", + "dev": true + }, + "node_modules/promise": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", + "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", + "dev": true, + "dependencies": { + "asap": "~2.0.3" + } + }, + "node_modules/prop-types": { + "version": "15.8.1", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", + "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", + "dev": true, + "dependencies": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.13.1" + } + }, + "node_modules/punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ==", + "dev": true + }, + "node_modules/pvtsutils": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/pvtsutils/-/pvtsutils-1.3.2.tgz", + "integrity": "sha512-+Ipe2iNUyrZz+8K/2IOo+kKikdtfhRKzNpQbruF2URmqPtoqAs8g3xS7TJvFF2GcPXjh7DkqMnpVveRFq4PgEQ==", + "dev": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/pvutils": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/pvutils/-/pvutils-1.1.3.tgz", + "integrity": "sha512-pMpnA0qRdFp32b1sJl1wOJNxZLQ2cbQx+k6tjNtZ8CpvVhNqEPRgivZ2WOUev2YMajecdH7ctUPDvEe87nariQ==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/react": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", + "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==", + "dev": true, + "peer": true, + "dependencies": { + "loose-envify": "^1.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "dev": true + }, + "node_modules/read-pkg": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", + "integrity": "sha512-7BGwRHqt4s/uVbuyoeejRn4YmFnYZiFl4AuaeXHlgZf3sONF0SOGlxs2Pw8g6hCKupo08RafIO5YXFNOKTfwsQ==", + "dev": true, + "dependencies": { + "load-json-file": "^1.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/read-pkg-up": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", + "integrity": "sha512-WD9MTlNtI55IwYUS27iHh9tK3YoIVhxis8yKhLpTqWtml739uXc9NWTpxoHkfZf3+DkCCsXox94/VWZniuZm6A==", + "dev": true, + "dependencies": { + "find-up": "^1.0.0", + "read-pkg": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/read-pkg-up/node_modules/find-up": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", + "integrity": "sha512-jvElSjyuo4EMQGoTwo1uJU5pQMwTW5lS1x05zzfJuTIyLR3zwO27LYrxNg+dlvKpGOuGy/MzBdXh80g0ve5+HA==", + "dev": true, + "dependencies": { + "path-exists": "^2.0.0", + "pinkie-promise": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/read-pkg-up/node_modules/path-exists": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", + "integrity": "sha512-yTltuKuhtNeFJKa1PiRzfLAU5182q1y4Eb4XCJ3PBqyzEDkAZRzBrKKBct682ls9reBVHf9udYLN5Nd+K1B9BQ==", + "dev": true, + "dependencies": { + "pinkie-promise": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/read-pkg/node_modules/path-type": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", + "integrity": "sha512-S4eENJz1pkiQn9Znv33Q+deTOKmbl+jj1Fl+qiP/vYezj+S8x+J3Uo0ISrx/QoEvIlOaDWJhPaRd1flJ9HXZqg==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.1.2", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/regenerator-runtime": { + "version": "0.13.11", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", + "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", + "dev": true + }, + "node_modules/relay-runtime": { + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/relay-runtime/-/relay-runtime-12.0.0.tgz", + "integrity": "sha512-QU6JKr1tMsry22DXNy9Whsq5rmvwr3LSZiiWV/9+DFpuTWvp+WFhobWMc8TC4OjKFfNhEZy7mOiqUAn5atQtug==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.0.0", + "fbjs": "^3.0.0", + "invariant": "^2.2.4" + } + }, + "node_modules/remedial": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/remedial/-/remedial-1.0.8.tgz", + "integrity": "sha512-/62tYiOe6DzS5BqVsNpH/nkGlX45C/Sp6V+NtiN6JQNS1Viay7cWkazmRkrQrdFj2eshDe96SIQNIoMxqhzBOg==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/remove-trailing-separator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", + "integrity": "sha512-/hS+Y0u3aOfIETiaiirUFwDBDzmXPvO+jAfKTitUngIPzdKc6Z0LoFjM/CK5PL4C+eKwHohlHAb6H0VFfmmUsw==", + "dev": true + }, + "node_modules/remove-trailing-spaces": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/remove-trailing-spaces/-/remove-trailing-spaces-1.0.8.tgz", + "integrity": "sha512-O3vsMYfWighyFbTd8hk8VaSj9UAGENxAtX+//ugIst2RMk5e03h6RoIS+0ylsFxY1gvmPuAY/PO4It+gPEeySA==", + "dev": true + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true + }, + "node_modules/resolve": { + "version": "1.22.2", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.2.tgz", + "integrity": "sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g==", + "dev": true, + "dependencies": { + "is-core-module": "^2.11.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/response-iterator": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/response-iterator/-/response-iterator-0.2.6.tgz", + "integrity": "sha512-pVzEEzrsg23Sh053rmDUvLSkGXluZio0qu8VT6ukrYuvtjVfCbDZH9d6PGXb8HZfzdNZt8feXv/jvUzlhRgLnw==", + "dev": true, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/restore-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", + "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", + "dev": true, + "dependencies": { + "onetime": "^5.1.0", + "signal-exit": "^3.0.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true, + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/rfdc": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.3.0.tgz", + "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==", + "dev": true + }, + "node_modules/rollup": { + "version": "3.25.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.25.1.tgz", + "integrity": "sha512-tywOR+rwIt5m2ZAWSe5AIJcTat8vGlnPFAv15ycCrw33t6iFsXZ6mzHVFh2psSjxQPmI+xgzMZZizUAukBI4aQ==", + "dev": true, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=14.18.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/run-async": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", + "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/rxjs": { + "version": "7.8.1", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", + "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", + "dev": true, + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true + }, + "node_modules/scuid": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/scuid/-/scuid-1.1.0.tgz", + "integrity": "sha512-MuCAyrGZcTLfQoH2XoBlQ8C6bzwN88XT/0slOGz0pn8+gIP85BOAfYa44ZXQUTOwRwPU0QvgU+V+OSajl/59Xg==", + "dev": true + }, + "node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/sentence-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/sentence-case/-/sentence-case-3.0.4.tgz", + "integrity": "sha512-8LS0JInaQMCRoQ7YUytAo/xUu5W2XnQxV2HI/6uM6U7CITS1RqPElr30V6uIqyMKM9lJGRVFy5/4CuzcixNYSg==", + "dev": true, + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3", + "upper-case-first": "^2.0.2" + } + }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", + "dev": true + }, + "node_modules/setimmediate": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", + "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==", + "dev": true + }, + "node_modules/shell-quote": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.1.tgz", + "integrity": "sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", + "dev": true + }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true + }, + "node_modules/signedsource": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/signedsource/-/signedsource-1.0.0.tgz", + "integrity": "sha512-6+eerH9fEnNmi/hyM1DXcRK3pWdoMQtlkQ+ns0ntzunjKqp5i3sKCc80ym8Fib3iaYhdJUOPdhlJWj1tvge2Ww==", + "dev": true + }, + "node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/slice-ansi": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-3.0.0.tgz", + "integrity": "sha512-pSyv7bSTC7ig9Dcgbw9AuRNUb5k5V6oDudjZoMBSr13qpLBG7tB+zgCkARjq7xIUgdz5P1Qe8u+rSGdouOOIyQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "astral-regex": "^2.0.0", + "is-fullwidth-code-point": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/snake-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/snake-case/-/snake-case-3.0.4.tgz", + "integrity": "sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==", + "dev": true, + "dependencies": { + "dot-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/spdx-correct": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.2.0.tgz", + "integrity": "sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==", + "dev": true, + "dependencies": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "node_modules/spdx-exceptions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz", + "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==", + "dev": true + }, + "node_modules/spdx-expression-parse": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", + "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", + "dev": true, + "dependencies": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "node_modules/spdx-license-ids": { + "version": "3.0.13", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.13.tgz", + "integrity": "sha512-XkD+zwiqXHikFZm4AX/7JSCXA98U5Db4AFd5XUg/+9UNtnH75+Z9KxtpYiJZx36mUDVOwH83pl7yvCer6ewM3w==", + "dev": true + }, + "node_modules/sponge-case": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/sponge-case/-/sponge-case-1.0.1.tgz", + "integrity": "sha512-dblb9Et4DAtiZ5YSUZHLl4XhH4uK80GhAZrVXdN4O2P4gQ40Wa5UIOPUHlA/nFd2PLblBZWUioLMMAVrgpoYcA==", + "dev": true, + "dependencies": { + "tslib": "^2.0.3" + } + }, + "node_modules/stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", + "dev": true + }, + "node_modules/std-env": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.3.3.tgz", + "integrity": "sha512-Rz6yejtVyWnVjC1RFvNmYL10kgjC49EOghxWn0RFqlCHGFpQx+Xe7yW3I4ceK1SGrWIGMjD5Kbue8W/udkbMJg==", + "dev": true + }, + "node_modules/streamsearch": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", + "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", + "dev": true, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/string-env-interpolation": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/string-env-interpolation/-/string-env-interpolation-1.0.1.tgz", + "integrity": "sha512-78lwMoCcn0nNu8LszbP1UA7g55OeE4v7rCeWnM5B453rnNr4aq+5it3FEYtZrSEiMvHZOZ9Jlqb0OD0M2VInqg==", + "dev": true + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-bom": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", + "integrity": "sha512-kwrX1y7czp1E69n2ajbG65mIo9dqvJ+8aBQXOGVxqwvNbsXdFM6Lq37dLAY3mknUwru8CfcCbfOLL/gMo+fi3g==", + "dev": true, + "dependencies": { + "is-utf8": "^0.2.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/strip-literal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-1.0.1.tgz", + "integrity": "sha512-QZTsipNpa2Ppr6v1AmJHESqJ3Uz247MUS0OjrnnZjFAvEoWqxuyFuXn2xLgMtRnijJShAa1HL0gtJyUs7u7n3Q==", + "dev": true, + "dependencies": { + "acorn": "^8.8.2" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/swap-case": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/swap-case/-/swap-case-2.0.2.tgz", + "integrity": "sha512-kc6S2YS/2yXbtkSMunBtKdah4VFETZ8Oh6ONSmSd9bRxhqTrtARUCBUiWXH3xVPpvR7tz2CSnkuXVE42EcGnMw==", + "dev": true, + "dependencies": { + "tslib": "^2.0.3" + } + }, + "node_modules/symbol-observable": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-4.0.0.tgz", + "integrity": "sha512-b19dMThMV4HVFynSAM1++gBHAbk2Tc/osgLIBZMKsyqh34jb2e8Os7T6ZW/Bt3pJFdBTd2JwAnAAEQV7rSNvcQ==", + "dev": true, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", + "dev": true + }, + "node_modules/time-zone": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/time-zone/-/time-zone-1.0.0.tgz", + "integrity": "sha512-TIsDdtKo6+XrPtiTm1ssmMngN1sAhyKnTO2kunQWqNPWIVvCm15Wmw4SWInwTVgJ5u/Tr04+8Ei9TNcw4x4ONA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/tinybench": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.5.0.tgz", + "integrity": "sha512-kRwSG8Zx4tjF9ZiyH4bhaebu+EDz1BOx9hOigYHlUW4xxI/wKIUQUqo018UlU4ar6ATPBsaMrdbKZ+tmPdohFA==", + "dev": true + }, + "node_modules/tinypool": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-0.5.0.tgz", + "integrity": "sha512-paHQtnrlS1QZYKF/GnLoOM/DN9fqaGOFbCbxzAhwniySnzl9Ebk8w73/dd34DAhe/obUbPAOldTyYXQZxnPBPQ==", + "dev": true, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tinyspy": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-2.1.1.tgz", + "integrity": "sha512-XPJL2uSzcOyBMky6OFrusqWlzfFrXtE0hPuMgW8A2HmaqrPo4ZQHRN/V0QXN3FSjKxpsbRrFc5LI7KOwBsT1/w==", + "dev": true, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/title-case": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/title-case/-/title-case-3.0.3.tgz", + "integrity": "sha512-e1zGYRvbffpcHIrnuqT0Dh+gEJtDaxDSoG4JAIpq4oDFyooziLBIiYQv0GBT4FUAnUop5uZ1hiIAj7oAF6sOCA==", + "dev": true, + "dependencies": { + "tslib": "^2.0.3" + } + }, + "node_modules/tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "dev": true, + "dependencies": { + "os-tmpdir": "~1.0.2" + }, + "engines": { + "node": ">=0.6.0" + } + }, + "node_modules/to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "dev": true + }, + "node_modules/ts-invariant": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/ts-invariant/-/ts-invariant-0.10.3.tgz", + "integrity": "sha512-uivwYcQaxAucv1CzRp2n/QdYPo4ILf9VXgH19zEIjFx2EJufV16P0JtJVpYHy89DItG6Kwj2oIUjrcK5au+4tQ==", + "dev": true, + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/ts-log": { + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/ts-log/-/ts-log-2.2.5.tgz", + "integrity": "sha512-PGcnJoTBnVGy6yYNFxWVNkdcAuAMstvutN9MgDJIV6L0oG8fB+ZNNy1T+wJzah8RPGor1mZuPQkVfXNDpy9eHA==", + "dev": true + }, + "node_modules/tslib": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.3.tgz", + "integrity": "sha512-mSxlJJwl3BMEQCUNnxXBU9jP4JBktcEGhURcPR6VQVlnP0FdDEsIaz0C35dXNGLyRfrATNofF0F5p2KPxQgB+w==", + "dev": true + }, + "node_modules/type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/type-fest": { + "version": "0.21.3", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", + "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/typescript": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.3.tgz", + "integrity": "sha512-XH627E9vkeqhlZFQuL+UsyAXEnibT0kWR2FWONlr4sTjvxyJYnyefgrkyECLzM5NenmKzRAy2rR/OlYLA1HkZw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/ua-parser-js": { + "version": "1.0.35", + "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.35.tgz", + "integrity": "sha512-fKnGuqmTBnIE+/KXSzCn4db8RTigUzw1AN0DmdU6hJovUTbYJKyqj+8Mt1c4VfRDnOVJnENmfYkIPZ946UrSAA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/ua-parser-js" + }, + { + "type": "paypal", + "url": "https://paypal.me/faisalman" + } + ], + "engines": { + "node": "*" + } + }, + "node_modules/ufo": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.1.2.tgz", + "integrity": "sha512-TrY6DsjTQQgyS3E3dBaOXf0TpPD8u9FVrVYmKVegJuFw51n/YB9XPt+U6ydzFG5ZIN7+DIjPbNmXoBj9esYhgQ==", + "dev": true + }, + "node_modules/unc-path-regex": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", + "integrity": "sha512-eXL4nmJT7oCpkZsHZUOJo8hcX3GbsiDOa0Qu9F646fi8dT3XuSVopVqAcEiVzSKKH7UoDti23wNX3qGFxcW5Qg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/unixify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unixify/-/unixify-1.0.0.tgz", + "integrity": "sha512-6bc58dPYhCMHHuwxldQxO3RRNZ4eCogZ/st++0+fcC1nr0jiGUtAdBJ2qzmLQWSxbtz42pWt4QQMiZ9HvZf5cg==", + "dev": true, + "dependencies": { + "normalize-path": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.11.tgz", + "integrity": "sha512-dCwEFf0/oT85M1fHBg4F0jtLwJrutGoHSQXCh7u4o2t1drG+c0a9Flnqww6XUKSfQMPpJBRjU8d4RXB09qtvaA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "escalade": "^3.1.1", + "picocolors": "^1.0.0" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/upper-case": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/upper-case/-/upper-case-2.0.2.tgz", + "integrity": "sha512-KgdgDGJt2TpuwBUIjgG6lzw2GWFRCW9Qkfkiv0DxqHHLYJHmtmdUIKcZd8rHgFSjopVTlw6ggzCm1b8MFQwikg==", + "dev": true, + "dependencies": { + "tslib": "^2.0.3" + } + }, + "node_modules/upper-case-first": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/upper-case-first/-/upper-case-first-2.0.2.tgz", + "integrity": "sha512-514ppYHBaKwfJRK/pNC6c/OxfGa0obSnAl106u97Ed0I625Nin96KAjttZF6ZL3e1XLtphxnqrOi9iWgm+u+bg==", + "dev": true, + "dependencies": { + "tslib": "^2.0.3" + } + }, + "node_modules/urlpattern-polyfill": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/urlpattern-polyfill/-/urlpattern-polyfill-8.0.2.tgz", + "integrity": "sha512-Qp95D4TPJl1kC9SKigDcqgyM2VDVO4RiJc2d4qe5GrYm+zbIQCWWKAFaJNQ4BhdFeDGwBmAxqJBwWSJDb9T3BQ==", + "dev": true + }, + "node_modules/urql": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/urql/-/urql-4.0.4.tgz", + "integrity": "sha512-C5P4BMnAsk+rbytCWglit5ijXbIKXsa9wofSGPbuMyJKsDdL+9GfipS362Nff/Caag+eYOK5W+sox8fwEILT6Q==", + "dev": true, + "dependencies": { + "@urql/core": "^4.0.0", + "wonka": "^6.3.2" + }, + "peerDependencies": { + "react": ">= 16.8.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true + }, + "node_modules/validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "dev": true, + "dependencies": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, + "node_modules/value-or-promise": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/value-or-promise/-/value-or-promise-1.0.12.tgz", + "integrity": "sha512-Z6Uz+TYwEqE7ZN50gwn+1LCVo9ZVrpxRPOhOLnncYkY1ZzOYtrX8Fwf/rFktZ8R5mJms6EZf5TqNOMeZmnPq9Q==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/vite": { + "version": "4.3.9", + "resolved": "https://registry.npmjs.org/vite/-/vite-4.3.9.tgz", + "integrity": "sha512-qsTNZjO9NoJNW7KnOrgYwczm0WctJ8m/yqYAMAK9Lxt4SoySUfS5S8ia9K7JHpa3KEeMfyF8LoJ3c5NeBJy6pg==", + "dev": true, + "dependencies": { + "esbuild": "^0.17.5", + "postcss": "^8.4.23", + "rollup": "^3.21.0" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + }, + "peerDependencies": { + "@types/node": ">= 14", + "less": "*", + "sass": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + } + } + }, + "node_modules/vite-node": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-0.32.0.tgz", + "integrity": "sha512-220P/y8YacYAU+daOAqiGEFXx2A8AwjadDzQqos6wSukjvvTWNqleJSwoUn0ckyNdjHIKoxn93Nh1vWBqEKr3Q==", + "dev": true, + "dependencies": { + "cac": "^6.7.14", + "debug": "^4.3.4", + "mlly": "^1.2.0", + "pathe": "^1.1.0", + "picocolors": "^1.0.0", + "vite": "^3.0.0 || ^4.0.0" + }, + "bin": { + "vite-node": "vite-node.mjs" + }, + "engines": { + "node": ">=v14.18.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/vitest": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.32.0.tgz", + "integrity": "sha512-SW83o629gCqnV3BqBnTxhB10DAwzwEx3z+rqYZESehUB+eWsJxwcBQx7CKy0otuGMJTYh7qCVuUX23HkftGl/Q==", + "dev": true, + "dependencies": { + "@types/chai": "^4.3.5", + "@types/chai-subset": "^1.3.3", + "@types/node": "*", + "@vitest/expect": "0.32.0", + "@vitest/runner": "0.32.0", + "@vitest/snapshot": "0.32.0", + "@vitest/spy": "0.32.0", + "@vitest/utils": "0.32.0", + "acorn": "^8.8.2", + "acorn-walk": "^8.2.0", + "cac": "^6.7.14", + "chai": "^4.3.7", + "concordance": "^5.0.4", + "debug": "^4.3.4", + "local-pkg": "^0.4.3", + "magic-string": "^0.30.0", + "pathe": "^1.1.0", + "picocolors": "^1.0.0", + "std-env": "^3.3.2", + "strip-literal": "^1.0.1", + "tinybench": "^2.5.0", + "tinypool": "^0.5.0", + "vite": "^3.0.0 || ^4.0.0", + "vite-node": "0.32.0", + "why-is-node-running": "^2.2.2" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": ">=v14.18.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@vitest/browser": "*", + "@vitest/ui": "*", + "happy-dom": "*", + "jsdom": "*", + "playwright": "*", + "safaridriver": "*", + "webdriverio": "*" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@vitest/browser": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + }, + "playwright": { + "optional": true + }, + "safaridriver": { + "optional": true + }, + "webdriverio": { + "optional": true + } + } + }, + "node_modules/wcwidth": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", + "integrity": "sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==", + "dev": true, + "dependencies": { + "defaults": "^1.0.3" + } + }, + "node_modules/web-streams-polyfill": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz", + "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/webcrypto-core": { + "version": "1.7.7", + "resolved": "https://registry.npmjs.org/webcrypto-core/-/webcrypto-core-1.7.7.tgz", + "integrity": "sha512-7FjigXNsBfopEj+5DV2nhNpfic2vumtjjgPmeDKk45z+MJwXKKfhPB7118Pfzrmh4jqOMST6Ch37iPAHoImg5g==", + "dev": true, + "dependencies": { + "@peculiar/asn1-schema": "^2.3.6", + "@peculiar/json-schema": "^1.1.12", + "asn1js": "^3.0.1", + "pvtsutils": "^1.3.2", + "tslib": "^2.4.0" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "dev": true + }, + "node_modules/well-known-symbols": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/well-known-symbols/-/well-known-symbols-2.0.0.tgz", + "integrity": "sha512-ZMjC3ho+KXo0BfJb7JgtQ5IBuvnShdlACNkKkdsqBmYw3bPAaJfPeYUo6tLUaT5tG/Gkh7xkpBhKRQ9e7pyg9Q==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dev": true, + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/which-module": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", + "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==", + "dev": true + }, + "node_modules/why-is-node-running": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.2.2.tgz", + "integrity": "sha512-6tSwToZxTOcotxHeA+qGCq1mVzKR3CwcJGmVcY+QE8SHy6TnpFnh8PAvPNHYr7EcuVeG0QSMxtYCuO1ta/G/oA==", + "dev": true, + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/window-size": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.2.0.tgz", + "integrity": "sha512-UD7d8HFA2+PZsbKyaOCEy8gMh1oDtHgJh1LfgjQ4zVXmYjAT/kvz3PueITKuqDiIXQe7yzpPnxX3lNc+AhQMyw==", + "dev": true, + "bin": { + "window-size": "cli.js" + }, + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/wonka": { + "version": "6.3.2", + "resolved": "https://registry.npmjs.org/wonka/-/wonka-6.3.2.tgz", + "integrity": "sha512-2xXbQ1LnwNS7egVm1HPhW2FyKrekolzhpM3mCwXdQr55gO+tAiY76rhb32OL9kKsW8taj++iP7C6hxlVzbnvrw==", + "dev": true + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "node_modules/ws": { + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", + "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", + "dev": true, + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true + }, + "node_modules/yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, + "node_modules/yaml-ast-parser": { + "version": "0.0.43", + "resolved": "https://registry.npmjs.org/yaml-ast-parser/-/yaml-ast-parser-0.0.43.tgz", + "integrity": "sha512-2PTINUwsRqSd+s8XxKaJWQlUuEMHJQyEuh2edBbW8KNJz0SJPwUSD2zRWqezFEdN7IzAgeuYHFUCF7o8zRdZ0A==", + "dev": true + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/zen-observable": { + "version": "0.8.15", + "resolved": "https://registry.npmjs.org/zen-observable/-/zen-observable-0.8.15.tgz", + "integrity": "sha512-PQ2PC7R9rslx84ndNBZB/Dkv8V8fZEpk83RLgXtYd0fwUgEjseMn1Dgajh2x6S8QbZAFa9p2qVCEuYZNgve0dQ==", + "dev": true + }, + "node_modules/zen-observable-ts": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/zen-observable-ts/-/zen-observable-ts-1.2.5.tgz", + "integrity": "sha512-QZWQekv6iB72Naeake9hS1KxHlotfRpe+WGNbNx5/ta+R3DNjVO2bswf63gXlWDcs+EMd7XY8HfVQyP1X6T4Zg==", + "dev": true, + "dependencies": { + "zen-observable": "0.8.15" + } + } + } +} diff --git a/integration/package.json b/integration/package.json new file mode 100644 index 0000000..c2fde89 --- /dev/null +++ b/integration/package.json @@ -0,0 +1,25 @@ +{ + "name": "integration", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "test": "vitest", + "gen": "graphql-codegen --config codegen.ts" + }, + "devDependencies": { + "@apollo/client": "^3.7.14", + "@graphql-codegen/cli": "^4.0.0", + "@graphql-codegen/client-preset": "^4.0.0", + "@graphql-codegen/introspection": "^4.0.0", + "@graphql-codegen/schema-ast": "^4.0.0", + "graphql": "^16.6.0", + "graphql-codegen": "^0.4.0", + "graphql-sse": "^2.1.4", + "graphql-ws": "^5.13.1", + "typescript": "^5.0.2", + "urql": "^4.0.3", + "vite": "^4.3.9", + "vitest": "^0.32.0" + } +} diff --git a/integration/server/cmd/integration/server.go b/integration/server/cmd/integration/server.go new file mode 100644 index 0000000..b6ea72a --- /dev/null +++ b/integration/server/cmd/integration/server.go @@ -0,0 +1,72 @@ +package main + +import ( + "context" + "errors" + "log" + "net/http" + "os" + "time" + + "github.com/vektah/gqlparser/v2/gqlerror" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/graphql/handler/extension" + "github.com/niko0xdev/gqlgen/graphql/handler/lru" + "github.com/niko0xdev/gqlgen/graphql/handler/transport" + "github.com/niko0xdev/gqlgen/graphql/playground" + "github.com/niko0xdev/gqlgen/integration/server" +) + +const defaultPort = "8080" + +func main() { + port := os.Getenv("PORT") + if port == "" { + port = defaultPort + } + + cfg := server.Config{Resolvers: &server.Resolver{}} + cfg.Complexity.Query.Complexity = func(childComplexity, value int) int { + // Allow the integration client to dictate the complexity, to verify this + // function is executed. + return value + } + + srv := handler.New(server.NewExecutableSchema(cfg)) + + srv.AddTransport(transport.Websocket{ + KeepAlivePingInterval: 10 * time.Second, + }) + srv.AddTransport(transport.SSE{}) + srv.AddTransport(transport.Options{}) + srv.AddTransport(transport.GET{}) + srv.AddTransport(transport.POST{}) + srv.AddTransport(transport.MultipartForm{}) + + srv.SetQueryCache(lru.New(1000)) + + srv.Use(extension.Introspection{}) + srv.Use(extension.AutomaticPersistedQuery{ + Cache: lru.New(100), + }) + + srv.SetErrorPresenter(func(ctx context.Context, e error) *gqlerror.Error { + var ie *server.CustomError + if errors.As(e, &ie) { + return &gqlerror.Error{ + Message: ie.UserMessage, + Path: graphql.GetPath(ctx), + } + } + return graphql.DefaultErrorPresenter(ctx, e) + }) + srv.Use(extension.FixedComplexityLimit(1000)) + + http.Handle("/", playground.Handler("GraphQL playground", "/query")) + http.Handle("/query", srv) + + log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) + log.Fatal(http.ListenAndServe(":"+port, nil)) +} diff --git a/integration/server/generated.go b/integration/server/generated.go new file mode 100644 index 0000000..fe6b103 --- /dev/null +++ b/integration/server/generated.go @@ -0,0 +1,5038 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package server + +import ( + "bytes" + "context" + "embed" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + models "github.com/niko0xdev/gqlgen/integration/server/models-go" + "github.com/niko0xdev/gqlgen/integration/server/remote_api" + "github.com/niko0xdev/gqlgen/integration/server/testomitempty" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Element() ElementResolver + Query() QueryResolver + User() UserResolver +} + +type DirectiveRoot struct { + Magic func(ctx context.Context, obj interface{}, next graphql.Resolver, kind *int) (res interface{}, err error) +} + +type ComplexityRoot struct { + Element struct { + Child func(childComplexity int) int + Error func(childComplexity int) int + Mismatched func(childComplexity int) int + } + + Query struct { + Coercion func(childComplexity int, value []*models.ListCoercion) int + Complexity func(childComplexity int, value int) int + Date func(childComplexity int, filter models.DateFilter) int + Error func(childComplexity int, typeArg *models.ErrorType) int + JSONEncoding func(childComplexity int) int + Path func(childComplexity int) int + Viewer func(childComplexity int) int + } + + RemoteModelWithOmitempty struct { + Description func(childComplexity int) int + } + + User struct { + Likes func(childComplexity int) int + Name func(childComplexity int) int + PhoneNumber func(childComplexity int) int + Query func(childComplexity int) int + } + + Viewer struct { + User func(childComplexity int) int + } +} + +type ElementResolver interface { + Child(ctx context.Context, obj *models.Element) (*models.Element, error) + Error(ctx context.Context, obj *models.Element) (bool, error) + Mismatched(ctx context.Context, obj *models.Element) ([]bool, error) +} +type QueryResolver interface { + Path(ctx context.Context) ([]*models.Element, error) + Date(ctx context.Context, filter models.DateFilter) (bool, error) + Viewer(ctx context.Context) (*models.Viewer, error) + JSONEncoding(ctx context.Context) (string, error) + Error(ctx context.Context, typeArg *models.ErrorType) (bool, error) + Complexity(ctx context.Context, value int) (bool, error) + Coercion(ctx context.Context, value []*models.ListCoercion) (bool, error) +} +type UserResolver interface { + Likes(ctx context.Context, obj *remote_api.User) ([]string, error) +} + +type executableSchema struct { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = ec + switch typeName + "." + field { + + case "Element.child": + if e.complexity.Element.Child == nil { + break + } + + return e.complexity.Element.Child(childComplexity), true + + case "Element.error": + if e.complexity.Element.Error == nil { + break + } + + return e.complexity.Element.Error(childComplexity), true + + case "Element.mismatched": + if e.complexity.Element.Mismatched == nil { + break + } + + return e.complexity.Element.Mismatched(childComplexity), true + + case "Query.coercion": + if e.complexity.Query.Coercion == nil { + break + } + + args, err := ec.field_Query_coercion_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Coercion(childComplexity, args["value"].([]*models.ListCoercion)), true + + case "Query.complexity": + if e.complexity.Query.Complexity == nil { + break + } + + args, err := ec.field_Query_complexity_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Complexity(childComplexity, args["value"].(int)), true + + case "Query.date": + if e.complexity.Query.Date == nil { + break + } + + args, err := ec.field_Query_date_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Date(childComplexity, args["filter"].(models.DateFilter)), true + + case "Query.error": + if e.complexity.Query.Error == nil { + break + } + + args, err := ec.field_Query_error_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Error(childComplexity, args["type"].(*models.ErrorType)), true + + case "Query.jsonEncoding": + if e.complexity.Query.JSONEncoding == nil { + break + } + + return e.complexity.Query.JSONEncoding(childComplexity), true + + case "Query.path": + if e.complexity.Query.Path == nil { + break + } + + return e.complexity.Query.Path(childComplexity), true + + case "Query.viewer": + if e.complexity.Query.Viewer == nil { + break + } + + return e.complexity.Query.Viewer(childComplexity), true + + case "RemoteModelWithOmitempty.newDesc": + if e.complexity.RemoteModelWithOmitempty.Description == nil { + break + } + + return e.complexity.RemoteModelWithOmitempty.Description(childComplexity), true + + case "User.likes": + if e.complexity.User.Likes == nil { + break + } + + return e.complexity.User.Likes(childComplexity), true + + case "User.name": + if e.complexity.User.Name == nil { + break + } + + return e.complexity.User.Name(childComplexity), true + + case "User.phoneNumber": + if e.complexity.User.PhoneNumber == nil { + break + } + + return e.complexity.User.PhoneNumber(childComplexity), true + + case "User.query": + if e.complexity.User.Query == nil { + break + } + + return e.complexity.User.Query(childComplexity), true + + case "Viewer.user": + if e.complexity.Viewer.User == nil { + break + } + + return e.complexity.Viewer.User(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap( + ec.unmarshalInputDateFilter, + ec.unmarshalInputListCoercion, + ) + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } +} + +type executionContext struct { + *graphql.OperationContext + *executableSchema + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + +//go:embed "schema/schema.graphql" "schema/testomitempty.graphql" "schema/user.graphql" +var sourcesFS embed.FS + +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) +} + +var sources = []*ast.Source{ + {Name: "schema/schema.graphql", Input: sourceData("schema/schema.graphql"), BuiltIn: false}, + {Name: "schema/testomitempty.graphql", Input: sourceData("schema/testomitempty.graphql"), BuiltIn: false}, + {Name: "schema/user.graphql", Input: sourceData("schema/user.graphql"), BuiltIn: false}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (ec *executionContext) dir_magic_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["kind"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("kind")) + arg0, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["kind"] = arg0 + return args, nil +} + +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_coercion_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 []*models.ListCoercion + if tmp, ok := rawArgs["value"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("value")) + arg0, err = ec.unmarshalOListCoercion2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐListCoercionᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["value"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_complexity_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["value"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("value")) + arg0, err = ec.unmarshalNInt2int(ctx, tmp) + if err != nil { + return nil, err + } + } + args["value"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_date_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 models.DateFilter + if tmp, ok := rawArgs["filter"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) + arg0, err = ec.unmarshalNDateFilter2githubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐDateFilter(ctx, tmp) + if err != nil { + return nil, err + } + } + args["filter"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_error_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 *models.ErrorType + if tmp, ok := rawArgs["type"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("type")) + arg0, err = ec.unmarshalOErrorType2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐErrorType(ctx, tmp) + if err != nil { + return nil, err + } + } + args["type"] = arg0 + return args, nil +} + +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) _Element_child(ctx context.Context, field graphql.CollectedField, obj *models.Element) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Element_child(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Element().Child(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.(*models.Element) + fc.Result = res + return ec.marshalNElement2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐElement(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Element_child(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Element", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "child": + return ec.fieldContext_Element_child(ctx, field) + case "error": + return ec.fieldContext_Element_error(ctx, field) + case "mismatched": + return ec.fieldContext_Element_mismatched(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Element", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Element_error(ctx context.Context, field graphql.CollectedField, obj *models.Element) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Element_error(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Element().Error(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.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Element_error(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Element", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Element_mismatched(ctx context.Context, field graphql.CollectedField, obj *models.Element) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Element_mismatched(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Element().Mismatched(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]bool) + fc.Result = res + return ec.marshalOBoolean2ᚕboolᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Element_mismatched(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Element", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_path(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_path(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Path(rctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*models.Element) + fc.Result = res + return ec.marshalOElement2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐElement(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_path(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "child": + return ec.fieldContext_Element_child(ctx, field) + case "error": + return ec.fieldContext_Element_error(ctx, field) + case "mismatched": + return ec.fieldContext_Element_mismatched(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Element", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_date(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_date(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Date(rctx, fc.Args["filter"].(models.DateFilter)) + }) + 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) fieldContext_Query_date(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_date_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_viewer(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_viewer(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Viewer(rctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*models.Viewer) + fc.Result = res + return ec.marshalOViewer2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐViewer(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_viewer(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "user": + return ec.fieldContext_Viewer_user(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Viewer", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_jsonEncoding(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_jsonEncoding(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().JSONEncoding(rctx) + }) + 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) fieldContext_Query_jsonEncoding(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_error(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_error(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Error(rctx, fc.Args["type"].(*models.ErrorType)) + }) + 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) fieldContext_Query_error(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_error_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_complexity(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_complexity(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Complexity(rctx, fc.Args["value"].(int)) + }) + 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) fieldContext_Query_complexity(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_complexity_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_coercion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_coercion(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Coercion(rctx, fc.Args["value"].([]*models.ListCoercion)) + }) + 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) fieldContext_Query_coercion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_coercion_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _RemoteModelWithOmitempty_newDesc(ctx context.Context, field graphql.CollectedField, obj *testomitempty.RemoteModelWithOmitempty) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_RemoteModelWithOmitempty_newDesc(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalOString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_RemoteModelWithOmitempty_newDesc(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "RemoteModelWithOmitempty", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *remote_api.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_User_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_likes(ctx context.Context, field graphql.CollectedField, obj *remote_api.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_likes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.User().Likes(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.marshalNString2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_likes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_phoneNumber(ctx context.Context, field graphql.CollectedField, obj *remote_api.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_phoneNumber(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PhoneNumber, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalOString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_phoneNumber(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_query(ctx context.Context, field graphql.CollectedField, obj *remote_api.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_query(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + res := models.Query{} + fc.Result = res + return ec.marshalNQuery2githubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐQuery(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_query(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "path": + return ec.fieldContext_Query_path(ctx, field) + case "date": + return ec.fieldContext_Query_date(ctx, field) + case "viewer": + return ec.fieldContext_Query_viewer(ctx, field) + case "jsonEncoding": + return ec.fieldContext_Query_jsonEncoding(ctx, field) + case "error": + return ec.fieldContext_Query_error(ctx, field) + case "complexity": + return ec.fieldContext_Query_complexity(ctx, field) + case "coercion": + return ec.fieldContext_Query_coercion(ctx, field) + case "__schema": + return ec.fieldContext_Query___schema(ctx, field) + case "__type": + return ec.fieldContext_Query___type(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Query", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Viewer_user(ctx context.Context, field graphql.CollectedField, obj *models.Viewer) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Viewer_user(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.User, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*remote_api.User) + fc.Result = res + return ec.marshalOUser2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋremote_apiᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Viewer_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Viewer", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_User_name(ctx, field) + case "likes": + return ec.fieldContext_User_likes(ctx, field) + case "phoneNumber": + return ec.fieldContext_User_phoneNumber(ctx, field) + case "query": + return ec.fieldContext_User_query(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), 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.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), 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.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), 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.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputDateFilter(ctx context.Context, obj interface{}) (models.DateFilter, error) { + var it models.DateFilter + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + if _, present := asMap["timezone"]; !present { + asMap["timezone"] = "UTC" + } + if _, present := asMap["op"]; !present { + asMap["op"] = "EQ" + } + + fieldsInOrder := [...]string{"value", "timezone", "op"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "value": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("value")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Value = data + case "timezone": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("timezone")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Timezone = data + case "op": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("op")) + data, err := ec.unmarshalODATE_FILTER_OP2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐDateFilterOp(ctx, v) + if err != nil { + return it, err + } + it.Op = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputListCoercion(ctx context.Context, obj interface{}) (models.ListCoercion, error) { + var it models.ListCoercion + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"enumVal", "strVal", "intVal", "scalarVal"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "enumVal": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("enumVal")) + data, err := ec.unmarshalOErrorType2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐErrorType(ctx, v) + if err != nil { + return it, err + } + it.EnumVal = data + case "strVal": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("strVal")) + data, err := ec.unmarshalOString2ᚕᚖstring(ctx, v) + if err != nil { + return it, err + } + it.StrVal = data + case "intVal": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intVal")) + data, err := ec.unmarshalOInt2ᚕᚖint(ctx, v) + if err != nil { + return it, err + } + it.IntVal = data + case "scalarVal": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("scalarVal")) + data, err := ec.unmarshalOMap2ᚕmap(ctx, v) + if err != nil { + return it, err + } + it.ScalarVal = data + } + } + + return it, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var elementImplementors = []string{"Element"} + +func (ec *executionContext) _Element(ctx context.Context, sel ast.SelectionSet, obj *models.Element) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, elementImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Element") + case "child": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Element_child(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "error": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Element_error(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "mismatched": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Element_mismatched(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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 "path": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_path(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "date": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_date(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "viewer": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_viewer(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "jsonEncoding": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_jsonEncoding(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "error": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_error(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "complexity": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_complexity(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "coercion": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_coercion(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var remoteModelWithOmitemptyImplementors = []string{"RemoteModelWithOmitempty"} + +func (ec *executionContext) _RemoteModelWithOmitempty(ctx context.Context, sel ast.SelectionSet, obj *testomitempty.RemoteModelWithOmitempty) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, remoteModelWithOmitemptyImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("RemoteModelWithOmitempty") + case "newDesc": + out.Values[i] = ec._RemoteModelWithOmitempty_newDesc(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var userImplementors = []string{"User"} + +func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *remote_api.User) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("User") + case "name": + out.Values[i] = ec._User_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "likes": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._User_likes(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "phoneNumber": + out.Values[i] = ec._User_phoneNumber(ctx, field, obj) + case "query": + out.Values[i] = ec._User_query(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var viewerImplementors = []string{"Viewer"} + +func (ec *executionContext) _Viewer(ctx context.Context, sel ast.SelectionSet, obj *models.Viewer) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, viewerImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Viewer") + case "user": + out.Values[i] = ec._Viewer_user(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNDateFilter2githubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐDateFilter(ctx context.Context, v interface{}) (models.DateFilter, error) { + res, err := ec.unmarshalInputDateFilter(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNElement2githubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐElement(ctx context.Context, sel ast.SelectionSet, v models.Element) graphql.Marshaler { + return ec._Element(ctx, sel, &v) +} + +func (ec *executionContext) marshalNElement2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐElement(ctx context.Context, sel ast.SelectionSet, v *models.Element) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Element(ctx, sel, v) +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNListCoercion2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐListCoercion(ctx context.Context, v interface{}) (*models.ListCoercion, error) { + res, err := ec.unmarshalInputListCoercion(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNQuery2githubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐQuery(ctx context.Context, sel ast.SelectionSet, v models.Query) graphql.Marshaler { + return ec._Query(ctx, sel) +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + 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 + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]bool, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNBoolean2bool(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalOBoolean2ᚕboolᚄ(ctx context.Context, sel ast.SelectionSet, v []bool) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNBoolean2bool(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +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) unmarshalODATE_FILTER_OP2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐDateFilterOp(ctx context.Context, v interface{}) (*models.DateFilterOp, error) { + if v == nil { + return nil, nil + } + var res = new(models.DateFilterOp) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalODATE_FILTER_OP2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐDateFilterOp(ctx context.Context, sel ast.SelectionSet, v *models.DateFilterOp) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) marshalOElement2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐElement(ctx context.Context, sel ast.SelectionSet, v []*models.Element) 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.marshalOElement2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐElement(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) marshalOElement2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐElement(ctx context.Context, sel ast.SelectionSet, v *models.Element) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Element(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOErrorType2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐErrorType(ctx context.Context, v interface{}) ([]*models.ErrorType, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*models.ErrorType, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalOErrorType2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐErrorType(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalOErrorType2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐErrorType(ctx context.Context, sel ast.SelectionSet, v []*models.ErrorType) 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.marshalOErrorType2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐErrorType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) unmarshalOErrorType2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐErrorType(ctx context.Context, v interface{}) (*models.ErrorType, error) { + if v == nil { + return nil, nil + } + var res = new(models.ErrorType) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOErrorType2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐErrorType(ctx context.Context, sel ast.SelectionSet, v *models.ErrorType) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalOInt2ᚕᚖint(ctx context.Context, v interface{}) ([]*int, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*int, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalOInt2ᚖint(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalOInt2ᚕᚖint(ctx context.Context, sel ast.SelectionSet, v []*int) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalOInt2ᚖint(ctx, sel, v[i]) + } + + return ret +} + +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) unmarshalOListCoercion2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐListCoercionᚄ(ctx context.Context, v interface{}) ([]*models.ListCoercion, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*models.ListCoercion, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNListCoercion2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐListCoercion(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOMap2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalMap(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOMap2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := graphql.MarshalMap(v) + return res +} + +func (ec *executionContext) unmarshalOMap2ᚕmap(ctx context.Context, v interface{}) ([]map[string]interface{}, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]map[string]interface{}, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalOMap2map(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalOMap2ᚕmap(ctx context.Context, sel ast.SelectionSet, v []map[string]interface{}) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalOMap2map(ctx, sel, v[i]) + } + + return ret +} + +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 { + vSlice = graphql.CoerceList(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) marshalOUser2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋremote_apiᚐUser(ctx context.Context, sel ast.SelectionSet, v *remote_api.User) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._User(ctx, sel, v) +} + +func (ec *executionContext) marshalOViewer2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐViewer(ctx context.Context, sel ast.SelectionSet, v *models.Viewer) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Viewer(ctx, sel, v) +} + +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/integration/server/gqlgen.yml b/integration/server/gqlgen.yml new file mode 100644 index 0000000..e90ae05 --- /dev/null +++ b/integration/server/gqlgen.yml @@ -0,0 +1,26 @@ +schema: + - schema/**/*.graphql + +exec: + filename: generated.go +model: + filename: models-go/generated.go +resolver: + filename: resolver.go + type: Resolver + +struct_tag: json + +autobind: + - "github.com/niko0xdev/gqlgen/integration/server/testomitempty" + +models: + Element: + model: github.com/niko0xdev/gqlgen/integration/server/models-go.Element + Viewer: + model: github.com/niko0xdev/gqlgen/integration/server/models-go.Viewer + User: + model: github.com/niko0xdev/gqlgen/integration/server/remote_api.User + fields: + likes: + resolver: true diff --git a/integration/server/models-go/element.go b/integration/server/models-go/element.go new file mode 100644 index 0000000..de64deb --- /dev/null +++ b/integration/server/models-go/element.go @@ -0,0 +1,9 @@ +package models + +type Element struct { + ID int +} + +func (e *Element) Mismatched() []Element { + return []Element{*e} +} diff --git a/integration/server/models-go/generated.go b/integration/server/models-go/generated.go new file mode 100644 index 0000000..54fa635 --- /dev/null +++ b/integration/server/models-go/generated.go @@ -0,0 +1,115 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package models + +import ( + "fmt" + "io" + "strconv" +) + +type DateFilter struct { + Value string `json:"value"` + Timezone *string `json:"timezone,omitempty"` + Op *DateFilterOp `json:"op,omitempty"` +} + +type ListCoercion struct { + EnumVal []*ErrorType `json:"enumVal,omitempty"` + StrVal []*string `json:"strVal,omitempty"` + IntVal []*int `json:"intVal,omitempty"` + ScalarVal []map[string]interface{} `json:"scalarVal,omitempty"` +} + +type Query struct { +} + +type DateFilterOp string + +const ( + DateFilterOpEq DateFilterOp = "EQ" + DateFilterOpNeq DateFilterOp = "NEQ" + DateFilterOpGt DateFilterOp = "GT" + DateFilterOpGte DateFilterOp = "GTE" + DateFilterOpLt DateFilterOp = "LT" + DateFilterOpLte DateFilterOp = "LTE" +) + +var AllDateFilterOp = []DateFilterOp{ + DateFilterOpEq, + DateFilterOpNeq, + DateFilterOpGt, + DateFilterOpGte, + DateFilterOpLt, + DateFilterOpLte, +} + +func (e DateFilterOp) IsValid() bool { + switch e { + case DateFilterOpEq, DateFilterOpNeq, DateFilterOpGt, DateFilterOpGte, DateFilterOpLt, DateFilterOpLte: + return true + } + return false +} + +func (e DateFilterOp) String() string { + return string(e) +} + +func (e *DateFilterOp) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = DateFilterOp(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid DATE_FILTER_OP", str) + } + return nil +} + +func (e DateFilterOp) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +type ErrorType string + +const ( + ErrorTypeCustom ErrorType = "CUSTOM" + ErrorTypeNormal ErrorType = "NORMAL" +) + +var AllErrorType = []ErrorType{ + ErrorTypeCustom, + ErrorTypeNormal, +} + +func (e ErrorType) IsValid() bool { + switch e { + case ErrorTypeCustom, ErrorTypeNormal: + return true + } + return false +} + +func (e ErrorType) String() string { + return string(e) +} + +func (e *ErrorType) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = ErrorType(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid ErrorType", str) + } + return nil +} + +func (e ErrorType) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} diff --git a/integration/server/models-go/viewer.go b/integration/server/models-go/viewer.go new file mode 100644 index 0000000..ae8820e --- /dev/null +++ b/integration/server/models-go/viewer.go @@ -0,0 +1,7 @@ +package models + +import "github.com/niko0xdev/gqlgen/integration/server/remote_api" + +type Viewer struct { + User *remote_api.User +} diff --git a/integration/server/remote_api/user.go b/integration/server/remote_api/user.go new file mode 100644 index 0000000..feefded --- /dev/null +++ b/integration/server/remote_api/user.go @@ -0,0 +1,7 @@ +package remote_api + +type User struct { + Name string + Likes []string + PhoneNumber string +} diff --git a/integration/server/resolver.go b/integration/server/resolver.go new file mode 100644 index 0000000..9a1d8f5 --- /dev/null +++ b/integration/server/resolver.go @@ -0,0 +1,106 @@ +//go:generate go run ../../testdata/gqlgen.go + +package server + +import ( + "context" + "fmt" + "time" + + models "github.com/niko0xdev/gqlgen/integration/server/models-go" + "github.com/niko0xdev/gqlgen/integration/server/remote_api" +) + +type CustomError struct { + UserMessage string + InternalError string +} + +func (e *CustomError) Error() string { + return e.InternalError +} + +type Resolver struct{} + +func (r *Resolver) User() UserResolver { + return &userResolver{r} +} + +func (r *Resolver) Element() ElementResolver { + return &elementResolver{r} +} + +func (r *Resolver) Query() QueryResolver { + return &queryResolver{r} +} + +type elementResolver struct{ *Resolver } + +func (r *elementResolver) Error(ctx context.Context, obj *models.Element) (bool, error) { + // A silly hack to make the result order stable + time.Sleep(time.Duration(obj.ID) * 10 * time.Millisecond) + + return false, fmt.Errorf("boom") +} + +func (r *elementResolver) Mismatched(ctx context.Context, obj *models.Element) ([]bool, error) { + return []bool{true}, nil +} + +func (r *elementResolver) Child(ctx context.Context, obj *models.Element) (*models.Element, error) { + return &models.Element{ID: obj.ID * 10}, nil +} + +type queryResolver struct{ *Resolver } + +func (r *queryResolver) Error(ctx context.Context, typeArg *models.ErrorType) (bool, error) { + if *typeArg == models.ErrorTypeCustom { + return false, &CustomError{"User message", "Internal Message"} + } + + return false, fmt.Errorf("normal error") +} + +func (r *queryResolver) Path(ctx context.Context) ([]*models.Element, error) { + return []*models.Element{{ID: 1}, {ID: 2}, {ID: 3}, {ID: 4}}, nil +} + +func (r *queryResolver) Coercion(ctx context.Context, input []*models.ListCoercion) (bool, error) { + return true, nil +} + +func (r *queryResolver) Date(ctx context.Context, filter models.DateFilter) (bool, error) { + if filter.Value != "asdf" { + return false, fmt.Errorf("value must be asdf") + } + + if *filter.Timezone != "UTC" { + return false, fmt.Errorf("timezone must be utc") + } + + if *filter.Op != models.DateFilterOpEq { + return false, fmt.Errorf("unknown op %s", *filter.Op) + } + + return true, nil +} + +func (r *queryResolver) Viewer(ctx context.Context) (*models.Viewer, error) { + return &models.Viewer{ + User: &remote_api.User{Name: "Bob", Likes: []string{"Alice"}, PhoneNumber: "1234567890"}, + }, nil +} + +func (r *queryResolver) JSONEncoding(ctx context.Context) (string, error) { + return "\U000fe4ed", nil +} + +func (r *queryResolver) Complexity(ctx context.Context, value int) (bool, error) { + return true, nil +} + +type userResolver struct{ *Resolver } + +func (r *userResolver) Likes(ctx context.Context, obj *remote_api.User) ([]string, error) { + return obj.Likes, nil +} diff --git a/integration/server/schema/schema.graphql b/integration/server/schema/schema.graphql new file mode 100644 index 0000000..0b5a39e --- /dev/null +++ b/integration/server/schema/schema.graphql @@ -0,0 +1,56 @@ +"This directive does magical things" +directive @magic(kind: Int) on FIELD_DEFINITION + +scalar Map + +type Element { + child: Element! + error: Boolean! + mismatched: [Boolean!] +} + +enum DATE_FILTER_OP { + # multi + # line + # comment + EQ + NEQ + GT + GTE + LT + LTE +} + +input DateFilter { + value: String! + timezone: String = "UTC" + op: DATE_FILTER_OP = EQ +} + +type Viewer { + user: User +} + +input ListCoercion { + enumVal: [ErrorType] + strVal: [String] + intVal: [Int] + scalarVal: [Map] +} + +type Query { + path: [Element] + date(filter: DateFilter!): Boolean! + viewer: Viewer + jsonEncoding: String! + error(type: ErrorType = NORMAL): Boolean! + complexity(value: Int!): Boolean! + coercion(value: [ListCoercion!]): Boolean! +} + +enum ErrorType { + CUSTOM + NORMAL +} + +# this is a comment with a `backtick` diff --git a/integration/server/schema/testomitempty.graphql b/integration/server/schema/testomitempty.graphql new file mode 100644 index 0000000..7a9285a --- /dev/null +++ b/integration/server/schema/testomitempty.graphql @@ -0,0 +1,3 @@ +type RemoteModelWithOmitempty { + newDesc: String +} diff --git a/integration/server/schema/user.graphql b/integration/server/schema/user.graphql new file mode 100644 index 0000000..8387e18 --- /dev/null +++ b/integration/server/schema/user.graphql @@ -0,0 +1,6 @@ +type User { + name: String! + likes: [String!]! + phoneNumber: String @deprecated + query: Query! +} diff --git a/integration/server/testomitempty/testmodel.go b/integration/server/testomitempty/testmodel.go new file mode 100644 index 0000000..a712165 --- /dev/null +++ b/integration/server/testomitempty/testmodel.go @@ -0,0 +1,5 @@ +package testomitempty + +type RemoteModelWithOmitempty struct { + Description string `json:"newDesc,omitempty"` +} diff --git a/integration/src/__test__/integration.spec.ts b/integration/src/__test__/integration.spec.ts new file mode 100644 index 0000000..06cc99b --- /dev/null +++ b/integration/src/__test__/integration.spec.ts @@ -0,0 +1,419 @@ +import { afterAll, describe, expect, it } from "vitest"; +import { + ApolloClient, + ApolloLink, + FetchResult, + HttpLink, + InMemoryCache, + NormalizedCacheObject, + Observable, + Operation, +} from "@apollo/client/core"; +import { print } from "graphql"; +import { GraphQLWsLink } from "@apollo/client/link/subscriptions"; +import { WebSocket } from "ws"; +import { createClient as createClientWS } from "graphql-ws"; +import { + Client as ClientSSE, + ClientOptions as ClientOptionsSSE, + createClient as createClientSSE, +} from "graphql-sse"; +import { + CoercionDocument, + ComplexityDocument, + DateDocument, + ErrorDocument, + ErrorType, + JsonEncodingDocument, + PathDocument, + UserFragmentFragmentDoc, + ViewerDocument, +} from "../generated/graphql.ts"; +import { + cacheExchange, + Client, + dedupExchange, + subscriptionExchange, +} from "urql"; +import { isFragmentReady, useFragment } from "../generated"; +import { readFileSync } from "fs"; +import { join } from "path"; + +const uri = process.env.VITE_SERVER_URL || "http://localhost:8080/query"; + +function test(client: ApolloClient<NormalizedCacheObject>) { + describe("Json", () => { + it("should follow json escaping rules", async () => { + const res = await client.query({ + query: JsonEncodingDocument, + }); + + expect(res.data.jsonEncoding).toBe("󾓭"); + expect(res.errors).toBe(undefined); + + return null; + }); + }); + + describe("Input defaults", () => { + it("should pass default values to resolver", async () => { + const res = await client.query({ + query: DateDocument, + variables: { + filter: { + value: "asdf", + }, + }, + }); + + expect(res.data.date).toBe(true); + expect(res.errors).toBe(undefined); + return null; + }); + }); + + describe("Complexity", () => { + it("should fail when complexity is too high", async () => { + const res = await client.query({ + query: ComplexityDocument, + variables: { + value: 2000, + }, + }); + + expect(res.errors).toBeDefined(); + if (res.errors) { + expect(res.errors[0].message).toBe( + "operation has complexity 2000, which exceeds the limit of 1000" + ); + } + return null; + }); + + it("should succeed when complexity is not too high", async () => { + const res = await client.query({ + query: ComplexityDocument, + variables: { + value: 1000, + }, + }); + + expect(res.data.complexity).toBe(true); + expect(res.errors).toBe(undefined); + return null; + }); + }); + + describe("List Coercion", () => { + it("should succeed when nested single values are passed", async () => { + const res = await client.query({ + query: CoercionDocument, + variables: { + value: { + enumVal: ErrorType.Custom, + strVal: "test", + intVal: 1, + }, + }, + }); + + expect(res.data.coercion).toBe(true); + return null; + }); + + it("should succeed when nested array of values are passed", async () => { + const res = await client.query({ + query: CoercionDocument, + variables: { + value: { + enumVal: [ErrorType.Custom], + strVal: ["test"], + intVal: [1], + }, + }, + }); + + expect(res.data.coercion).toBe(true); + return null; + }); + + it("should succeed when single value is passed", async () => { + const res = await client.query({ + query: CoercionDocument, + variables: { + value: { + enumVal: ErrorType.Custom, + }, + }, + }); + + expect(res.data.coercion).toBe(true); + return null; + }); + + it("should succeed when single scalar value is passed", async () => { + const res = await client.query({ + query: CoercionDocument, + variables: { + value: [ + { + scalarVal: { + key: "someValue", + }, + }, + ], + }, + }); + + expect(res.data.coercion).toBe(true); + return null; + }); + + it("should succeed when multiple values are passed", async () => { + const res = await client.query({ + query: CoercionDocument, + variables: { + value: [ + { + enumVal: [ErrorType.Custom, ErrorType.Normal], + }, + ], + }, + }); + + expect(res.data.coercion).toBe(true); + return null; + }); + }); + + describe("Errors", () => { + it("should respond with correct paths", async () => { + const res = await client.query({ + query: PathDocument, + }); + + expect(res.errors).toBeDefined(); + if (res.errors) { + expect(res.errors[0].path).toEqual(["path", 0, "cc", "error"]); + expect(res.errors[1].path).toEqual(["path", 1, "cc", "error"]); + expect(res.errors[2].path).toEqual(["path", 2, "cc", "error"]); + expect(res.errors[3].path).toEqual(["path", 3, "cc", "error"]); + } + return null; + }); + + it("should use the error presenter for custom errors", async () => { + let res = await client.query({ + query: ErrorDocument, + variables: { + type: ErrorType.Custom, + }, + }); + + expect(res.errors).toBeDefined(); + if (res.errors) { + expect(res.errors[0].message).toEqual("User message"); + } + return null; + }); + + it("should pass through for other errors", async () => { + const res = await client.query({ + query: ErrorDocument, + variables: { + type: ErrorType.Normal, + }, + }); + + expect(res.errors).toBeDefined(); + if (res.errors) { + expect(res.errors[0]?.message).toEqual("normal error"); + } + return null; + }); + }); +} + +describe("HTTP client", () => { + const client = new ApolloClient({ + link: new HttpLink({ + uri, + fetch, + }), + cache: new InMemoryCache(), + defaultOptions: { + watchQuery: { + fetchPolicy: "network-only", + errorPolicy: "ignore", + }, + query: { + fetchPolicy: "network-only", + errorPolicy: "all", + }, + }, + }); + + test(client); + + afterAll(() => { + client.stop(); + }); +}); + +describe("Schema Introspection", () => { + const schemaJson = readFileSync( + join(__dirname, "../generated/schema-introspection.json"), + "utf-8" + ); + const schema = JSON.parse(schemaJson); + + it("User.phoneNumber is deprecated and deprecationReason has the default value: `No longer supported`", async () => { + const userType = schema.__schema.types.find( + (type: any) => type.name === "User" + ); + + expect(userType).toBeDefined(); + + const phoneNumberField = userType.fields.find( + (field: any) => field.name === "phoneNumber" + ); + expect(phoneNumberField).toBeDefined(); + + expect(phoneNumberField.isDeprecated).toBe(true); + expect(phoneNumberField.deprecationReason).toBe("No longer supported"); + }); +}); + +describe("Websocket client", () => { + const client = new ApolloClient({ + link: new GraphQLWsLink( + createClientWS({ + url: uri + .replace("http://", "ws://") + .replace("https://", "wss://"), + webSocketImpl: WebSocket, + }) + ), + cache: new InMemoryCache(), + defaultOptions: { + watchQuery: { + fetchPolicy: "network-only", + errorPolicy: "ignore", + }, + query: { + fetchPolicy: "network-only", + errorPolicy: "all", + }, + }, + }); + + test(client); + + afterAll(() => { + client.stop(); + }); +}); + +describe("SSE client", () => { + class SSELink extends ApolloLink { + private client: ClientSSE; + + constructor(options: ClientOptionsSSE) { + super(); + this.client = createClientSSE(options); + } + + public request(operation: Operation): Observable<FetchResult> { + return new Observable((sink) => { + return this.client.subscribe<FetchResult>( + { ...operation, query: print(operation.query) }, + { + next: sink.next.bind(sink), + complete: sink.complete.bind(sink), + error: sink.error.bind(sink), + } + ); + }); + } + } + + const client = new ApolloClient({ + link: new SSELink({ + url: uri, + }), + cache: new InMemoryCache(), + defaultOptions: { + watchQuery: { + fetchPolicy: "network-only", + errorPolicy: "ignore", + }, + query: { + fetchPolicy: "network-only", + errorPolicy: "all", + }, + }, + }); + + test(client); + + afterAll(() => { + client.stop(); + }); +}); + +describe("URQL SSE client", () => { + const wsClient = createClientWS({ + url: uri.replace("http://", "ws://").replace("https://", "wss://"), + webSocketImpl: WebSocket, + }); + + const client = new Client({ + url: uri, + exchanges: [ + dedupExchange, + cacheExchange, + subscriptionExchange({ + enableAllOperations: true, + forwardSubscription(request) { + const input = { ...request, query: request.query || "" }; + return { + subscribe(sink) { + const unsubscribe = wsClient.subscribe(input, sink); + return { unsubscribe }; + }, + }; + }, + }), + ], + }); + + describe("Defer", () => { + it("test using defer", async () => { + const res = await client.query(ViewerDocument, {}); + + expect(res.error).toBe(undefined); + expect(res.data).toBeDefined(); + expect(res.data?.viewer).toBeDefined(); + expect(res.data?.viewer?.user).toBeDefined(); + expect(res.data?.viewer?.user?.name).toBe("Bob"); + expect(res.data?.viewer?.user?.query?.jsonEncoding).toBe("󾓭"); + let ready: boolean; + if ( + (ready = isFragmentReady( + ViewerDocument, + UserFragmentFragmentDoc, + res.data?.viewer?.user + )) + ) { + const userFragment = useFragment( + UserFragmentFragmentDoc, + res.data?.viewer?.user + ); + expect(userFragment).toBeDefined(); + expect(userFragment?.likes).toStrictEqual(["Alice"]); + } + expect(ready).toBeTruthy(); + return null; + }); + }); +}); diff --git a/integration/src/generated/.gitignore b/integration/src/generated/.gitignore new file mode 100644 index 0000000..4ccb0c3 --- /dev/null +++ b/integration/src/generated/.gitignore @@ -0,0 +1,2 @@ +schema-fetched.graphql +schema-introspection.json diff --git a/integration/src/generated/fragment-masking.ts b/integration/src/generated/fragment-masking.ts new file mode 100644 index 0000000..2ba06f1 --- /dev/null +++ b/integration/src/generated/fragment-masking.ts @@ -0,0 +1,66 @@ +import { ResultOf, DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core'; +import { FragmentDefinitionNode } from 'graphql'; +import { Incremental } from './graphql'; + + +export type FragmentType<TDocumentType extends DocumentTypeDecoration<any, any>> = TDocumentType extends DocumentTypeDecoration< + infer TType, + any +> + ? [TType] extends [{ ' $fragmentName'?: infer TKey }] + ? TKey extends string + ? { ' $fragmentRefs'?: { [key in TKey]: TType } } + : never + : never + : never; + +// return non-nullable if `fragmentType` is non-nullable +export function useFragment<TType>( + _documentNode: DocumentTypeDecoration<TType, any>, + fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> +): TType; +// return nullable if `fragmentType` is nullable +export function useFragment<TType>( + _documentNode: DocumentTypeDecoration<TType, any>, + fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null | undefined +): TType | null | undefined; +// return array of non-nullable if `fragmentType` is array of non-nullable +export function useFragment<TType>( + _documentNode: DocumentTypeDecoration<TType, any>, + fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> +): ReadonlyArray<TType>; +// return array of nullable if `fragmentType` is array of nullable +export function useFragment<TType>( + _documentNode: DocumentTypeDecoration<TType, any>, + fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined +): ReadonlyArray<TType> | null | undefined; +export function useFragment<TType>( + _documentNode: DocumentTypeDecoration<TType, any>, + fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined +): TType | ReadonlyArray<TType> | null | undefined { + return fragmentType as any; +} + + +export function makeFragmentData< + F extends DocumentTypeDecoration<any, any>, + FT extends ResultOf<F> +>(data: FT, _fragment: F): FragmentType<F> { + return data as FragmentType<F>; +} +export function isFragmentReady<TQuery, TFrag>( + queryNode: DocumentTypeDecoration<TQuery, any>, + fragmentNode: TypedDocumentNode<TFrag>, + data: FragmentType<TypedDocumentNode<Incremental<TFrag>, any>> | null | undefined +): data is FragmentType<typeof fragmentNode> { + const deferredFields = (queryNode as { __meta__?: { deferredFields: Record<string, (keyof TFrag)[]> } }).__meta__ + ?.deferredFields; + + if (!deferredFields) return true; + + const fragDef = fragmentNode.definitions[0] as FragmentDefinitionNode | undefined; + const fragName = fragDef?.name?.value; + + const fields = (fragName && deferredFields[fragName]) || []; + return fields.length > 0 && fields.every(field => data && field in data); +} diff --git a/integration/src/generated/gql.ts b/integration/src/generated/gql.ts new file mode 100644 index 0000000..3fc1b81 --- /dev/null +++ b/integration/src/generated/gql.ts @@ -0,0 +1,72 @@ +/* eslint-disable */ +import * as types from './graphql'; +import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; + +/** + * Map of all GraphQL operations in the project. + * + * This map has several performance disadvantages: + * 1. It is not tree-shakeable, so it will include all operations in the project. + * 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle. + * 3. It does not support dead code elimination, so it will add unused operations. + * + * Therefore it is highly recommended to use the babel or swc plugin for production. + */ +const documents = { + "query coercion($value: [ListCoercion!]) {\n coercion(value: $value)\n}": types.CoercionDocument, + "query complexity($value: Int!) {\n complexity(value: $value)\n}": types.ComplexityDocument, + "query date($filter: DateFilter!) {\n date(filter: $filter)\n}": types.DateDocument, + "query error($type: ErrorType) {\n error(type: $type)\n}": types.ErrorDocument, + "query jsonEncoding {\n jsonEncoding\n}": types.JsonEncodingDocument, + "query path {\n path {\n cc: child {\n error\n }\n }\n}": types.PathDocument, + "query viewer {\n viewer {\n user {\n name\n phoneNumber\n query {\n jsonEncoding\n }\n ...userFragment @defer\n }\n }\n}\n\nfragment userFragment on User {\n likes\n}": types.ViewerDocument, +}; + +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + * + * + * @example + * ```ts + * const query = graphql(`query GetUser($id: ID!) { user(id: $id) { name } }`); + * ``` + * + * The query argument is unknown! + * Please regenerate the types. + */ +export function graphql(source: string): unknown; + +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function graphql(source: "query coercion($value: [ListCoercion!]) {\n coercion(value: $value)\n}"): (typeof documents)["query coercion($value: [ListCoercion!]) {\n coercion(value: $value)\n}"]; +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function graphql(source: "query complexity($value: Int!) {\n complexity(value: $value)\n}"): (typeof documents)["query complexity($value: Int!) {\n complexity(value: $value)\n}"]; +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function graphql(source: "query date($filter: DateFilter!) {\n date(filter: $filter)\n}"): (typeof documents)["query date($filter: DateFilter!) {\n date(filter: $filter)\n}"]; +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function graphql(source: "query error($type: ErrorType) {\n error(type: $type)\n}"): (typeof documents)["query error($type: ErrorType) {\n error(type: $type)\n}"]; +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function graphql(source: "query jsonEncoding {\n jsonEncoding\n}"): (typeof documents)["query jsonEncoding {\n jsonEncoding\n}"]; +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function graphql(source: "query path {\n path {\n cc: child {\n error\n }\n }\n}"): (typeof documents)["query path {\n path {\n cc: child {\n error\n }\n }\n}"]; +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function graphql(source: "query viewer {\n viewer {\n user {\n name\n phoneNumber\n query {\n jsonEncoding\n }\n ...userFragment @defer\n }\n }\n}\n\nfragment userFragment on User {\n likes\n}"): (typeof documents)["query viewer {\n viewer {\n user {\n name\n phoneNumber\n query {\n jsonEncoding\n }\n ...userFragment @defer\n }\n }\n}\n\nfragment userFragment on User {\n likes\n}"]; + +export function graphql(source: string) { + return (documents as any)[source] ?? {}; +} + +export type DocumentType<TDocumentNode extends DocumentNode<any, any>> = TDocumentNode extends DocumentNode< infer TType, any> ? TType : never; \ No newline at end of file diff --git a/integration/src/generated/graphql.ts b/integration/src/generated/graphql.ts new file mode 100644 index 0000000..1e1605a --- /dev/null +++ b/integration/src/generated/graphql.ts @@ -0,0 +1,159 @@ +/* eslint-disable */ +import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +export type Maybe<T> = T | null; +export type InputMaybe<T> = Maybe<T>; +export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] }; +export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> }; +export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> }; +export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never }; +export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +/** All built-in and custom scalars, mapped to their actual values */ +export type Scalars = { + ID: { input: string | number; output: string; } + String: { input: string; output: string; } + Boolean: { input: boolean; output: boolean; } + Int: { input: number; output: number; } + Float: { input: number; output: number; } + Map: { input: any; output: any; } +}; + +export enum Date_Filter_Op { + Eq = 'EQ', + Gt = 'GT', + Gte = 'GTE', + Lt = 'LT', + Lte = 'LTE', + Neq = 'NEQ' +} + +export type DateFilter = { + op?: InputMaybe<Date_Filter_Op>; + timezone?: InputMaybe<Scalars['String']['input']>; + value: Scalars['String']['input']; +}; + +export type Element = { + __typename?: 'Element'; + child: Element; + error: Scalars['Boolean']['output']; + mismatched?: Maybe<Array<Scalars['Boolean']['output']>>; +}; + +export enum ErrorType { + Custom = 'CUSTOM', + Normal = 'NORMAL' +} + +export type ListCoercion = { + enumVal?: InputMaybe<Array<InputMaybe<ErrorType>>>; + intVal?: InputMaybe<Array<InputMaybe<Scalars['Int']['input']>>>; + scalarVal?: InputMaybe<Array<InputMaybe<Scalars['Map']['input']>>>; + strVal?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>; +}; + +export type Query = { + __typename?: 'Query'; + coercion: Scalars['Boolean']['output']; + complexity: Scalars['Boolean']['output']; + date: Scalars['Boolean']['output']; + error: Scalars['Boolean']['output']; + jsonEncoding: Scalars['String']['output']; + path?: Maybe<Array<Maybe<Element>>>; + viewer?: Maybe<Viewer>; +}; + + +export type QueryCoercionArgs = { + value?: InputMaybe<Array<ListCoercion>>; +}; + + +export type QueryComplexityArgs = { + value: Scalars['Int']['input']; +}; + + +export type QueryDateArgs = { + filter: DateFilter; +}; + + +export type QueryErrorArgs = { + type?: InputMaybe<ErrorType>; +}; + +export type RemoteModelWithOmitempty = { + __typename?: 'RemoteModelWithOmitempty'; + newDesc?: Maybe<Scalars['String']['output']>; +}; + +export type User = { + __typename?: 'User'; + likes: Array<Scalars['String']['output']>; + name: Scalars['String']['output']; + /** @deprecated No longer supported */ + phoneNumber?: Maybe<Scalars['String']['output']>; + query: Query; +}; + +export type Viewer = { + __typename?: 'Viewer'; + user?: Maybe<User>; +}; + +export type CoercionQueryVariables = Exact<{ + value?: InputMaybe<Array<ListCoercion> | ListCoercion>; +}>; + + +export type CoercionQuery = { __typename?: 'Query', coercion: boolean }; + +export type ComplexityQueryVariables = Exact<{ + value: Scalars['Int']['input']; +}>; + + +export type ComplexityQuery = { __typename?: 'Query', complexity: boolean }; + +export type DateQueryVariables = Exact<{ + filter: DateFilter; +}>; + + +export type DateQuery = { __typename?: 'Query', date: boolean }; + +export type ErrorQueryVariables = Exact<{ + type?: InputMaybe<ErrorType>; +}>; + + +export type ErrorQuery = { __typename?: 'Query', error: boolean }; + +export type JsonEncodingQueryVariables = Exact<{ [key: string]: never; }>; + + +export type JsonEncodingQuery = { __typename?: 'Query', jsonEncoding: string }; + +export type PathQueryVariables = Exact<{ [key: string]: never; }>; + + +export type PathQuery = { __typename?: 'Query', path?: Array<{ __typename?: 'Element', cc: { __typename?: 'Element', error: boolean } } | null> | null }; + +export type ViewerQueryVariables = Exact<{ [key: string]: never; }>; + + +export type ViewerQuery = { __typename?: 'Query', viewer?: { __typename?: 'Viewer', user?: ( { __typename?: 'User', name: string, phoneNumber?: string | null, query: { __typename?: 'Query', jsonEncoding: string } } & ( + { __typename?: 'User' } + & { ' $fragmentRefs'?: { 'UserFragmentFragment': Incremental<UserFragmentFragment> } } + ) ) | null } | null }; + +export type UserFragmentFragment = { __typename?: 'User', likes: Array<string> } & { ' $fragmentName'?: 'UserFragmentFragment' }; + +export const UserFragmentFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"userFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"User"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"likes"}}]}}]} as unknown as DocumentNode<UserFragmentFragment, unknown>; +export const CoercionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"coercion"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"value"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ListCoercion"}}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"coercion"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"value"},"value":{"kind":"Variable","name":{"kind":"Name","value":"value"}}}]}]}}]} as unknown as DocumentNode<CoercionQuery, CoercionQueryVariables>; +export const ComplexityDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"complexity"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"value"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"complexity"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"value"},"value":{"kind":"Variable","name":{"kind":"Name","value":"value"}}}]}]}}]} as unknown as DocumentNode<ComplexityQuery, ComplexityQueryVariables>; +export const DateDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"date"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"filter"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"DateFilter"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"date"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"filter"},"value":{"kind":"Variable","name":{"kind":"Name","value":"filter"}}}]}]}}]} as unknown as DocumentNode<DateQuery, DateQueryVariables>; +export const ErrorDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"error"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"type"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"ErrorType"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"error"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"type"},"value":{"kind":"Variable","name":{"kind":"Name","value":"type"}}}]}]}}]} as unknown as DocumentNode<ErrorQuery, ErrorQueryVariables>; +export const JsonEncodingDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"jsonEncoding"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"jsonEncoding"}}]}}]} as unknown as DocumentNode<JsonEncodingQuery, JsonEncodingQueryVariables>; +export const PathDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"path"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"path"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"cc"},"name":{"kind":"Name","value":"child"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"error"}}]}}]}}]}}]} as unknown as DocumentNode<PathQuery, PathQueryVariables>; +export const ViewerDocument = {"__meta__":{"deferredFields":{"userFragment":["likes"]}},"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"viewer"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"viewer"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"phoneNumber"}},{"kind":"Field","name":{"kind":"Name","value":"query"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"jsonEncoding"}}]}},{"kind":"FragmentSpread","name":{"kind":"Name","value":"userFragment"},"directives":[{"kind":"Directive","name":{"kind":"Name","value":"defer"}}]}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"userFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"User"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"likes"}}]}}]} as unknown as DocumentNode<ViewerQuery, ViewerQueryVariables>; \ No newline at end of file diff --git a/integration/src/generated/index.ts b/integration/src/generated/index.ts new file mode 100644 index 0000000..f515991 --- /dev/null +++ b/integration/src/generated/index.ts @@ -0,0 +1,2 @@ +export * from "./fragment-masking"; +export * from "./gql"; \ No newline at end of file diff --git a/integration/src/generated/schema-expected.graphql b/integration/src/generated/schema-expected.graphql new file mode 100644 index 0000000..1c58ff1 --- /dev/null +++ b/integration/src/generated/schema-expected.graphql @@ -0,0 +1,67 @@ +""" +The @defer directive may be specified on a fragment spread to imply de-prioritization, that causes the fragment to be omitted in the initial response, and delivered as a subsequent response afterward. A query with @defer directive will cause the request to potentially return multiple responses, where non-deferred data is delivered in the initial response and data deferred delivered in a subsequent response. @include and @skip take precedence over @defer. +""" +directive @defer(if: Boolean = true, label: String) on FRAGMENT_SPREAD | INLINE_FRAGMENT + +"""This directive does magical things""" +directive @magic(kind: Int) on FIELD_DEFINITION + +enum DATE_FILTER_OP { + EQ + GT + GTE + LT + LTE + NEQ +} + +input DateFilter { + op: DATE_FILTER_OP = EQ + timezone: String = "UTC" + value: String! +} + +type Element { + child: Element! + error: Boolean! + mismatched: [Boolean!] +} + +enum ErrorType { + CUSTOM + NORMAL +} + +input ListCoercion { + enumVal: [ErrorType] + intVal: [Int] + scalarVal: [Map] + strVal: [String] +} + +scalar Map + +type Query { + coercion(value: [ListCoercion!]): Boolean! + complexity(value: Int!): Boolean! + date(filter: DateFilter!): Boolean! + error(type: ErrorType = NORMAL): Boolean! + jsonEncoding: String! + path: [Element] + viewer: Viewer +} + +type RemoteModelWithOmitempty { + newDesc: String +} + +type User { + likes: [String!]! + name: String! + phoneNumber: String @deprecated + query: Query! +} + +type Viewer { + user: User +} \ No newline at end of file diff --git a/integration/src/queries/coercion.graphql b/integration/src/queries/coercion.graphql new file mode 100644 index 0000000..8b04a8c --- /dev/null +++ b/integration/src/queries/coercion.graphql @@ -0,0 +1,3 @@ +query coercion($value: [ListCoercion!]){ + coercion(value: $value ) +} diff --git a/integration/src/queries/complexity.graphql b/integration/src/queries/complexity.graphql new file mode 100644 index 0000000..17a3898 --- /dev/null +++ b/integration/src/queries/complexity.graphql @@ -0,0 +1,3 @@ +query complexity($value: Int!) { + complexity(value: $value) +} diff --git a/integration/src/queries/date.graphql b/integration/src/queries/date.graphql new file mode 100644 index 0000000..fbcc552 --- /dev/null +++ b/integration/src/queries/date.graphql @@ -0,0 +1,3 @@ +query date($filter: DateFilter!) { + date(filter: $filter) +} diff --git a/integration/src/queries/error.graphql b/integration/src/queries/error.graphql new file mode 100644 index 0000000..7f9e44a --- /dev/null +++ b/integration/src/queries/error.graphql @@ -0,0 +1,3 @@ +query error($type: ErrorType) { + error(type: $type) +} diff --git a/integration/src/queries/jsonEncoding.graphql b/integration/src/queries/jsonEncoding.graphql new file mode 100644 index 0000000..87db900 --- /dev/null +++ b/integration/src/queries/jsonEncoding.graphql @@ -0,0 +1,3 @@ +query jsonEncoding { + jsonEncoding +} diff --git a/integration/src/queries/path.graphql b/integration/src/queries/path.graphql new file mode 100644 index 0000000..26012fe --- /dev/null +++ b/integration/src/queries/path.graphql @@ -0,0 +1,7 @@ +query path { + path { + cc:child { + error + } + } +} diff --git a/integration/src/queries/viewer.graphql b/integration/src/queries/viewer.graphql new file mode 100644 index 0000000..0aa48d0 --- /dev/null +++ b/integration/src/queries/viewer.graphql @@ -0,0 +1,16 @@ +query viewer { + viewer { + user { + name + phoneNumber + query { + jsonEncoding + } + ...userFragment @defer + } + } +} + +fragment userFragment on User { + likes +} diff --git a/integration/tsconfig.json b/integration/tsconfig.json new file mode 100644 index 0000000..75abdef --- /dev/null +++ b/integration/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"] +} diff --git a/internal/code/compare.go b/internal/code/compare.go new file mode 100644 index 0000000..e521d31 --- /dev/null +++ b/internal/code/compare.go @@ -0,0 +1,155 @@ +package code + +import ( + "fmt" + "go/types" +) + +// CompatibleTypes isnt a strict comparison, it allows for pointer differences +func CompatibleTypes(expected, actual types.Type) error { + // Special case to deal with pointer mismatches + { + expectedPtr, expectedIsPtr := expected.(*types.Pointer) + actualPtr, actualIsPtr := actual.(*types.Pointer) + + if expectedIsPtr && actualIsPtr { + return CompatibleTypes(expectedPtr.Elem(), actualPtr.Elem()) + } + if expectedIsPtr && !actualIsPtr { + return CompatibleTypes(expectedPtr.Elem(), actual) + } + if !expectedIsPtr && actualIsPtr { + return CompatibleTypes(expected, actualPtr.Elem()) + } + } + + switch expected := expected.(type) { + case *types.Slice: + if actual, ok := actual.(*types.Slice); ok { + return CompatibleTypes(expected.Elem(), actual.Elem()) + } + + case *types.Array: + if actual, ok := actual.(*types.Array); ok { + if expected.Len() != actual.Len() { + return fmt.Errorf("array length differs") + } + + return CompatibleTypes(expected.Elem(), actual.Elem()) + } + + case *types.Basic: + if actual, ok := actual.(*types.Basic); ok { + if actual.Kind() != expected.Kind() { + return fmt.Errorf("basic kind differs, %s != %s", expected.Name(), actual.Name()) + } + + return nil + } + + case *types.Struct: + if actual, ok := actual.(*types.Struct); ok { + if expected.NumFields() != actual.NumFields() { + return fmt.Errorf("number of struct fields differ") + } + + for i := 0; i < expected.NumFields(); i++ { + if expected.Field(i).Name() != actual.Field(i).Name() { + return fmt.Errorf("struct field %d name differs, %s != %s", i, expected.Field(i).Name(), actual.Field(i).Name()) + } + if err := CompatibleTypes(expected.Field(i).Type(), actual.Field(i).Type()); err != nil { + return err + } + } + return nil + } + + case *types.Tuple: + if actual, ok := actual.(*types.Tuple); ok { + if expected.Len() != actual.Len() { + return fmt.Errorf("tuple length differs, %d != %d", expected.Len(), actual.Len()) + } + + for i := 0; i < expected.Len(); i++ { + if err := CompatibleTypes(expected.At(i).Type(), actual.At(i).Type()); err != nil { + return err + } + } + + return nil + } + + case *types.Signature: + if actual, ok := actual.(*types.Signature); ok { + if err := CompatibleTypes(expected.Params(), actual.Params()); err != nil { + return err + } + err := CompatibleTypes(expected.Results(), actual.Results()) + return err + } + case *types.Interface: + if actual, ok := actual.(*types.Interface); ok { + if expected.NumMethods() != actual.NumMethods() { + return fmt.Errorf("interface method count differs, %d != %d", expected.NumMethods(), actual.NumMethods()) + } + + for i := 0; i < expected.NumMethods(); i++ { + if expected.Method(i).Name() != actual.Method(i).Name() { + return fmt.Errorf("interface method %d name differs, %s != %s", i, expected.Method(i).Name(), actual.Method(i).Name()) + } + if err := CompatibleTypes(expected.Method(i).Type(), actual.Method(i).Type()); err != nil { + return err + } + } + + return nil + } + + case *types.Map: + if actual, ok := actual.(*types.Map); ok { + if err := CompatibleTypes(expected.Key(), actual.Key()); err != nil { + return err + } + + err := CompatibleTypes(expected.Elem(), actual.Elem()) + return err + } + + case *types.Chan: + if actual, ok := actual.(*types.Chan); ok { + return CompatibleTypes(expected.Elem(), actual.Elem()) + } + + case *types.Named: + if actual, ok := actual.(*types.Named); ok { + if NormalizeVendor(expected.Obj().Pkg().Path()) != NormalizeVendor(actual.Obj().Pkg().Path()) { + return fmt.Errorf( + "package name of named type differs, %s != %s", + NormalizeVendor(expected.Obj().Pkg().Path()), + NormalizeVendor(actual.Obj().Pkg().Path()), + ) + } + + if expected.Obj().Name() != actual.Obj().Name() { + return fmt.Errorf( + "named type name differs, %s != %s", + NormalizeVendor(expected.Obj().Name()), + NormalizeVendor(actual.Obj().Name()), + ) + } + + return nil + } + + // Before models are generated all missing references will be Invalid Basic references. + // lets assume these are valid too. + if actual, ok := actual.(*types.Basic); ok && actual.Kind() == types.Invalid { + return nil + } + + default: + return fmt.Errorf("missing support for %T", expected) + } + + return fmt.Errorf("type mismatch %T != %T", expected, actual) +} diff --git a/internal/code/compare_test.go b/internal/code/compare_test.go new file mode 100644 index 0000000..0100d57 --- /dev/null +++ b/internal/code/compare_test.go @@ -0,0 +1,85 @@ +package code + +import ( + "go/ast" + "go/importer" + "go/parser" + "go/token" + "go/types" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestCompatibleTypes(t *testing.T) { + valid := []struct { + expected string + actual string + }{ + {"string", "string"}, + {"*string", "string"}, + {"string", "*string"}, + {"*string", "*string"}, + {"[]string", "[]string"}, + {"*[]string", "[]string"}, + {"*[]string", "[]*string"}, + {"*[]*[]*[]string", "[][][]string"}, + {"map[string]interface{}", "map[string]interface{}"}, + {"map[string]string", "map[string]string"}, + {"Bar", "Bar"}, + {"interface{}", "interface{}"}, + {"interface{Foo() bool}", "interface{Foo() bool}"}, + {"struct{Foo bool}", "struct{Foo bool}"}, + } + + for _, tc := range valid { + t.Run(tc.expected+"="+tc.actual, func(t *testing.T) { + expectedType := parseTypeStr(t, tc.expected) + actualType := parseTypeStr(t, tc.actual) + require.NoError(t, CompatibleTypes(expectedType, actualType)) + }) + } + + invalid := []struct { + expected string + actual string + }{ + {"string", "int"}, + {"*string", "[]string"}, + {"[]string", "[][]string"}, + {"Bar", "Baz"}, + {"map[string]interface{}", "map[string]string"}, + {"map[string]string", "[]string"}, + {"interface{Foo() bool}", "interface{}"}, + {"struct{Foo bool}", "struct{Bar bool}"}, + } + + for _, tc := range invalid { + t.Run(tc.expected+"!="+tc.actual, func(t *testing.T) { + expectedType := parseTypeStr(t, tc.expected) + actualType := parseTypeStr(t, tc.actual) + require.Error(t, CompatibleTypes(expectedType, actualType)) + }) + } +} + +func parseTypeStr(t *testing.T, s string) types.Type { + t.Helper() + + fset := token.NewFileSet() + f, err := parser.ParseFile(fset, "test.go", `package test + type Bar string + type Baz string + + type Foo struct { + Field `+s+` + } + `, 0) + require.NoError(t, err) + + conf := types.Config{Importer: importer.Default()} + pkg, err := conf.Check("test", fset, []*ast.File{f}, nil) + require.NoError(t, err) + + return pkg.Scope().Lookup("Foo").Type().(*types.Named).Underlying().(*types.Struct).Field(0).Type() +} diff --git a/internal/code/imports.go b/internal/code/imports.go new file mode 100644 index 0000000..89ebab9 --- /dev/null +++ b/internal/code/imports.go @@ -0,0 +1,174 @@ +package code + +import ( + "bufio" + "fmt" + "go/build" + "go/parser" + "go/token" + "os" + "path/filepath" + "regexp" + "strings" +) + +var gopaths []string + +func init() { + gopaths = filepath.SplitList(build.Default.GOPATH) + for i, p := range gopaths { + gopaths[i] = filepath.ToSlash(filepath.Join(p, "src")) + } +} + +// NameForDir manually looks for package stanzas in files located in the given directory. This can be +// much faster than having to consult go list, because we already know exactly where to look. +func NameForDir(dir string) string { + dir, err := filepath.Abs(dir) + if err != nil { + return SanitizePackageName(filepath.Base(dir)) + } + files, err := os.ReadDir(dir) + if err != nil { + return SanitizePackageName(filepath.Base(dir)) + } + fset := token.NewFileSet() + for _, file := range files { + if !strings.HasSuffix(strings.ToLower(file.Name()), ".go") { + continue + } + + filename := filepath.Join(dir, file.Name()) + if src, err := parser.ParseFile(fset, filename, nil, parser.PackageClauseOnly); err == nil { + return src.Name.Name + } + } + + return SanitizePackageName(filepath.Base(dir)) +} + +type goModuleSearchResult struct { + path string + goModPath string + moduleName string +} + +var goModuleRootCache = map[string]goModuleSearchResult{} + +// goModuleRoot returns the root of the current go module if there is a go.mod file in the directory tree +// If not, it returns false +func goModuleRoot(dir string) (string, bool) { + dir, err := filepath.Abs(dir) + if err != nil { + panic(err) + } + dir = filepath.ToSlash(dir) + + dirs := []string{dir} + result := goModuleSearchResult{} + + for { + modDir := dirs[len(dirs)-1] + + if val, ok := goModuleRootCache[dir]; ok { + result = val + break + } + + if content, err := os.ReadFile(filepath.Join(modDir, "go.mod")); err == nil { + moduleName := extractModuleName(content) + result = goModuleSearchResult{ + path: moduleName, + goModPath: modDir, + moduleName: moduleName, + } + goModuleRootCache[modDir] = result + break + } + + if modDir == "" || modDir == "." || modDir == "/" || strings.HasSuffix(modDir, "\\") { + // Reached the top of the file tree which means go.mod file is not found + // Set root folder with a sentinel cache value + goModuleRootCache[modDir] = result + break + } + + dirs = append(dirs, filepath.Dir(modDir)) + } + + // create a cache for each path in a tree traversed, except the top one as it is already cached + for _, d := range dirs[:len(dirs)-1] { + if result.moduleName == "" { + // go.mod is not found in the tree, so the same sentinel value fits all the directories in a tree + goModuleRootCache[d] = result + } else { + if relPath, err := filepath.Rel(result.goModPath, d); err != nil { + panic(err) + } else { + path := result.moduleName + relPath := filepath.ToSlash(relPath) + if !strings.HasSuffix(relPath, "/") { + path += "/" + } + path += relPath + + goModuleRootCache[d] = goModuleSearchResult{ + path: path, + goModPath: result.goModPath, + moduleName: result.moduleName, + } + } + } + } + + res := goModuleRootCache[dir] + if res.moduleName == "" { + return "", false + } + return res.path, true +} + +func extractModuleName(content []byte) string { + for { + advance, tkn, err := bufio.ScanLines(content, false) + if err != nil { + panic(fmt.Errorf("error parsing mod file: %w", err)) + } + if advance == 0 { + break + } + s := strings.Trim(string(tkn), " \t") + if s != "" && !strings.HasPrefix(s, "//") { + break + } + if advance <= len(content) { + content = content[advance:] + } + } + moduleName := string(modregex.FindSubmatch(content)[1]) + return moduleName +} + +// ImportPathForDir takes a path and returns a golang import path for the package +func ImportPathForDir(dir string) (res string) { + dir, err := filepath.Abs(dir) + if err != nil { + panic(err) + } + dir = filepath.ToSlash(dir) + + modDir, ok := goModuleRoot(dir) + if ok { + return modDir + } + + for _, gopath := range gopaths { + if len(gopath) < len(dir) && strings.EqualFold(gopath, dir[0:len(gopath)]) { + return dir[len(gopath)+1:] + } + } + + return "" +} + +var modregex = regexp.MustCompile(`module (\S*)`) diff --git a/internal/code/imports_test.go b/internal/code/imports_test.go new file mode 100644 index 0000000..1175a83 --- /dev/null +++ b/internal/code/imports_test.go @@ -0,0 +1,57 @@ +package code + +import ( + "os" + "path/filepath" + "runtime" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestExtractModuleName(t *testing.T) { + wd, err := os.Getwd() + require.NoError(t, err) + + modDir := filepath.Join(wd, "..", "..", "testdata") + content, err := os.ReadFile(filepath.Join(modDir, "gomod-with-leading-comments.mod")) + require.NoError(t, err) + assert.Equal(t, "github.com/niko0xdev/gqlgen", extractModuleName(content)) +} + +func TestImportPathForDir(t *testing.T) { + wd, err := os.Getwd() + + require.NoError(t, err) + + assert.Equal(t, "github.com/niko0xdev/gqlgen/internal/code", ImportPathForDir(wd)) + + assert.Equal(t, "github.com/niko0xdev/gqlgen/internal/code", ImportPathForDir(wd)) + assert.Equal(t, "github.com/niko0xdev/gqlgen/api", ImportPathForDir(filepath.Join(wd, "..", "..", "api"))) + + // doesnt contain go code, but should still give a valid import path + assert.Equal(t, "github.com/niko0xdev/gqlgen/docs", ImportPathForDir(filepath.Join(wd, "..", "..", "docs"))) + + // directory does not exist + assert.Equal(t, "github.com/niko0xdev/gqlgen/dos", ImportPathForDir(filepath.Join(wd, "..", "..", "dos"))) + + // out of module + assert.Equal(t, "", ImportPathForDir(filepath.Join(wd, "..", "..", ".."))) + + if runtime.GOOS == "windows" { + assert.Equal(t, "", ImportPathForDir("C:/doesnotexist")) + } else { + assert.Equal(t, "", ImportPathForDir("/doesnotexist")) + } +} + +func TestNameForDir(t *testing.T) { + wd, err := os.Getwd() + require.NoError(t, err) + + assert.Equal(t, "tmp", NameForDir("/tmp")) + assert.Equal(t, "code", NameForDir(wd)) + assert.Equal(t, "docs", NameForDir(wd+"/../../docs")) + assert.Equal(t, "main", NameForDir(wd+"/../..")) +} diff --git a/internal/code/packages.go b/internal/code/packages.go new file mode 100644 index 0000000..a591f55 --- /dev/null +++ b/internal/code/packages.go @@ -0,0 +1,273 @@ +package code + +import ( + "bytes" + "errors" + "fmt" + "os" + "os/exec" + "path/filepath" + "runtime/debug" + "strings" + "sync" + + "golang.org/x/tools/go/packages" +) + +var ( + once = sync.Once{} + modInfo *debug.BuildInfo +) + +var mode = packages.NeedName | + packages.NeedFiles | + packages.NeedImports | + packages.NeedTypes | + packages.NeedSyntax | + packages.NeedTypesInfo | + packages.NeedModule | + packages.NeedDeps + +type ( + // Packages is a wrapper around x/tools/go/packages that maintains a (hopefully prewarmed) cache of packages + // that can be invalidated as writes are made and packages are known to change. + Packages struct { + packages map[string]*packages.Package + importToName map[string]string + loadErrors []error + buildFlags []string + + numLoadCalls int // stupid test steam. ignore. + numNameCalls int // stupid test steam. ignore. + } + // Option is a function that can be passed to NewPackages to configure the package loader + Option func(p *Packages) +) + +// WithBuildTags adds build tags to the packages.Load call +func WithBuildTags(tags ...string) func(p *Packages) { + return func(p *Packages) { + p.buildFlags = append(p.buildFlags, "-tags", strings.Join(tags, ",")) + } +} + +// NewPackages creates a new packages cache +// It will load all packages in the current module, and any packages that are passed to Load or LoadAll +func NewPackages(opts ...Option) *Packages { + p := &Packages{} + for _, opt := range opts { + opt(p) + } + return p +} + +func (p *Packages) CleanupUserPackages() { + once.Do(func() { + var ok bool + modInfo, ok = debug.ReadBuildInfo() + if !ok { + modInfo = nil + } + }) + // Don't cleanup github.com/niko0xdev/gqlgen prefixed packages, + // they haven't changed and do not need to be reloaded + if modInfo != nil { + var toRemove []string + for k := range p.packages { + if !strings.HasPrefix(k, modInfo.Main.Path) { + toRemove = append(toRemove, k) + } + } + for _, k := range toRemove { + delete(p.packages, k) + } + } else { + p.packages = nil // Cleanup all packages if we don't know for some reason which ones to keep + } +} + +// ReloadAll will call LoadAll after clearing the package cache, so we can reload +// packages in the case that the packages have changed +func (p *Packages) ReloadAll(importPaths ...string) []*packages.Package { + if p.packages != nil { + p.CleanupUserPackages() + } + return p.LoadAll(importPaths...) +} + +// LoadAll will call packages.Load and return the package data for the given packages, +// but if the package already have been loaded it will return cached values instead. +func (p *Packages) LoadAll(importPaths ...string) []*packages.Package { + if p.packages == nil { + p.packages = map[string]*packages.Package{} + } + + missing := make([]string, 0, len(importPaths)) + for _, path := range importPaths { + if _, ok := p.packages[path]; ok { + continue + } + missing = append(missing, path) + } + + if len(missing) > 0 { + p.numLoadCalls++ + pkgs, err := packages.Load(&packages.Config{ + Mode: mode, + BuildFlags: p.buildFlags, + }, missing...) + if err != nil { + p.loadErrors = append(p.loadErrors, err) + } + + for _, pkg := range pkgs { + p.addToCache(pkg) + } + } + + res := make([]*packages.Package, 0, len(importPaths)) + for _, path := range importPaths { + res = append(res, p.packages[NormalizeVendor(path)]) + } + return res +} + +func (p *Packages) addToCache(pkg *packages.Package) { + imp := NormalizeVendor(pkg.PkgPath) + p.packages[imp] = pkg + for _, imp := range pkg.Imports { + if _, found := p.packages[NormalizeVendor(imp.PkgPath)]; !found { + p.addToCache(imp) + } + } +} + +// Load works the same as LoadAll, except a single package at a time. +func (p *Packages) Load(importPath string) *packages.Package { + // Quick cache check first to avoid expensive allocations of LoadAll() + if p.packages != nil { + if pkg, ok := p.packages[importPath]; ok { + return pkg + } + } + + pkgs := p.LoadAll(importPath) + if len(pkgs) == 0 { + return nil + } + return pkgs[0] +} + +// LoadWithTypes tries a standard load, which may not have enough type info (TypesInfo== nil) available if the imported package is a +// second order dependency. Fortunately this doesnt happen very often, so we can just issue a load when we detect it. +func (p *Packages) LoadWithTypes(importPath string) *packages.Package { + pkg := p.Load(importPath) + if pkg == nil || pkg.TypesInfo == nil { + p.numLoadCalls++ + pkgs, err := packages.Load(&packages.Config{ + Mode: mode, + BuildFlags: p.buildFlags, + }, importPath) + if err != nil { + p.loadErrors = append(p.loadErrors, err) + return nil + } + p.addToCache(pkgs[0]) + pkg = pkgs[0] + } + return pkg +} + +// NameForPackage looks up the package name from the package stanza in the go files at the given import path. +func (p *Packages) NameForPackage(importPath string) string { + if importPath == "" { + panic(errors.New("import path can not be empty")) + } + if p.importToName == nil { + p.importToName = map[string]string{} + } + + importPath = NormalizeVendor(importPath) + + // if its in the name cache use it + if name := p.importToName[importPath]; name != "" { + return name + } + + // otherwise we might have already loaded the full package data for it cached + pkg := p.packages[importPath] + + if pkg == nil { + // otherwise do a name only lookup for it but don't put it in the package cache. + p.numNameCalls++ + pkgs, err := packages.Load(&packages.Config{ + Mode: packages.NeedName, + BuildFlags: p.buildFlags, + }, importPath) + if err != nil { + p.loadErrors = append(p.loadErrors, err) + } else { + pkg = pkgs[0] + } + } + + if pkg == nil || pkg.Name == "" { + return SanitizePackageName(filepath.Base(importPath)) + } + + p.importToName[importPath] = pkg.Name + + return pkg.Name +} + +// Evict removes a given package import path from the cache, along with any packages that depend on it. Further calls +// to Load will fetch it from disk. +func (p *Packages) Evict(importPath string) { + delete(p.packages, importPath) + + for _, pkg := range p.packages { + for _, imported := range pkg.Imports { + if imported.PkgPath == importPath { + p.Evict(pkg.PkgPath) + } + } + } +} + +func (p *Packages) ModTidy() error { + p.packages = nil + tidyCmd := exec.Command("go", "mod", "tidy") + tidyCmd.Stdout = os.Stdout + tidyCmd.Stderr = os.Stdout + if err := tidyCmd.Run(); err != nil { + return fmt.Errorf("go mod tidy failed: %w", err) + } + return nil +} + +// Errors returns any errors that were returned by Load, either from the call itself or any of the loaded packages. +func (p *Packages) Errors() PkgErrors { + var res []error //nolint:prealloc + res = append(res, p.loadErrors...) + for _, pkg := range p.packages { + for _, err := range pkg.Errors { + res = append(res, err) + } + } + return res +} + +func (p *Packages) Count() int { + return len(p.packages) +} + +type PkgErrors []error + +func (p PkgErrors) Error() string { + var b bytes.Buffer + b.WriteString("packages.Load: ") + for _, e := range p { + b.WriteString(e.Error() + "\n") + } + return b.String() +} diff --git a/internal/code/packages_test.go b/internal/code/packages_test.go new file mode 100644 index 0000000..9508535 --- /dev/null +++ b/internal/code/packages_test.go @@ -0,0 +1,74 @@ +package code + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestPackages(t *testing.T) { + t.Run("name for existing package does not load again", func(t *testing.T) { + p := initialState(t) + require.Equal(t, "a", p.NameForPackage("github.com/niko0xdev/gqlgen/internal/code/testdata/a")) + require.Equal(t, 1, p.numLoadCalls) + }) + + t.Run("name for unknown package makes name only load", func(t *testing.T) { + p := initialState(t) + require.Equal(t, "c", p.NameForPackage("github.com/niko0xdev/gqlgen/internal/code/testdata/c")) + require.Equal(t, 1, p.numLoadCalls) + require.Equal(t, 1, p.numNameCalls) + }) + + t.Run("evicting a package causes it to load again", func(t *testing.T) { + p := initialState(t) + p.Evict("github.com/niko0xdev/gqlgen/internal/code/testdata/b") + require.Equal(t, "a", p.Load("github.com/niko0xdev/gqlgen/internal/code/testdata/a").Name) + require.Equal(t, 1, p.numLoadCalls) + require.Equal(t, "b", p.Load("github.com/niko0xdev/gqlgen/internal/code/testdata/b").Name) + require.Equal(t, 2, p.numLoadCalls) + }) + + t.Run("evicting a package also evicts its dependencies", func(t *testing.T) { + p := initialState(t) + p.Evict("github.com/niko0xdev/gqlgen/internal/code/testdata/a") + require.Equal(t, "a", p.Load("github.com/niko0xdev/gqlgen/internal/code/testdata/a").Name) + require.Equal(t, 2, p.numLoadCalls) + require.Equal(t, "b", p.Load("github.com/niko0xdev/gqlgen/internal/code/testdata/b").Name) + require.Equal(t, 3, p.numLoadCalls) + }) + t.Run("able to load private package with build tags", func(t *testing.T) { + p := initialState(t, WithBuildTags("private")) + p.Evict("github.com/niko0xdev/gqlgen/internal/code/testdata/a") + require.Equal(t, "a", p.Load("github.com/niko0xdev/gqlgen/internal/code/testdata/a").Name) + require.Equal(t, 2, p.numLoadCalls) + require.Equal(t, "p", p.Load("github.com/niko0xdev/gqlgen/internal/code/testdata/p").Name) + require.Equal(t, 3, p.numLoadCalls) + }) +} + +func TestNameForPackage(t *testing.T) { + var p Packages + + assert.Equal(t, "api", p.NameForPackage("github.com/niko0xdev/gqlgen/api")) + + // does not contain go code, should still give a valid name + assert.Equal(t, "docs", p.NameForPackage("github.com/niko0xdev/gqlgen/docs")) + assert.Equal(t, "github_com", p.NameForPackage("github.com")) +} + +func initialState(t *testing.T, opts ...Option) *Packages { + p := NewPackages(opts...) + pkgs := p.LoadAll( + "github.com/niko0xdev/gqlgen/internal/code/testdata/a", + "github.com/niko0xdev/gqlgen/internal/code/testdata/b", + ) + require.Nil(t, p.Errors()) + + require.Equal(t, 1, p.numLoadCalls) + require.Equal(t, 0, p.numNameCalls) + require.Equal(t, "a", pkgs[0].Name) + require.Equal(t, "b", pkgs[1].Name) + return p +} diff --git a/internal/code/testdata/a/a.go b/internal/code/testdata/a/a.go new file mode 100644 index 0000000..bc4bece --- /dev/null +++ b/internal/code/testdata/a/a.go @@ -0,0 +1,3 @@ +package a + +var A = "A" diff --git a/internal/code/testdata/b/b.go b/internal/code/testdata/b/b.go new file mode 100644 index 0000000..6bb1d51 --- /dev/null +++ b/internal/code/testdata/b/b.go @@ -0,0 +1,5 @@ +package b + +import "github.com/niko0xdev/gqlgen/internal/code/testdata/a" + +var B = a.A + " B" diff --git a/internal/code/testdata/c/c.go b/internal/code/testdata/c/c.go new file mode 100644 index 0000000..1685529 --- /dev/null +++ b/internal/code/testdata/c/c.go @@ -0,0 +1,7 @@ +package c + +import ( + "github.com/niko0xdev/gqlgen/internal/code/testdata/b" +) + +var C = b.B + " C" diff --git a/internal/code/testdata/p/p.go b/internal/code/testdata/p/p.go new file mode 100644 index 0000000..eda9bcf --- /dev/null +++ b/internal/code/testdata/p/p.go @@ -0,0 +1,13 @@ +//go:build private +// +build private + +// This file is excluded from the build unless the "private" build tag is set. +// This is used to test loading private packages. +// See internal/code/packages_test.go for more details. +package p + +import ( + "github.com/niko0xdev/gqlgen/internal/code/testdata/b" +) + +var P = b.C + " P" diff --git a/internal/code/util.go b/internal/code/util.go new file mode 100644 index 0000000..b9fbc99 --- /dev/null +++ b/internal/code/util.go @@ -0,0 +1,61 @@ +package code + +import ( + "go/build" + "os" + "path/filepath" + "regexp" + "strings" +) + +// take a string in the form github.com/package/blah.Type and split it into package and type +func PkgAndType(name string) (string, string) { + parts := strings.Split(name, ".") + if len(parts) == 1 { + return "", name + } + + return strings.Join(parts[:len(parts)-1], "."), parts[len(parts)-1] +} + +var modsRegex = regexp.MustCompile(`^(\*|\[\])*`) + +// NormalizeVendor takes a qualified package path and turns it into normal one. +// eg . +// github.com/foo/vendor/github.com/niko0xdev/gqlgen/graphql becomes +// github.com/niko0xdev/gqlgen/graphql +func NormalizeVendor(pkg string) string { + modifiers := modsRegex.FindAllString(pkg, 1)[0] + pkg = strings.TrimPrefix(pkg, modifiers) + parts := strings.Split(pkg, "/vendor/") + return modifiers + parts[len(parts)-1] +} + +// QualifyPackagePath takes an import and fully qualifies it with a vendor dir, if one is required. +// eg . +// github.com/niko0xdev/gqlgen/graphql becomes +// github.com/foo/vendor/github.com/niko0xdev/gqlgen/graphql +// +// x/tools/packages only supports 'qualified package paths' so this will need to be done prior to calling it +// See https://github.com/golang/go/issues/30289 +func QualifyPackagePath(importPath string) string { + wd, _ := os.Getwd() + + // in go module mode, the import path doesn't need fixing + if _, ok := goModuleRoot(wd); ok { + return importPath + } + + pkg, err := build.Import(importPath, wd, 0) + if err != nil { + return importPath + } + + return pkg.ImportPath +} + +var invalidPackageNameChar = regexp.MustCompile(`\W`) + +func SanitizePackageName(pkg string) string { + return invalidPackageNameChar.ReplaceAllLiteralString(filepath.Base(pkg), "_") +} diff --git a/internal/code/util_test.go b/internal/code/util_test.go new file mode 100644 index 0000000..6aa7ce6 --- /dev/null +++ b/internal/code/util_test.go @@ -0,0 +1,15 @@ +package code + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestNormalizeVendor(t *testing.T) { + require.Equal(t, "bar/baz", NormalizeVendor("foo/vendor/bar/baz")) + require.Equal(t, "[]bar/baz", NormalizeVendor("[]foo/vendor/bar/baz")) + require.Equal(t, "*bar/baz", NormalizeVendor("*foo/vendor/bar/baz")) + require.Equal(t, "*[]*bar/baz", NormalizeVendor("*[]*foo/vendor/bar/baz")) + require.Equal(t, "[]*bar/baz", NormalizeVendor("[]*foo/vendor/bar/baz")) +} diff --git a/internal/imports/prune.go b/internal/imports/prune.go new file mode 100644 index 0000000..751f9b6 --- /dev/null +++ b/internal/imports/prune.go @@ -0,0 +1,100 @@ +// Wrapper around x/tools/imports that only removes imports, never adds new ones. + +package imports + +import ( + "bytes" + "go/ast" + "go/parser" + "go/printer" + "go/token" + "strings" + + "golang.org/x/tools/go/ast/astutil" + "golang.org/x/tools/imports" + + "github.com/niko0xdev/gqlgen/internal/code" +) + +type visitFn func(node ast.Node) + +func (fn visitFn) Visit(node ast.Node) ast.Visitor { + fn(node) + return fn +} + +// Prune removes any unused imports +func Prune(filename string, src []byte, packages *code.Packages) ([]byte, error) { + fset := token.NewFileSet() + + file, err := parser.ParseFile(fset, filename, src, parser.ParseComments|parser.AllErrors) + if err != nil { + return nil, err + } + + unused := getUnusedImports(file, packages) + for ipath, name := range unused { + astutil.DeleteNamedImport(fset, file, name, ipath) + } + printConfig := &printer.Config{Mode: printer.TabIndent, Tabwidth: 8} + + var buf bytes.Buffer + if err := printConfig.Fprint(&buf, fset, file); err != nil { + return nil, err + } + + return imports.Process(filename, buf.Bytes(), &imports.Options{FormatOnly: true, Comments: true, TabIndent: true, TabWidth: 8}) +} + +func getUnusedImports(file ast.Node, packages *code.Packages) map[string]string { + imported := map[string]*ast.ImportSpec{} + used := map[string]bool{} + + ast.Walk(visitFn(func(node ast.Node) { + if node == nil { + return + } + switch v := node.(type) { + case *ast.ImportSpec: + if v.Name != nil { + imported[v.Name.Name] = v + break + } + ipath := strings.Trim(v.Path.Value, `"`) + if ipath == "C" { + break + } + + local := packages.NameForPackage(ipath) + + imported[local] = v + case *ast.SelectorExpr: + xident, ok := v.X.(*ast.Ident) + if !ok { + break + } + if xident.Obj != nil { + // if the parser can resolve it, it's not a package ref + break + } + used[xident.Name] = true + } + }), file) + + for pkg := range used { + delete(imported, pkg) + } + + unusedImport := map[string]string{} + for pkg, is := range imported { + if !used[pkg] && pkg != "_" && pkg != "." { + name := "" + if is.Name != nil { + name = is.Name.Name + } + unusedImport[strings.Trim(is.Path.Value, `"`)] = name + } + } + + return unusedImport +} diff --git a/internal/imports/prune_test.go b/internal/imports/prune_test.go new file mode 100644 index 0000000..fb2411a --- /dev/null +++ b/internal/imports/prune_test.go @@ -0,0 +1,27 @@ +package imports + +import ( + "os" + "strings" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/internal/code" +) + +func TestPrune(t *testing.T) { + // prime the packages cache so that it's not considered uninitialized + + b, err := Prune("testdata/unused.go", mustReadFile("testdata/unused.go"), code.NewPackages()) + require.NoError(t, err) + require.Equal(t, strings.ReplaceAll(string(mustReadFile("testdata/unused.expected.go")), "\r\n", "\n"), string(b)) +} + +func mustReadFile(filename string) []byte { + b, err := os.ReadFile(filename) + if err != nil { + panic(err) + } + return b +} diff --git a/internal/imports/testdata/unused.expected.go b/internal/imports/testdata/unused.expected.go new file mode 100644 index 0000000..f9d393d --- /dev/null +++ b/internal/imports/testdata/unused.expected.go @@ -0,0 +1,23 @@ +package testdata + +import ( + a "fmt" + "time" + + _ "underscore" +) + +type foo struct { + Time time.Time `json:"text"` +} + +func fn() { + a.Println("hello") +} + +type Message struct { + ID string `json:"id"` + Text string `json:"text"` + CreatedBy string `json:"createdBy"` + CreatedAt time.Time `json:"createdAt"` +} diff --git a/internal/imports/testdata/unused.go b/internal/imports/testdata/unused.go new file mode 100644 index 0000000..f9d393d --- /dev/null +++ b/internal/imports/testdata/unused.go @@ -0,0 +1,23 @@ +package testdata + +import ( + a "fmt" + "time" + + _ "underscore" +) + +type foo struct { + Time time.Time `json:"text"` +} + +func fn() { + a.Println("hello") +} + +type Message struct { + ID string `json:"id"` + Text string `json:"text"` + CreatedBy string `json:"createdBy"` + CreatedAt time.Time `json:"createdAt"` +} diff --git a/internal/rewrite/rewriter.go b/internal/rewrite/rewriter.go new file mode 100644 index 0000000..aec01a4 --- /dev/null +++ b/internal/rewrite/rewriter.go @@ -0,0 +1,208 @@ +package rewrite + +import ( + "bytes" + "fmt" + "go/ast" + "go/token" + "os" + "path/filepath" + "strconv" + "strings" + + "golang.org/x/tools/go/packages" + + "github.com/niko0xdev/gqlgen/internal/code" +) + +type Rewriter struct { + pkg *packages.Package + files map[string]string + copied map[ast.Decl]bool +} + +func New(dir string) (*Rewriter, error) { + importPath := code.ImportPathForDir(dir) + if importPath == "" { + return nil, fmt.Errorf("import path not found for directory: %q", dir) + } + pkgs, err := packages.Load(&packages.Config{ + Mode: packages.NeedSyntax | packages.NeedTypes, + }, importPath) + if err != nil { + return nil, err + } + if len(pkgs) == 0 { + return nil, fmt.Errorf("package not found for importPath: %s", importPath) + } + + return &Rewriter{ + pkg: pkgs[0], + files: map[string]string{}, + copied: map[ast.Decl]bool{}, + }, nil +} + +func (r *Rewriter) getSource(start, end token.Pos) string { + startPos := r.pkg.Fset.Position(start) + endPos := r.pkg.Fset.Position(end) + + if startPos.Filename != endPos.Filename { + panic("cant get source spanning multiple files") + } + + file := r.getFile(startPos.Filename) + return file[startPos.Offset:endPos.Offset] +} + +func (r *Rewriter) getFile(filename string) string { + if _, ok := r.files[filename]; !ok { + b, err := os.ReadFile(filename) + if err != nil { + panic(fmt.Errorf("unable to load file, already exists: %w", err)) + } + + r.files[filename] = string(b) + + } + + return r.files[filename] +} + +func (r *Rewriter) GetPrevDecl(structname, methodname string) *ast.FuncDecl { + for _, f := range r.pkg.Syntax { + for _, d := range f.Decls { + d, isFunc := d.(*ast.FuncDecl) + if !isFunc { + continue + } + if d.Name.Name != methodname { + continue + } + if d.Recv == nil || len(d.Recv.List) == 0 { + continue + } + recv := d.Recv.List[0].Type + if star, isStar := recv.(*ast.StarExpr); isStar { + recv = star.X + } + ident, ok := recv.(*ast.Ident) + if !ok { + continue + } + if ident.Name != structname { + continue + } + r.copied[d] = true + return d + } + } + return nil +} + +func (r *Rewriter) GetMethodComment(structname, methodname string) string { + d := r.GetPrevDecl(structname, methodname) + if d != nil { + return d.Doc.Text() + } + return "" +} + +func (r *Rewriter) GetMethodBody(structname, methodname string) string { + d := r.GetPrevDecl(structname, methodname) + if d != nil { + return r.getSource(d.Body.Pos()+1, d.Body.End()-1) + } + return "" +} + +func (r *Rewriter) MarkStructCopied(name string) { + for _, f := range r.pkg.Syntax { + for _, d := range f.Decls { + d, isGen := d.(*ast.GenDecl) + if !isGen { + continue + } + if d.Tok != token.TYPE || len(d.Specs) == 0 { + continue + } + + spec, isTypeSpec := d.Specs[0].(*ast.TypeSpec) + if !isTypeSpec { + continue + } + + if spec.Name.Name != name { + continue + } + + r.copied[d] = true + } + } +} + +func (r *Rewriter) ExistingImports(filename string) []Import { + filename, err := filepath.Abs(filename) + if err != nil { + panic(err) + } + for _, f := range r.pkg.Syntax { + pos := r.pkg.Fset.Position(f.Pos()) + + if filename != pos.Filename { + continue + } + + var imps []Import + for _, i := range f.Imports { + name := "" + if i.Name != nil { + name = i.Name.Name + } + path, err := strconv.Unquote(i.Path.Value) + if err != nil { + panic(err) + } + imps = append(imps, Import{name, path}) + } + return imps + } + return nil +} + +func (r *Rewriter) RemainingSource(filename string) string { + filename, err := filepath.Abs(filename) + if err != nil { + panic(err) + } + for _, f := range r.pkg.Syntax { + pos := r.pkg.Fset.Position(f.Pos()) + + if filename != pos.Filename { + continue + } + + var buf bytes.Buffer + + for _, d := range f.Decls { + if r.copied[d] { + continue + } + + if d, isGen := d.(*ast.GenDecl); isGen && d.Tok == token.IMPORT { + continue + } + + buf.WriteString(r.getSource(d.Pos(), d.End())) + buf.WriteString("\n") + } + + return strings.TrimSpace(buf.String()) + } + return "" +} + +type Import struct { + Alias string + ImportPath string +} diff --git a/internal/rewrite/rewriter_test.go b/internal/rewrite/rewriter_test.go new file mode 100644 index 0000000..9ac5ffb --- /dev/null +++ b/internal/rewrite/rewriter_test.go @@ -0,0 +1,44 @@ +package rewrite + +import ( + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestRewriter(t *testing.T) { + t.Run("default", func(t *testing.T) { + r, err := New("testdata") + require.NoError(t, err) + + body := r.GetMethodBody("Foo", "Method") + require.Equal(t, ` + // leading comment + + // field comment + m.Field++ + + // trailing comment +`, strings.ReplaceAll(body, "\r\n", "\n")) + + imps := r.ExistingImports("testdata/example.go") + require.Len(t, imps, 2) + assert.Equal(t, []Import{ + { + Alias: "lol", + ImportPath: "bytes", + }, + { + Alias: "", + ImportPath: "fmt", + }, + }, imps) + }) + + t.Run("out of scope dir", func(t *testing.T) { + _, err := New("../../../out-of-gomod/package") + require.Error(t, err) + }) +} diff --git a/internal/rewrite/testdata/example.go b/internal/rewrite/testdata/example.go new file mode 100644 index 0000000..6a3297a --- /dev/null +++ b/internal/rewrite/testdata/example.go @@ -0,0 +1,25 @@ +package testdata + +import ( + lol "bytes" + "fmt" +) + +type Foo struct { + Field int +} + +func (m *Foo) Method(arg int) { + // leading comment + + // field comment + m.Field++ + + // trailing comment +} + +func (m *Foo) String() string { + var buf lol.Buffer + buf.WriteString(fmt.Sprintf("%d", m.Field)) + return buf.String() +} diff --git a/internal/tools.go b/internal/tools.go new file mode 100644 index 0000000..ef46208 --- /dev/null +++ b/internal/tools.go @@ -0,0 +1,8 @@ +//go:build tools +// +build tools + +package main + +import ( + _ "github.com/matryer/moq" +) diff --git a/main.go b/main.go new file mode 100644 index 0000000..f17bb63 --- /dev/null +++ b/main.go @@ -0,0 +1,234 @@ +package main + +//go:generate go generate ./_examples/... + +import ( + "bytes" + _ "embed" + "errors" + "fmt" + "html/template" + "io" + "io/fs" + "log" + "os" + "path/filepath" + + "github.com/urfave/cli/v2" + + "github.com/niko0xdev/gqlgen/api" + "github.com/niko0xdev/gqlgen/codegen/config" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/internal/code" + "github.com/niko0xdev/gqlgen/plugin/servergen" +) + +//go:embed init-templates/schema.graphqls +var schemaFileContent string + +//go:embed init-templates/gqlgen.yml.gotmpl +var configFileTemplate string + +func getConfigFileContent(pkgName string) string { + var buf bytes.Buffer + if err := template.Must(template.New("gqlgen.yml").Parse(configFileTemplate)).Execute(&buf, pkgName); err != nil { + panic(err) + } + return buf.String() +} + +func fileExists(filename string) bool { + _, err := os.Stat(filename) + return !errors.Is(err, fs.ErrNotExist) +} + +// see Go source code: +// https://github.com/golang/go/blob/f57ebed35132d02e5cf016f324853217fb545e91/src/cmd/go/internal/modload/init.go#L1283 +func findModuleRoot(dir string) (roots string) { + if dir == "" { + panic("dir not set") + } + dir = filepath.Clean(dir) + + // Look for enclosing go.mod. + for { + if fi, err := os.Stat(filepath.Join(dir, "go.mod")); err == nil && !fi.IsDir() { + return dir + } + d := filepath.Dir(dir) + if d == dir { // the parent of the root is itself, so we can go no further + break + } + dir = d + } + return "" +} + +func initFile(filename, contents string) error { + if err := os.MkdirAll(filepath.Dir(filename), 0o755); err != nil { + return fmt.Errorf("unable to create directory for file '%s': %w\n", filename, err) + } + if err := os.WriteFile(filename, []byte(contents), 0o644); err != nil { + return fmt.Errorf("unable to write file '%s': %w\n", filename, err) + } + + return nil +} + +var initCmd = &cli.Command{ + Name: "init", + 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", 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") + + cwd, err := os.Getwd() + if err != nil { + log.Println(err) + return fmt.Errorf("unable to determine current directory:%w", err) + } + pkgName := code.ImportPathForDir(cwd) + if pkgName == "" { + return fmt.Errorf( + "unable to determine import path for current directory, you probably need to run 'go mod init' first", + ) + } + modRoot := findModuleRoot(cwd) + if modRoot == "" { + return fmt.Errorf("go.mod is missing. Please, do 'go mod init' first\n") + } + + // 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") + } + + // create config + fmt.Println("Creating", configFilename) + if err := initFile(configFilename, getConfigFileContent(pkgName)); err != nil { + return err + } + + // create schema + fmt.Println("Creating", schemaFilename) + + if err := initFile(schemaFilename, schemaFileContent); err != nil { + return err + } + + // 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) + + var cfg *config.Config + if cfg, err = config.LoadConfig(configFilename); err != nil { + panic(err) + } + + fmt.Println("Creating", serverFilename) + fmt.Println("Generating...") + if err := api.Generate(cfg, api.AddPlugin(servergen.New(serverFilename))); err != nil { + return err + } + + fmt.Printf("\nExec \"go run ./%s\" to start GraphQL server\n", serverFilename) + return nil + }, +} + +var generateCmd = &cli.Command{ + Name: "generate", + Usage: "generate a graphql server based on schema", + Flags: []cli.Flag{ + &cli.BoolFlag{Name: "verbose, v", Usage: "show logs"}, + &cli.StringFlag{Name: "config, c", Usage: "the config filename"}, + }, + Action: func(ctx *cli.Context) error { + var cfg *config.Config + var err error + if configFilename := ctx.String("config"); configFilename != "" { + cfg, err = config.LoadConfig(configFilename) + if err != nil { + return err + } + } else { + cfg, err = config.LoadConfigFromDefaultLocations() + if errors.Is(err, fs.ErrNotExist) { + cfg, err = config.LoadDefaultConfig() + } + + if err != nil { + return err + } + } + + if err = api.Generate(cfg); err != nil { + return err + } + return nil + }, +} + +var versionCmd = &cli.Command{ + Name: "version", + Usage: "print the version string", + Action: func(ctx *cli.Context) error { + fmt.Println(graphql.Version) + return nil + }, +} + +func main() { + app := cli.NewApp() + app.Name = "gqlgen" + app.Usage = generateCmd.Usage + app.Description = "This is a library for quickly creating strictly typed graphql servers in golang. See https://gqlgen.com/ for a getting started guide." + app.HideVersion = true + app.Flags = generateCmd.Flags + app.Version = graphql.Version + app.Before = func(context *cli.Context) error { + if context.Bool("verbose") { + log.SetFlags(0) + } else { + log.SetOutput(io.Discard) + } + return nil + } + + app.Action = generateCmd.Action + app.Commands = []*cli.Command{ + generateCmd, + initCmd, + versionCmd, + } + + if err := app.Run(os.Args); err != nil { + fmt.Fprint(os.Stderr, err.Error()+"\n") + os.Exit(1) + } +} diff --git a/plugin/federation/entity.go b/plugin/federation/entity.go new file mode 100644 index 0000000..1202adc --- /dev/null +++ b/plugin/federation/entity.go @@ -0,0 +1,118 @@ +package federation + +import ( + "go/types" + + "github.com/vektah/gqlparser/v2/ast" + + "github.com/niko0xdev/gqlgen/codegen/config" + "github.com/niko0xdev/gqlgen/codegen/templates" + "github.com/niko0xdev/gqlgen/plugin/federation/fieldset" +) + +// Entity represents a federated type +// that was declared in the GQL schema. +type Entity struct { + Name string // The same name as the type declaration + Def *ast.Definition + Resolvers []*EntityResolver + Requires []*Requires + Multi bool +} + +type EntityResolver struct { + ResolverName string // The resolver name, such as FindUserByID + KeyFields []*KeyField // The fields declared in @key. + InputType types.Type // The Go generated input type for multi entity resolvers + InputTypeName string +} + +func (e *EntityResolver) LookupInputType() string { + return templates.CurrentImports.LookupType(e.InputType) +} + +type KeyField struct { + Definition *ast.FieldDefinition + Field fieldset.Field // len > 1 for nested fields + Type *config.TypeReference // The Go representation of that field type +} + +// Requires represents an @requires clause +type Requires struct { + Name string // the name of the field + Field fieldset.Field // source Field, len > 1 for nested fields + Type *config.TypeReference // The Go representation of that field type +} + +func (e *Entity) allFieldsAreExternal(federationVersion int) bool { + for _, field := range e.Def.Fields { + if !e.isFieldImplicitlyExternal(field, federationVersion) && field.Directives.ForName("external") == nil { + return false + } + } + return true +} + +// In federation v2, key fields are implicitly external. +func (e *Entity) isFieldImplicitlyExternal(field *ast.FieldDefinition, federationVersion int) bool { + // Key fields are only implicitly external in Federation 2 + if federationVersion != 2 { + return false + } + // TODO: From the spec, it seems like if an entity is not resolvable then it should not only not have a resolver, but should not appear in the _Entitiy union. + // The current implementation is a less drastic departure from the previous behavior, but should probably be reviewed. + // See https://www.apollographql.com/docs/federation/subgraph-spec/ + if e.isResolvable() { + return false + } + // If the field is a key field, it is implicitly external + if e.isKeyField(field) { + return true + } + + return false +} + +// Determine if the entity is resolvable. +func (e *Entity) isResolvable() bool { + key := e.Def.Directives.ForName("key") + if key == nil { + // If there is no key directive, the entity is resolvable. + return true + } + resolvable := key.Arguments.ForName("resolvable") + if resolvable == nil { + // If there is no resolvable argument, the entity is resolvable. + return true + } + // only if resolvable: false has been set on the @key directive do we consider the entity non-resolvable. + return resolvable.Value.Raw != "false" +} + +// Determine if a field is part of the entities key. +func (e *Entity) isKeyField(field *ast.FieldDefinition) bool { + for _, keyField := range e.keyFields() { + if keyField == field.Name { + return true + } + } + return false +} + +// Get the key fields for this entity. +func (e *Entity) keyFields() []string { + key := e.Def.Directives.ForName("key") + if key == nil { + return []string{} + } + fields := key.Arguments.ForName("fields") + if fields == nil { + return []string{} + } + fieldSet := fieldset.New(fields.Value.Raw, nil) + keyFields := make([]string, len(fieldSet)) + for i, field := range fieldSet { + keyFields[i] = field[0] + } + return keyFields +} diff --git a/plugin/federation/federation.go b/plugin/federation/federation.go new file mode 100644 index 0000000..ff7c104 --- /dev/null +++ b/plugin/federation/federation.go @@ -0,0 +1,474 @@ +package federation + +import ( + _ "embed" + "fmt" + "sort" + "strings" + + "github.com/vektah/gqlparser/v2/ast" + + "github.com/niko0xdev/gqlgen/codegen" + "github.com/niko0xdev/gqlgen/codegen/config" + "github.com/niko0xdev/gqlgen/codegen/templates" + "github.com/niko0xdev/gqlgen/plugin" + "github.com/niko0xdev/gqlgen/plugin/federation/fieldset" +) + +//go:embed federation.gotpl +var federationTemplate string + +type federation struct { + Entities []*Entity + Version int +} + +// New returns a federation plugin that injects +// federated directives and types into the schema +func New(version int) plugin.Plugin { + if version == 0 { + version = 1 + } + + return &federation{Version: version} +} + +// Name returns the plugin name +func (f *federation) Name() string { + return "federation" +} + +// MutateConfig mutates the configuration +func (f *federation) MutateConfig(cfg *config.Config) error { + builtins := config.TypeMap{ + "_Service": { + Model: config.StringList{ + "github.com/niko0xdev/gqlgen/plugin/federation/fedruntime.Service", + }, + }, + "_Entity": { + Model: config.StringList{ + "github.com/niko0xdev/gqlgen/plugin/federation/fedruntime.Entity", + }, + }, + "Entity": { + Model: config.StringList{ + "github.com/niko0xdev/gqlgen/plugin/federation/fedruntime.Entity", + }, + }, + "_Any": { + Model: config.StringList{"github.com/niko0xdev/gqlgen/graphql.Map"}, + }, + "federation__Scope": { + Model: config.StringList{"github.com/niko0xdev/gqlgen/graphql.String"}, + }, + } + + for typeName, entry := range builtins { + if cfg.Models.Exists(typeName) { + return fmt.Errorf("%v already exists which must be reserved when Federation is enabled", typeName) + } + cfg.Models[typeName] = entry + } + cfg.Directives["external"] = config.DirectiveConfig{SkipRuntime: true} + cfg.Directives["requires"] = config.DirectiveConfig{SkipRuntime: true} + cfg.Directives["provides"] = config.DirectiveConfig{SkipRuntime: true} + cfg.Directives["key"] = config.DirectiveConfig{SkipRuntime: true} + cfg.Directives["extends"] = config.DirectiveConfig{SkipRuntime: true} + + // Federation 2 specific directives + if f.Version == 2 { + cfg.Directives["shareable"] = config.DirectiveConfig{SkipRuntime: true} + cfg.Directives["link"] = config.DirectiveConfig{SkipRuntime: true} + cfg.Directives["tag"] = config.DirectiveConfig{SkipRuntime: true} + cfg.Directives["override"] = config.DirectiveConfig{SkipRuntime: true} + cfg.Directives["inaccessible"] = config.DirectiveConfig{SkipRuntime: true} + cfg.Directives["authenticated"] = config.DirectiveConfig{SkipRuntime: true} + cfg.Directives["requiresScopes"] = config.DirectiveConfig{SkipRuntime: true} + cfg.Directives["interfaceObject"] = config.DirectiveConfig{SkipRuntime: true} + cfg.Directives["composeDirective"] = config.DirectiveConfig{SkipRuntime: true} + } + + return nil +} + +func (f *federation) InjectSourceEarly() *ast.Source { + input := `` + + // add version-specific changes on key directive, as well as adding the new directives for federation 2 + if f.Version == 1 { + input += ` + directive @key(fields: _FieldSet!) repeatable on OBJECT | INTERFACE + directive @requires(fields: _FieldSet!) on FIELD_DEFINITION + directive @provides(fields: _FieldSet!) on FIELD_DEFINITION + directive @extends on OBJECT | INTERFACE + directive @external on FIELD_DEFINITION + scalar _Any + scalar _FieldSet +` + } else if f.Version == 2 { + input += ` + directive @authenticated on FIELD_DEFINITION | OBJECT | INTERFACE | SCALAR | ENUM + directive @composeDirective(name: String!) repeatable on SCHEMA + directive @extends on OBJECT | INTERFACE + directive @external on OBJECT | FIELD_DEFINITION + directive @key(fields: FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE + directive @inaccessible on + | ARGUMENT_DEFINITION + | ENUM + | ENUM_VALUE + | FIELD_DEFINITION + | INPUT_FIELD_DEFINITION + | INPUT_OBJECT + | INTERFACE + | OBJECT + | SCALAR + | UNION + directive @interfaceObject on OBJECT + directive @link(import: [String!], url: String!) repeatable on SCHEMA + directive @override(from: String!) on FIELD_DEFINITION + directive @provides(fields: FieldSet!) on FIELD_DEFINITION + directive @requires(fields: FieldSet!) on FIELD_DEFINITION + directive @requiresScopes(scopes: [[federation__Scope!]!]!) on + | FIELD_DEFINITION + | OBJECT + | INTERFACE + | SCALAR + | ENUM + directive @shareable repeatable on FIELD_DEFINITION | OBJECT + directive @tag(name: String!) repeatable on + | ARGUMENT_DEFINITION + | ENUM + | ENUM_VALUE + | FIELD_DEFINITION + | INPUT_FIELD_DEFINITION + | INPUT_OBJECT + | INTERFACE + | OBJECT + | SCALAR + | UNION + scalar _Any + scalar FieldSet + scalar federation__Scope +` + } + return &ast.Source{ + Name: "federation/directives.graphql", + Input: input, + BuiltIn: true, + } +} + +// InjectSourceLate creates a GraphQL Entity type with all +// the fields that had the @key directive +func (f *federation) InjectSourceLate(schema *ast.Schema) *ast.Source { + f.setEntities(schema) + + var entities, resolvers, entityResolverInputDefinitions string + for _, e := range f.Entities { + + if e.Def.Kind != ast.Interface { + if entities != "" { + entities += " | " + } + entities += e.Name + } else if len(schema.GetPossibleTypes(e.Def)) == 0 { + fmt.Println( + "skipping @key field on interface " + e.Def.Name + " as no types implement it", + ) + } + + for _, r := range e.Resolvers { + if e.Multi { + if entityResolverInputDefinitions != "" { + entityResolverInputDefinitions += "\n\n" + } + entityResolverInputDefinitions += "input " + r.InputTypeName + " {\n" + for _, keyField := range r.KeyFields { + entityResolverInputDefinitions += fmt.Sprintf( + "\t%s: %s\n", + keyField.Field.ToGo(), + keyField.Definition.Type.String(), + ) + } + entityResolverInputDefinitions += "}" + resolvers += fmt.Sprintf("\t%s(reps: [%s]!): [%s]\n", r.ResolverName, r.InputTypeName, e.Name) + } else { + resolverArgs := "" + for _, keyField := range r.KeyFields { + resolverArgs += fmt.Sprintf("%s: %s,", keyField.Field.ToGoPrivate(), keyField.Definition.Type.String()) + } + resolvers += fmt.Sprintf("\t%s(%s): %s!\n", r.ResolverName, resolverArgs, e.Name) + } + } + } + + var blocks []string + if entities != "" { + entities = `# a union of all types that use the @key directive +union _Entity = ` + entities + blocks = append(blocks, entities) + } + + // resolvers can be empty if a service defines only "empty + // extend" types. This should be rare. + if resolvers != "" { + if entityResolverInputDefinitions != "" { + blocks = append(blocks, entityResolverInputDefinitions) + } + resolvers = `# fake type to build resolver interfaces for users to implement +type Entity { + ` + resolvers + ` +}` + blocks = append(blocks, resolvers) + } + + _serviceTypeDef := `type _Service { + sdl: String +}` + blocks = append(blocks, _serviceTypeDef) + + var additionalQueryFields string + // Quote from the Apollo Federation subgraph specification: + // If no types are annotated with the key directive, then the + // _Entity union and _entities field should be removed from the schema + if len(f.Entities) > 0 { + additionalQueryFields += ` _entities(representations: [_Any!]!): [_Entity]! +` + } + // _service field is required in any case + additionalQueryFields += ` _service: _Service!` + + extendTypeQueryDef := `extend type ` + schema.Query.Name + ` { +` + additionalQueryFields + ` +}` + blocks = append(blocks, extendTypeQueryDef) + + return &ast.Source{ + Name: "federation/entity.graphql", + BuiltIn: true, + Input: "\n" + strings.Join(blocks, "\n\n") + "\n", + } +} + +func (f *federation) GenerateCode(data *codegen.Data) error { + if len(f.Entities) > 0 { + if data.Objects.ByName("Entity") != nil { + data.Objects.ByName("Entity").Root = true + } + for _, e := range f.Entities { + obj := data.Objects.ByName(e.Def.Name) + + if e.Def.Kind == ast.Interface { + if len(data.Interfaces[e.Def.Name].Implementors) == 0 { + fmt.Println( + "skipping @key field on interface " + e.Def.Name + " as no types implement it", + ) + continue + } + obj = data.Objects.ByName(data.Interfaces[e.Def.Name].Implementors[0].Name) + } + + for _, r := range e.Resolvers { + // fill in types for key fields + // + for _, keyField := range r.KeyFields { + if len(keyField.Field) == 0 { + fmt.Println( + "skipping @key field " + keyField.Definition.Name + " in " + r.ResolverName + " in " + e.Def.Name, + ) + continue + } + cgField := keyField.Field.TypeReference(obj, data.Objects) + keyField.Type = cgField.TypeReference + } + } + + // fill in types for requires fields + // + for _, reqField := range e.Requires { + if len(reqField.Field) == 0 { + fmt.Println("skipping @requires field " + reqField.Name + " in " + e.Def.Name) + continue + } + cgField := reqField.Field.TypeReference(obj, data.Objects) + reqField.Type = cgField.TypeReference + } + } + } + + // fill in types for resolver inputs + // + for _, entity := range f.Entities { + if !entity.Multi { + continue + } + + for _, resolver := range entity.Resolvers { + obj := data.Inputs.ByName(resolver.InputTypeName) + if obj == nil { + return fmt.Errorf("input object %s not found", resolver.InputTypeName) + } + + resolver.InputType = obj.Type + } + } + + return templates.Render(templates.Options{ + PackageName: data.Config.Federation.Package, + Filename: data.Config.Federation.Filename, + Data: f, + GeneratedHeader: true, + Packages: data.Config.Packages, + Template: federationTemplate, + }) +} + +func (f *federation) setEntities(schema *ast.Schema) { + for _, schemaType := range schema.Types { + keys, ok := isFederatedEntity(schemaType) + if !ok { + continue + } + + if (schemaType.Kind == ast.Interface) && (len(schema.GetPossibleTypes(schemaType)) == 0) { + fmt.Printf("@key directive found on unused \"interface %s\". Will be ignored.\n", schemaType.Name) + continue + } + + e := &Entity{ + Name: schemaType.Name, + Def: schemaType, + Resolvers: nil, + Requires: nil, + } + + // Let's process custom entity resolver settings. + dir := schemaType.Directives.ForName("entityResolver") + if dir != nil { + if dirArg := dir.Arguments.ForName("multi"); dirArg != nil { + if dirVal, err := dirArg.Value.Value(nil); err == nil { + e.Multi = dirVal.(bool) + } + } + } + + // If our schema has a field with a type defined in + // another service, then we need to define an "empty + // extend" of that type in this service, so this service + // knows what the type is like. But the graphql-server + // will never ask us to actually resolve this "empty + // extend", so we don't require a resolver function for + // it. (Well, it will never ask in practice; it's + // unclear whether the spec guarantees this. See + // https://github.com/apollographql/apollo-server/issues/3852 + // ). Example: + // type MyType { + // myvar: TypeDefinedInOtherService + // } + // // Federation needs this type, but + // // it doesn't need a resolver for it! + // extend TypeDefinedInOtherService @key(fields: "id") { + // id: ID @external + // } + if !e.allFieldsAreExternal(f.Version) { + for _, dir := range keys { + if len(dir.Arguments) > 2 { + panic("More than two arguments provided for @key declaration.") + } + var arg *ast.Argument + + // since keys are able to now have multiple arguments, we need to check both possible for a possible @key(fields="" fields="") + for _, a := range dir.Arguments { + if a.Name == "fields" { + if arg != nil { + panic("More than one `fields` provided for @key declaration.") + } + arg = a + } + } + + keyFieldSet := fieldset.New(arg.Value.Raw, nil) + + keyFields := make([]*KeyField, len(keyFieldSet)) + resolverFields := []string{} + for i, field := range keyFieldSet { + def := field.FieldDefinition(schemaType, schema) + + if def == nil { + panic(fmt.Sprintf("no field for %v", field)) + } + + keyFields[i] = &KeyField{Definition: def, Field: field} + resolverFields = append(resolverFields, keyFields[i].Field.ToGo()) + } + + resolverFieldsToGo := schemaType.Name + "By" + strings.Join(resolverFields, "And") + var resolverName string + if e.Multi { + resolverFieldsToGo += "s" // Pluralize for better API readability + resolverName = fmt.Sprintf("findMany%s", resolverFieldsToGo) + } else { + resolverName = fmt.Sprintf("find%s", resolverFieldsToGo) + } + + e.Resolvers = append(e.Resolvers, &EntityResolver{ + ResolverName: resolverName, + KeyFields: keyFields, + InputTypeName: resolverFieldsToGo + "Input", + }) + } + + e.Requires = []*Requires{} + for _, f := range schemaType.Fields { + dir := f.Directives.ForName("requires") + if dir == nil { + continue + } + if len(dir.Arguments) != 1 || dir.Arguments[0].Name != "fields" { + panic("Exactly one `fields` argument needed for @requires declaration.") + } + requiresFieldSet := fieldset.New(dir.Arguments[0].Value.Raw, nil) + for _, field := range requiresFieldSet { + e.Requires = append(e.Requires, &Requires{ + Name: field.ToGoPrivate(), + Field: field, + }) + } + } + } + f.Entities = append(f.Entities, e) + } + + // make sure order remains stable across multiple builds + sort.Slice(f.Entities, func(i, j int) bool { + return f.Entities[i].Name < f.Entities[j].Name + }) +} + +func isFederatedEntity(schemaType *ast.Definition) ([]*ast.Directive, bool) { + switch schemaType.Kind { + case ast.Object: + keys := schemaType.Directives.ForNames("key") + if len(keys) > 0 { + return keys, true + } + case ast.Interface: + keys := schemaType.Directives.ForNames("key") + if len(keys) > 0 { + return keys, true + } + + // TODO: support @extends for interfaces + if dir := schemaType.Directives.ForName("extends"); dir != nil { + panic( + fmt.Sprintf( + "@extends directive is not currently supported for interfaces, use \"extend interface %s\" instead.", + schemaType.Name, + )) + } + default: + // ignore + } + return nil, false +} diff --git a/plugin/federation/federation.gotpl b/plugin/federation/federation.gotpl new file mode 100644 index 0000000..c4bd71f --- /dev/null +++ b/plugin/federation/federation.gotpl @@ -0,0 +1,268 @@ +{{ reserveImport "context" }} +{{ reserveImport "errors" }} +{{ reserveImport "fmt" }} +{{ reserveImport "strings" }} +{{ reserveImport "sync" }} + +{{ reserveImport "github.com/niko0xdev/gqlgen/plugin/federation/fedruntime" }} + +var ( + ErrUnknownType = errors.New("unknown type") + ErrTypeNotFound = errors.New("type not found") +) + +func (ec *executionContext) __resolve__service(ctx context.Context) (fedruntime.Service, error) { + if ec.DisableIntrospection { + return fedruntime.Service{}, errors.New("federated introspection disabled") + } + + var sdl []string + + for _, src := range sources { + if src.BuiltIn { + continue + } + sdl = append(sdl, src.Input) + } + + return fedruntime.Service{ + SDL: strings.Join(sdl, "\n"), + }, nil +} + +{{if .Entities}} +func (ec *executionContext) __resolve_entities(ctx context.Context, representations []map[string]interface{}) []fedruntime.Entity { + list := make([]fedruntime.Entity, len(representations)) + + repsMap := map[string]struct { + i []int + r []map[string]interface{} + }{} + + // We group entities by typename so that we can parallelize their resolution. + // This is particularly helpful when there are entity groups in multi mode. + buildRepresentationGroups := func(reps []map[string]interface{}) { + for i, rep := range reps { + typeName, ok := rep["__typename"].(string) + if !ok { + // If there is no __typename, we just skip the representation; + // we just won't be resolving these unknown types. + ec.Error(ctx, errors.New("__typename must be an existing string")) + continue + } + + _r := repsMap[typeName] + _r.i = append(_r.i, i) + _r.r = append(_r.r, rep) + repsMap[typeName] = _r + } + } + + isMulti := func(typeName string) bool { + switch typeName { + {{- range .Entities -}} + {{- if .Resolvers -}} + {{- if .Multi -}} + case "{{.Def.Name}}": + return true + {{ end }} + {{- end -}} + {{- end -}} + default: + return false + } + } + + resolveEntity := func(ctx context.Context, typeName string, rep map[string]interface{}, idx []int, i int) (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) + } + }() + + switch typeName { + {{ range $_, $entity := .Entities }} + {{- if and .Resolvers (not .Multi) -}} + case "{{.Def.Name}}": + resolverName, err := entityResolverNameFor{{.Def.Name}}(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "{{.Def.Name}}": %w`, err) + } + switch resolverName { + {{ range $i, $resolver := .Resolvers }} + case "{{.ResolverName}}": + {{- range $j, $keyField := .KeyFields }} + id{{$j}}, err := ec.{{.Type.UnmarshalFunc}}(ctx, rep["{{.Field.Join `"].(map[string]interface{})["`}}"]) + if err != nil { + return fmt.Errorf(`unmarshalling param {{$j}} for {{$resolver.ResolverName}}(): %w`, err) + } + {{- end}} + entity, err := ec.resolvers.Entity().{{.ResolverName | go}}(ctx, {{- range $j, $_ := .KeyFields -}} id{{$j}}, {{end}}) + if err != nil { + return fmt.Errorf(`resolving Entity "{{$entity.Def.Name}}": %w`, err) + } + {{ range $entity.Requires }} + entity.{{.Field.JoinGo `.`}}, err = ec.{{.Type.UnmarshalFunc}}(ctx, rep["{{.Field.Join `"].(map[string]interface{})["`}}"]) + if err != nil { + return err + } + {{- end }} + list[idx[i]] = entity + return nil + {{- end }} + } + {{ end }} + {{- end }} + } + return fmt.Errorf("%w: %s", ErrUnknownType, typeName) + } + + resolveManyEntities := func(ctx context.Context, typeName string, reps []map[string]interface{}, idx []int) (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) + } + }() + + switch typeName { + {{ range $_, $entity := .Entities }} + {{ if and .Resolvers .Multi -}} + case "{{.Def.Name}}": + resolverName, err := entityResolverNameFor{{.Def.Name}}(ctx, reps[0]) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "{{.Def.Name}}": %w`, err) + } + switch resolverName { + {{ range $i, $resolver := .Resolvers }} + case "{{.ResolverName}}": + _reps := make([]*{{.LookupInputType}}, len(reps)) + + for i, rep := range reps { + {{ range $i, $keyField := .KeyFields -}} + id{{$i}}, err := ec.{{.Type.UnmarshalFunc}}(ctx, rep["{{.Field.Join `"].(map[string]interface{})["`}}"]) + if err != nil { + return errors.New(fmt.Sprintf("Field %s undefined in schema.", "{{.Definition.Name}}")) + } + {{end}} + + _reps[i] = &{{.LookupInputType}} { + {{ range $i, $keyField := .KeyFields -}} + {{$keyField.Field.ToGo}}: id{{$i}}, + {{end}} + } + } + + entities, err := ec.resolvers.Entity().{{.ResolverName | go}}(ctx, _reps) + if err != nil { + return err + } + + for i, entity := range entities { + {{- range $entity.Requires }} + entity.{{.Field.JoinGo `.`}}, err = ec.{{.Type.UnmarshalFunc}}(ctx, reps[i]["{{.Field.Join `"].(map[string]interface{})["`}}"]) + if err != nil { + return err + } + {{- end}} + list[idx[i]] = entity + } + return nil + {{ end }} + default: + return fmt.Errorf("unknown resolver: %s", resolverName) + } + {{ end }} + {{- end }} + default: + return errors.New("unknown type: "+typeName) + } + } + + resolveEntityGroup := func(typeName string, reps []map[string]interface{}, idx []int) { + if isMulti(typeName) { + err := resolveManyEntities(ctx, typeName, reps, idx) + if err != nil { + ec.Error(ctx, err) + } + } else { + // if there are multiple entities to resolve, parallelize (similar to + // graphql.FieldSet.Dispatch) + var e sync.WaitGroup + e.Add(len(reps)) + for i, rep := range reps { + i, rep := i, rep + go func(i int, rep map[string]interface{}) { + err := resolveEntity(ctx, typeName, rep, idx, i) + if err != nil { + ec.Error(ctx, err) + } + e.Done() + }(i, rep) + } + e.Wait() + } + } + buildRepresentationGroups(representations) + + switch len(repsMap) { + case 0: + return list + case 1: + for typeName, reps := range repsMap { + resolveEntityGroup(typeName, reps.r, reps.i) + } + return list + default: + var g sync.WaitGroup + g.Add(len(repsMap)) + for typeName, reps := range repsMap { + go func(typeName string, reps []map[string]interface{}, idx []int) { + resolveEntityGroup(typeName, reps, idx) + g.Done() + }(typeName, reps.r, reps.i) + } + g.Wait() + return list + } +} + +{{- /* Make sure the required fields are in the given entity representation and return the name of the proper resolver. */ -}} + +{{ range $_, $entity := .Entities }} + {{- if .Resolvers }} + + func entityResolverNameFor{{$entity.Name}}(ctx context.Context, rep map[string]interface{}) (string, error) { + {{- range .Resolvers }} + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + {{- range $_, $keyField := .KeyFields }} + m = rep + {{- range $i, $field := .Field }} + if {{ if (ne $i $keyField.Field.LastIndex ) -}}val{{- else -}}_{{- end -}}, ok = m["{{.}}"]; !ok { + break + } + {{- if (ne $i $keyField.Field.LastIndex ) }} + if m, ok = val.(map[string]interface{}); !ok { + break + } + {{- end}} + {{- end}} + {{- end }} + return "{{.ResolverName}}", nil + } + {{- end }} + return "", fmt.Errorf("%w for {{$entity.Name}}", ErrTypeNotFound) + } + {{- end }} +{{- end }} + +{{end}} diff --git a/plugin/federation/federation_entityresolver_test.go b/plugin/federation/federation_entityresolver_test.go new file mode 100644 index 0000000..ef95031 --- /dev/null +++ b/plugin/federation/federation_entityresolver_test.go @@ -0,0 +1,610 @@ +//go:generate go run ../../testdata/gqlgen.go -config testdata/entityresolver/gqlgen.yml +package federation + +import ( + "encoding/json" + "strconv" + "strings" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/client" + "github.com/niko0xdev/gqlgen/graphql/handler" + "github.com/niko0xdev/gqlgen/plugin/federation/testdata/entityresolver" + "github.com/niko0xdev/gqlgen/plugin/federation/testdata/entityresolver/generated" +) + +func TestEntityResolver(t *testing.T) { + c := client.New(handler.NewDefaultServer( + generated.NewExecutableSchema(generated.Config{ + Resolvers: &entityresolver.Resolver{}, + }), + )) + + t.Run("Hello entities", func(t *testing.T) { + representations := []map[string]interface{}{ + { + "__typename": "Hello", + "name": "first name - 1", + }, { + "__typename": "Hello", + "name": "first name - 2", + }, + } + + var resp struct { + Entities []struct { + Name string `json:"name"` + } `json:"_entities"` + } + + err := c.Post( + entityQuery([]string{ + "Hello {name}", + }), + &resp, + client.Var("representations", representations), + ) + + require.NoError(t, err) + require.Equal(t, resp.Entities[0].Name, "first name - 1") + require.Equal(t, resp.Entities[1].Name, "first name - 2") + }) + + t.Run("HelloWithError entities", func(t *testing.T) { + representations := []map[string]interface{}{ + { + "__typename": "HelloWithErrors", + "name": "first name - 1", + }, { + "__typename": "HelloWithErrors", + "name": "first name - 2", + }, { + "__typename": "HelloWithErrors", + "name": "inject error", + }, { + "__typename": "HelloWithErrors", + "name": "first name - 3", + }, { + "__typename": "HelloWithErrors", + "name": "", + }, + } + + var resp struct { + Entities []struct { + Name string `json:"name"` + } `json:"_entities"` + } + + err := c.Post( + entityQuery([]string{ + "HelloWithErrors {name}", + }), + &resp, + client.Var("representations", representations), + ) + + require.Error(t, err) + entityErrors, err := getEntityErrors(err) + require.NoError(t, err) + require.Len(t, entityErrors, 2) + errMessages := []string{ + entityErrors[0].Message, + entityErrors[1].Message, + } + + require.Contains(t, errMessages, "resolving Entity \"HelloWithErrors\": error (empty key) resolving HelloWithErrorsByName") + require.Contains(t, errMessages, "resolving Entity \"HelloWithErrors\": error resolving HelloWithErrorsByName") + + require.Len(t, resp.Entities, 5) + require.Equal(t, resp.Entities[0].Name, "first name - 1") + require.Equal(t, resp.Entities[1].Name, "first name - 2") + require.Equal(t, resp.Entities[2].Name, "") + require.Equal(t, resp.Entities[3].Name, "first name - 3") + require.Equal(t, resp.Entities[4].Name, "") + }) + + t.Run("World entities with nested key", func(t *testing.T) { + representations := []map[string]interface{}{ + { + "__typename": "World", + "hello": map[string]interface{}{ + "name": "world name - 1", + }, + "foo": "foo 1", + }, { + "__typename": "World", + "hello": map[string]interface{}{ + "name": "world name - 2", + }, + "foo": "foo 2", + }, + } + + var resp struct { + Entities []struct { + Foo string `json:"foo"` + Hello struct { + Name string `json:"name"` + } `json:"hello"` + } `json:"_entities"` + } + + err := c.Post( + entityQuery([]string{ + "World {foo hello {name}}", + }), + &resp, + client.Var("representations", representations), + ) + + require.NoError(t, err) + require.Equal(t, resp.Entities[0].Foo, "foo 1") + require.Equal(t, resp.Entities[0].Hello.Name, "world name - 1") + require.Equal(t, resp.Entities[1].Foo, "foo 2") + require.Equal(t, resp.Entities[1].Hello.Name, "world name - 2") + }) + + t.Run("World entities with multiple keys", func(t *testing.T) { + representations := []map[string]interface{}{ + { + "__typename": "WorldWithMultipleKeys", + "hello": map[string]interface{}{ + "name": "world name - 1", + }, + "foo": "foo 1", + }, { + "__typename": "WorldWithMultipleKeys", + "bar": 11, + }, + } + + var resp struct { + Entities []struct { + Foo string `json:"foo"` + Hello struct { + Name string `json:"name"` + } `json:"hello"` + Bar int `json:"bar"` + } `json:"_entities"` + } + + err := c.Post( + entityQuery([]string{ + "WorldWithMultipleKeys {foo hello {name}}", + "WorldWithMultipleKeys {bar}", + }), + &resp, + client.Var("representations", representations), + ) + + require.NoError(t, err) + require.Equal(t, resp.Entities[0].Foo, "foo 1") + require.Equal(t, resp.Entities[0].Hello.Name, "world name - 1") + require.Equal(t, resp.Entities[1].Bar, 11) + }) + + t.Run("Hello WorldName entities (heterogeneous)", func(t *testing.T) { + // Entity resolution can handle heterogenenous representations. Meaning, + // the representations for resolving entities can be of different + // __typename. So the tests here will interleve two different entity + // types so that we can test support for resolving different types and + // correctly handle ordering. + representations := []map[string]interface{}{} + count := 10 + + for i := 0; i < count; i++ { + if i%2 == 0 { + representations = append(representations, map[string]interface{}{ + "__typename": "Hello", + "name": "hello - " + strconv.Itoa(i), + }) + } else { + representations = append(representations, map[string]interface{}{ + "__typename": "WorldName", + "name": "world name - " + strconv.Itoa(i), + }) + } + } + + var resp struct { + Entities []struct { + Name string `json:"name"` + } `json:"_entities"` + } + + err := c.Post( + entityQuery([]string{ + "Hello {name}", + "WorldName {name}", + }), + &resp, + client.Var("representations", representations), + ) + + require.NoError(t, err) + require.Len(t, resp.Entities, count) + + for i := 0; i < count; i++ { + if i%2 == 0 { + require.Equal(t, resp.Entities[i].Name, "hello - "+strconv.Itoa(i)) + } else { + require.Equal(t, resp.Entities[i].Name, "world name - "+strconv.Itoa(i)) + } + } + }) + + t.Run("PlanetRequires entities with requires directive", func(t *testing.T) { + representations := []map[string]interface{}{ + { + "__typename": "PlanetRequires", + "name": "earth", + "diameter": 12, + }, { + "__typename": "PlanetRequires", + "name": "mars", + "diameter": 10, + }, + } + + var resp struct { + Entities []struct { + Name string `json:"name"` + Diameter int `json:"diameter"` + } `json:"_entities"` + } + + err := c.Post( + entityQuery([]string{ + "PlanetRequires {name, diameter}", + }), + &resp, + client.Var("representations", representations), + ) + + require.NoError(t, err) + require.Equal(t, resp.Entities[0].Name, "earth") + require.Equal(t, resp.Entities[0].Diameter, 12) + require.Equal(t, resp.Entities[1].Name, "mars") + require.Equal(t, resp.Entities[1].Diameter, 10) + }) + + t.Run("PlanetRequires entities with multiple required fields directive", func(t *testing.T) { + representations := []map[string]interface{}{ + { + "__typename": "PlanetMultipleRequires", + "name": "earth", + "density": 800, + "diameter": 12, + }, { + "__typename": "PlanetMultipleRequires", + "name": "mars", + "density": 850, + "diameter": 10, + }, + } + + var resp struct { + Entities []struct { + Name string `json:"name"` + Density int `json:"density"` + Diameter int `json:"diameter"` + } `json:"_entities"` + } + + err := c.Post( + entityQuery([]string{ + "PlanetMultipleRequires {name, diameter, density}", + }), + &resp, + client.Var("representations", representations), + ) + + require.NoError(t, err) + require.Equal(t, resp.Entities[0].Name, "earth") + require.Equal(t, resp.Entities[0].Diameter, 12) + require.Equal(t, resp.Entities[0].Density, 800) + require.Equal(t, resp.Entities[1].Name, "mars") + require.Equal(t, resp.Entities[1].Diameter, 10) + require.Equal(t, resp.Entities[1].Density, 850) + }) + + t.Run("PlanetRequiresNested entities with requires directive having nested field", func(t *testing.T) { + representations := []map[string]interface{}{ + { + "__typename": "PlanetRequiresNested", + "name": "earth", + "world": map[string]interface{}{ + "foo": "A", + }, + }, { + "__typename": "PlanetRequiresNested", + "name": "mars", + "world": map[string]interface{}{ + "foo": "B", + }, + }, + } + + var resp struct { + Entities []struct { + Name string `json:"name"` + World struct { + Foo string `json:"foo"` + } `json:"world"` + } `json:"_entities"` + } + + err := c.Post( + entityQuery([]string{ + "PlanetRequiresNested {name, world { foo }}", + }), + &resp, + client.Var("representations", representations), + ) + + require.NoError(t, err) + require.Equal(t, resp.Entities[0].Name, "earth") + require.Equal(t, resp.Entities[0].World.Foo, "A") + require.Equal(t, resp.Entities[1].Name, "mars") + require.Equal(t, resp.Entities[1].World.Foo, "B") + }) +} + +func TestMultiEntityResolver(t *testing.T) { + c := client.New(handler.NewDefaultServer( + generated.NewExecutableSchema(generated.Config{ + Resolvers: &entityresolver.Resolver{}, + }), + )) + + t.Run("MultiHello entities", func(t *testing.T) { + itemCount := 10 + representations := []map[string]interface{}{} + + for i := 0; i < itemCount; i++ { + representations = append(representations, map[string]interface{}{ + "__typename": "MultiHello", + "name": "world name - " + strconv.Itoa(i), + }) + } + + var resp struct { + Entities []struct { + Name string `json:"name"` + } `json:"_entities"` + } + + err := c.Post( + entityQuery([]string{ + "MultiHello {name}", + }), + &resp, + client.Var("representations", representations), + ) + + require.NoError(t, err) + + for i := 0; i < itemCount; i++ { + require.Equal(t, resp.Entities[i].Name, "world name - "+strconv.Itoa(i)+" - from multiget") + } + }) + + t.Run("MultiHello and Hello (heterogeneous) entities", func(t *testing.T) { + itemCount := 20 + representations := []map[string]interface{}{} + + for i := 0; i < itemCount; i++ { + // Let's interleve the representations to test ordering of the + // responses from the entity query + if i%2 == 0 { + representations = append(representations, map[string]interface{}{ + "__typename": "MultiHello", + "name": "world name - " + strconv.Itoa(i), + }) + } else { + representations = append(representations, map[string]interface{}{ + "__typename": "Hello", + "name": "hello - " + strconv.Itoa(i), + }) + } + } + + var resp struct { + Entities []struct { + Name string `json:"name"` + } `json:"_entities"` + } + + err := c.Post( + entityQuery([]string{ + "MultiHello {name}", + "Hello {name}", + }), + &resp, + client.Var("representations", representations), + ) + + require.NoError(t, err) + + for i := 0; i < itemCount; i++ { + if i%2 == 0 { + require.Equal(t, resp.Entities[i].Name, "world name - "+strconv.Itoa(i)+" - from multiget") + } else { + require.Equal(t, resp.Entities[i].Name, "hello - "+strconv.Itoa(i)) + } + } + }) + + t.Run("MultiHelloWithError entities", func(t *testing.T) { + itemCount := 10 + representations := []map[string]interface{}{} + + for i := 0; i < itemCount; i++ { + representations = append(representations, map[string]interface{}{ + "__typename": "MultiHelloWithError", + "name": "world name - " + strconv.Itoa(i), + }) + } + + var resp struct { + Entities []struct { + Name string `json:"name"` + } `json:"_entities"` + } + + err := c.Post( + entityQuery([]string{ + "MultiHelloWithError {name}", + }), + &resp, + client.Var("representations", representations), + ) + + require.Error(t, err) + entityErrors, err := getEntityErrors(err) + require.NoError(t, err) + require.Len(t, entityErrors, 1) + require.Contains(t, entityErrors[0].Message, "error resolving MultiHelloWorldWithError") + }) + + t.Run("MultiHelloRequires entities with requires directive", func(t *testing.T) { + representations := []map[string]interface{}{ + { + "__typename": "MultiHelloRequires", + "name": "first name - 1", + "key1": "key1 - 1", + }, { + "__typename": "MultiHelloRequires", + "name": "first name - 2", + "key1": "key1 - 2", + }, + } + + var resp struct { + Entities []struct { + Name string `json:"name"` + Key1 string `json:"key1"` + } `json:"_entities"` + } + + err := c.Post( + entityQuery([]string{ + "MultiHelloRequires {name, key1}", + }), + &resp, + client.Var("representations", representations), + ) + + require.NoError(t, err) + require.Equal(t, resp.Entities[0].Name, "first name - 1") + require.Equal(t, resp.Entities[0].Key1, "key1 - 1") + require.Equal(t, resp.Entities[1].Name, "first name - 2") + require.Equal(t, resp.Entities[1].Key1, "key1 - 2") + }) + + t.Run("MultiHelloMultipleRequires entities with multiple required fields", func(t *testing.T) { + representations := []map[string]interface{}{ + { + "__typename": "MultiHelloMultipleRequires", + "name": "first name - 1", + "key1": "key1 - 1", + "key2": "key2 - 1", + }, { + "__typename": "MultiHelloMultipleRequires", + "name": "first name - 2", + "key1": "key1 - 2", + "key2": "key2 - 2", + }, + } + + var resp struct { + Entities []struct { + Name string `json:"name"` + Key1 string `json:"key1"` + Key2 string `json:"key2"` + } `json:"_entities"` + } + + err := c.Post( + entityQuery([]string{ + "MultiHelloMultipleRequires {name, key1, key2}", + }), + &resp, + client.Var("representations", representations), + ) + + require.NoError(t, err) + require.Equal(t, resp.Entities[0].Name, "first name - 1") + require.Equal(t, resp.Entities[0].Key1, "key1 - 1") + require.Equal(t, resp.Entities[0].Key2, "key2 - 1") + require.Equal(t, resp.Entities[1].Name, "first name - 2") + require.Equal(t, resp.Entities[1].Key1, "key1 - 2") + require.Equal(t, resp.Entities[1].Key2, "key2 - 2") + }) + + t.Run("MultiPlanetRequiresNested entities with requires directive having nested field", func(t *testing.T) { + representations := []map[string]interface{}{ + { + "__typename": "MultiPlanetRequiresNested", + "name": "earth", + "world": map[string]interface{}{ + "foo": "A", + }, + }, { + "__typename": "MultiPlanetRequiresNested", + "name": "mars", + "world": map[string]interface{}{ + "foo": "B", + }, + }, + } + + var resp struct { + Entities []struct { + Name string `json:"name"` + World struct { + Foo string `json:"foo"` + } `json:"world"` + } `json:"_entities"` + } + + err := c.Post( + entityQuery([]string{ + "MultiPlanetRequiresNested {name, world { foo }}", + }), + &resp, + client.Var("representations", representations), + ) + + require.NoError(t, err) + require.Equal(t, resp.Entities[0].Name, "earth") + require.Equal(t, resp.Entities[0].World.Foo, "A") + require.Equal(t, resp.Entities[1].Name, "mars") + require.Equal(t, resp.Entities[1].World.Foo, "B") + }) +} + +func entityQuery(queries []string) string { + // What we want! + // query($representations:[_Any!]!){_entities(representations:$representations){ ...on Hello{secondary} }} + entityQueries := make([]string, len(queries)) + for i, query := range queries { + entityQueries[i] = " ... on " + query + } + + return "query($representations:[_Any!]!){_entities(representations:$representations){" + strings.Join(entityQueries, "") + "}}" +} + +type entityResolverError struct { + Message string `json:"message"` + Path []string `json:"path"` +} + +func getEntityErrors(err error) ([]*entityResolverError, error) { + var errors []*entityResolverError + err = json.Unmarshal([]byte(err.Error()), &errors) + return errors, err +} diff --git a/plugin/federation/federation_test.go b/plugin/federation/federation_test.go new file mode 100644 index 0000000..9f86e89 --- /dev/null +++ b/plugin/federation/federation_test.go @@ -0,0 +1,274 @@ +package federation + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/codegen" + "github.com/niko0xdev/gqlgen/codegen/config" +) + +func TestWithEntities(t *testing.T) { + f, cfg := load(t, "testdata/allthethings/gqlgen.yml") + + require.Equal(t, []string{"ExternalExtension", "Hello", "MoreNesting", "MultiHelloMultiKey", "NestedKey", "VeryNestedKey", "World"}, cfg.Schema.Types["_Entity"].Types) + + require.Len(t, cfg.Schema.Types["Entity"].Fields, 8) + + require.Equal(t, "findExternalExtensionByUpc", cfg.Schema.Types["Entity"].Fields[0].Name) + require.Equal(t, "findHelloByName", cfg.Schema.Types["Entity"].Fields[1].Name) + // missing on purpose: all @external fields: + // require.Equal(t, "findMoreNestingByID", cfg.Schema.Types["Entity"].Fields[2].Name) + require.Equal(t, "findManyMultiHelloMultiKeyByNames", cfg.Schema.Types["Entity"].Fields[2].Name) + require.Equal(t, "findManyMultiHelloMultiKeyByKey2s", cfg.Schema.Types["Entity"].Fields[3].Name) + require.Equal(t, "findNestedKeyByIDAndHelloName", cfg.Schema.Types["Entity"].Fields[4].Name) + require.Equal(t, "findVeryNestedKeyByIDAndHelloNameAndWorldFooAndWorldBarAndMoreWorldFoo", cfg.Schema.Types["Entity"].Fields[5].Name) + require.Equal(t, "findWorldByFoo", cfg.Schema.Types["Entity"].Fields[6].Name) + require.Equal(t, "findWorldByBar", cfg.Schema.Types["Entity"].Fields[7].Name) + + require.NoError(t, f.MutateConfig(cfg)) + + require.Len(t, f.Entities, 7) + + require.Equal(t, "ExternalExtension", f.Entities[0].Name) + require.Len(t, f.Entities[0].Resolvers, 1) + require.Len(t, f.Entities[0].Resolvers[0].KeyFields, 1) + require.Equal(t, "upc", f.Entities[0].Resolvers[0].KeyFields[0].Definition.Name) + require.Equal(t, "String", f.Entities[0].Resolvers[0].KeyFields[0].Definition.Type.Name()) + + require.Equal(t, "Hello", f.Entities[1].Name) + require.Len(t, f.Entities[1].Resolvers, 1) + require.Len(t, f.Entities[1].Resolvers[0].KeyFields, 1) + require.Equal(t, "name", f.Entities[1].Resolvers[0].KeyFields[0].Definition.Name) + require.Equal(t, "String", f.Entities[1].Resolvers[0].KeyFields[0].Definition.Type.Name()) + + require.Equal(t, "MoreNesting", f.Entities[2].Name) + require.Len(t, f.Entities[2].Resolvers, 0) + + require.Equal(t, "MultiHelloMultiKey", f.Entities[3].Name) + require.Len(t, f.Entities[3].Resolvers, 2) + require.Len(t, f.Entities[3].Resolvers[0].KeyFields, 1) + require.Len(t, f.Entities[3].Resolvers[1].KeyFields, 1) + require.Equal(t, "name", f.Entities[3].Resolvers[0].KeyFields[0].Definition.Name) + require.Equal(t, "String", f.Entities[3].Resolvers[0].KeyFields[0].Definition.Type.Name()) + require.Equal(t, "key2", f.Entities[3].Resolvers[1].KeyFields[0].Definition.Name) + require.Equal(t, "String", f.Entities[3].Resolvers[1].KeyFields[0].Definition.Type.Name()) + + require.Equal(t, "NestedKey", f.Entities[4].Name) + require.Len(t, f.Entities[4].Resolvers, 1) + require.Len(t, f.Entities[4].Resolvers[0].KeyFields, 2) + require.Equal(t, "id", f.Entities[4].Resolvers[0].KeyFields[0].Definition.Name) + require.Equal(t, "String", f.Entities[4].Resolvers[0].KeyFields[0].Definition.Type.Name()) + require.Equal(t, "helloName", f.Entities[4].Resolvers[0].KeyFields[1].Definition.Name) + require.Equal(t, "String", f.Entities[4].Resolvers[0].KeyFields[1].Definition.Type.Name()) + + require.Equal(t, "VeryNestedKey", f.Entities[5].Name) + require.Len(t, f.Entities[5].Resolvers, 1) + require.Len(t, f.Entities[5].Resolvers[0].KeyFields, 5) + require.Equal(t, "id", f.Entities[5].Resolvers[0].KeyFields[0].Definition.Name) + require.Equal(t, "String", f.Entities[5].Resolvers[0].KeyFields[0].Definition.Type.Name()) + require.Equal(t, "helloName", f.Entities[5].Resolvers[0].KeyFields[1].Definition.Name) + require.Equal(t, "String", f.Entities[5].Resolvers[0].KeyFields[1].Definition.Type.Name()) + require.Equal(t, "worldFoo", f.Entities[5].Resolvers[0].KeyFields[2].Definition.Name) + require.Equal(t, "String", f.Entities[5].Resolvers[0].KeyFields[2].Definition.Type.Name()) + require.Equal(t, "worldBar", f.Entities[5].Resolvers[0].KeyFields[3].Definition.Name) + require.Equal(t, "Int", f.Entities[5].Resolvers[0].KeyFields[3].Definition.Type.Name()) + require.Equal(t, "moreWorldFoo", f.Entities[5].Resolvers[0].KeyFields[4].Definition.Name) + require.Equal(t, "String", f.Entities[5].Resolvers[0].KeyFields[4].Definition.Type.Name()) + + require.Len(t, f.Entities[5].Requires, 2) + require.Equal(t, f.Entities[5].Requires[0].Name, "id") + require.Equal(t, f.Entities[5].Requires[1].Name, "helloSecondary") + + require.Equal(t, "World", f.Entities[6].Name) + require.Len(t, f.Entities[6].Resolvers, 2) + require.Len(t, f.Entities[6].Resolvers[0].KeyFields, 1) + require.Equal(t, "foo", f.Entities[6].Resolvers[0].KeyFields[0].Definition.Name) + require.Equal(t, "String", f.Entities[6].Resolvers[0].KeyFields[0].Definition.Type.Name()) + require.Len(t, f.Entities[6].Resolvers[1].KeyFields, 1) + require.Equal(t, "bar", f.Entities[6].Resolvers[1].KeyFields[0].Definition.Name) + require.Equal(t, "Int", f.Entities[6].Resolvers[1].KeyFields[0].Definition.Type.Name()) +} + +func TestNoEntities(t *testing.T) { + f, cfg := load(t, "testdata/entities/nokey.yml") + + err := f.MutateConfig(cfg) + require.NoError(t, err) + require.Len(t, f.Entities, 0) +} + +func TestUnusedInterfaceKeyDirective(t *testing.T) { + f, cfg := load(t, "testdata/interfaces/unused_key.yml") + + err := f.MutateConfig(cfg) + require.NoError(t, err) + require.Len(t, f.Entities, 0) +} + +func TestInterfaceKeyDirective(t *testing.T) { + f, cfg := load(t, "testdata/interfaces/key.yml") + + err := f.MutateConfig(cfg) + require.NoError(t, err) + require.Len(t, cfg.Schema.Types["_Entity"].Types, 1) + require.Len(t, f.Entities, 2) +} + +func TestInterfaceExtendsDirective(t *testing.T) { + require.Panics(t, func() { + load(t, "testdata/interfaces/extends.yml") + }) +} + +func TestEntityInterfaces(t *testing.T) { + f, cfg := load(t, "testdata/entityinterfaces/interface.yml") + err := f.MutateConfig(cfg) + + require.NoError(t, err) + require.Len(t, f.Entities[0].Resolvers, 1) + require.Equal(t, "Hello", f.Entities[0].Name) + require.NotEmpty(t, f.Entities[1].Resolvers) +} + +func TestCodeGeneration(t *testing.T) { + f, cfg := load(t, "testdata/allthethings/gqlgen.yml") + + require.Len(t, cfg.Schema.Types["_Entity"].Types, 7) + require.Len(t, f.Entities, 7) + + require.NoError(t, f.MutateConfig(cfg)) + + data, err := codegen.BuildData(cfg) + if err != nil { + panic(err) + } + require.NoError(t, f.GenerateCode(data)) +} + +func TestCodeGenerationFederation2(t *testing.T) { + f, cfg := load(t, "testdata/federation2/federation2.yml") + err := f.MutateConfig(cfg) + + require.NoError(t, err) + require.Equal(t, "ExternalExtension", f.Entities[0].Name) + require.Len(t, f.Entities[0].Resolvers, 1) + require.Equal(t, "Hello", f.Entities[1].Name) + require.Empty(t, f.Entities[1].Resolvers) + require.Equal(t, "World", f.Entities[2].Name) + require.Empty(t, f.Entities[2].Resolvers) + + data, err := codegen.BuildData(cfg) + if err != nil { + panic(err) + } + require.NoError(t, f.GenerateCode(data)) +} + +// This test is to ensure that the input arguments are not +// changed when cfg.OmitSliceElementPointers is false OR true +func TestMultiWithOmitSliceElemPointersCfg(t *testing.T) { + + staticRepsString := "reps: [HelloByNamesInput]!" + t.Run("OmitSliceElementPointers true", func(t *testing.T) { + f, cfg := load(t, "testdata/multi/multi.yml") + cfg.OmitSliceElementPointers = true + err := f.MutateConfig(cfg) + require.NoError(t, err) + require.Len(t, cfg.Schema.Types["_Entity"].Types, 1) + require.Len(t, f.Entities, 1) + + entityGraphqlGenerated := false + for _, source := range cfg.Sources { + if source.Name != "federation/entity.graphql" { + continue + } + entityGraphqlGenerated = true + require.Contains(t, source.Input, staticRepsString) + } + require.True(t, entityGraphqlGenerated) + }) + + t.Run("OmitSliceElementPointers false", func(t *testing.T) { + f, cfg := load(t, "testdata/multi/multi.yml") + cfg.OmitSliceElementPointers = false + err := f.MutateConfig(cfg) + require.NoError(t, err) + require.Len(t, cfg.Schema.Types["_Entity"].Types, 1) + require.Len(t, f.Entities, 1) + + entityGraphqlGenerated := false + for _, source := range cfg.Sources { + if source.Name != "federation/entity.graphql" { + continue + } + entityGraphqlGenerated = true + require.Contains(t, source.Input, staticRepsString) + } + require.True(t, entityGraphqlGenerated) + }) +} + +func TestInjectSourceLate(t *testing.T) { + _, cfg := load(t, "testdata/allthethings/gqlgen.yml") + entityGraphqlGenerated := false + for _, source := range cfg.Sources { + if source.Name != "federation/entity.graphql" { + continue + } + entityGraphqlGenerated = true + require.Contains(t, source.Input, "union _Entity") + require.Contains(t, source.Input, "type _Service {") + require.Contains(t, source.Input, "extend type Query {") + require.Contains(t, source.Input, "_entities(representations: [_Any!]!): [_Entity]!") + require.Contains(t, source.Input, "_service: _Service!") + } + require.True(t, entityGraphqlGenerated) + + _, cfg = load(t, "testdata/entities/nokey.yml") + entityGraphqlGenerated = false + for _, source := range cfg.Sources { + if source.Name != "federation/entity.graphql" { + continue + } + entityGraphqlGenerated = true + require.NotContains(t, source.Input, "union _Entity") + require.Contains(t, source.Input, "type _Service {") + require.Contains(t, source.Input, "extend type Query {") + require.NotContains(t, source.Input, "_entities(representations: [_Any!]!): [_Entity]!") + require.Contains(t, source.Input, "_service: _Service!") + } + require.True(t, entityGraphqlGenerated) + + _, cfg = load(t, "testdata/schema/customquerytype.yml") + for _, source := range cfg.Sources { + if source.Name != "federation/entity.graphql" { + continue + } + require.Contains(t, source.Input, "extend type CustomQuery {") + } +} + +func load(t *testing.T, name string) (*federation, *config.Config) { + t.Helper() + + cfg, err := config.LoadConfig(name) + require.NoError(t, err) + + if cfg.Federation.Version == 0 { + cfg.Federation.Version = 1 + } + + f := &federation{Version: cfg.Federation.Version} + cfg.Sources = append(cfg.Sources, f.InjectSourceEarly()) + require.NoError(t, cfg.LoadSchema()) + + if src := f.InjectSourceLate(cfg.Schema); src != nil { + cfg.Sources = append(cfg.Sources, src) + } + require.NoError(t, cfg.LoadSchema()) + + require.NoError(t, cfg.Init()) + return f, cfg +} diff --git a/plugin/federation/fedruntime/runtime.go b/plugin/federation/fedruntime/runtime.go new file mode 100644 index 0000000..e5e9400 --- /dev/null +++ b/plugin/federation/fedruntime/runtime.go @@ -0,0 +1,16 @@ +package fedruntime + +// Service is the service object that the +// generated.go file will return for the _service +// query +type Service struct { + SDL string `json:"sdl"` +} + +// Everything with a @key implements this +type Entity interface { + IsEntity() +} + +// Used for the Link directive +type Link interface{} diff --git a/plugin/federation/fieldset/fieldset.go b/plugin/federation/fieldset/fieldset.go new file mode 100644 index 0000000..05fadd0 --- /dev/null +++ b/plugin/federation/fieldset/fieldset.go @@ -0,0 +1,182 @@ +package fieldset + +import ( + "fmt" + "strings" + + "github.com/vektah/gqlparser/v2/ast" + + "github.com/niko0xdev/gqlgen/codegen" + "github.com/niko0xdev/gqlgen/codegen/templates" +) + +// Set represents a FieldSet that is used in federation directives @key and @requires. +// Would be happier to reuse FieldSet parsing from gqlparser, but this suits for now. +type Set []Field + +// Field represents a single field in a FieldSet +type Field []string + +// New parses a FieldSet string into a TinyFieldSet. +func New(raw string, prefix []string) Set { + if !strings.Contains(raw, "{") { + return parseUnnestedKeyFieldSet(raw, prefix) + } + + var ( + ret = Set{} + subPrefix = prefix + ) + before, during, after := extractSubs(raw) + + if before != "" { + befores := New(before, prefix) + if len(befores) > 0 { + subPrefix = befores[len(befores)-1] + ret = append(ret, befores[:len(befores)-1]...) + } + } + if during != "" { + ret = append(ret, New(during, subPrefix)...) + } + if after != "" { + ret = append(ret, New(after, prefix)...) + } + return ret +} + +// FieldDefinition looks up a field in the type. +func (f Field) FieldDefinition(schemaType *ast.Definition, schema *ast.Schema) *ast.FieldDefinition { + objType := schemaType + def := objType.Fields.ForName(f[0]) + + for _, part := range f[1:] { + if objType.Kind != ast.Object { + panic(fmt.Sprintf(`invalid sub-field reference "%s" in %v: `, objType.Name, f)) + } + x := def.Type.Name() + objType = schema.Types[x] + if objType == nil { + panic("invalid schema type: " + x) + } + def = objType.Fields.ForName(part) + } + if def == nil { + return nil + } + ret := *def // shallow copy + ret.Name = f.ToGoPrivate() + + return &ret +} + +// TypeReference looks up the type of a field. +func (f Field) TypeReference(obj *codegen.Object, objects codegen.Objects) *codegen.Field { + var def *codegen.Field + + for _, part := range f { + def = fieldByName(obj, part) + if def == nil { + panic("unable to find field " + f[0]) + } + obj = objects.ByName(def.TypeReference.Definition.Name) + } + return def +} + +// ToGo converts a (possibly nested) field into a proper public Go name. +func (f Field) ToGo() string { + var ret string + + for _, field := range f { + ret += templates.ToGo(field) + } + return ret +} + +// ToGoPrivate converts a (possibly nested) field into a proper private Go name. +func (f Field) ToGoPrivate() string { + var ret string + + for i, field := range f { + if i == 0 { + ret += templates.ToGoPrivate(field) + continue + } + ret += templates.ToGo(field) + } + return ret +} + +// Join concatenates the field parts with a string separator between. Useful in templates. +func (f Field) Join(str string) string { + return strings.Join(f, str) +} + +// JoinGo concatenates the Go name of field parts with a string separator between. Useful in templates. +func (f Field) JoinGo(str string) string { + strs := []string{} + + for _, s := range f { + strs = append(strs, templates.ToGo(s)) + } + return strings.Join(strs, str) +} + +func (f Field) LastIndex() int { + return len(f) - 1 +} + +// local functions + +// parseUnnestedKeyFieldSet // handles simple case where none of the fields are nested. +func parseUnnestedKeyFieldSet(raw string, prefix []string) Set { + ret := Set{} + + for _, s := range strings.Fields(raw) { + next := append(prefix[0:len(prefix):len(prefix)], s) //nolint:gocritic // set cap=len in order to force slice reallocation + ret = append(ret, next) + } + return ret +} + +// extractSubs splits out and trims sub-expressions from before, inside, and after "{}". +func extractSubs(str string) (string, string, string) { + start := strings.Index(str, "{") + end := matchingBracketIndex(str, start) + + if start < 0 || end < 0 { + panic("invalid key fieldSet: " + str) + } + return strings.TrimSpace(str[:start]), strings.TrimSpace(str[start+1 : end]), strings.TrimSpace(str[end+1:]) +} + +// matchingBracketIndex returns the index of the closing bracket, assuming an open bracket at start. +func matchingBracketIndex(str string, start int) int { + if start < 0 || len(str) <= start+1 { + return -1 + } + var depth int + + for i, c := range str[start+1:] { + switch c { + case '{': + depth++ + case '}': + if depth == 0 { + return start + 1 + i + } + depth-- + } + } + return -1 +} + +func fieldByName(obj *codegen.Object, name string) *codegen.Field { + for _, field := range obj.Fields { + if field.Name == name { + return field + } + } + return nil +} diff --git a/plugin/federation/fieldset/fieldset_test.go b/plugin/federation/fieldset/fieldset_test.go new file mode 100644 index 0000000..c1af874 --- /dev/null +++ b/plugin/federation/fieldset/fieldset_test.go @@ -0,0 +1,95 @@ +package fieldset + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestUnnestedWithoutPrefix(t *testing.T) { + fieldSet := New("foo bar", nil) + + require.Len(t, fieldSet, 2) + + require.Len(t, fieldSet[0], 1) + require.Equal(t, "foo", fieldSet[0][0]) + + require.Len(t, fieldSet[1], 1) + require.Equal(t, "bar", fieldSet[1][0]) +} + +func TestNestedWithoutPrefix(t *testing.T) { + fieldSet := New("foo bar { baz} a b {c{d}}e", nil) + + require.Len(t, fieldSet, 5) + + require.Len(t, fieldSet[0], 1) + require.Equal(t, "foo", fieldSet[0][0]) + + require.Len(t, fieldSet[1], 2) + require.Equal(t, "bar", fieldSet[1][0]) + require.Equal(t, "baz", fieldSet[1][1]) + + require.Len(t, fieldSet[2], 1) + require.Equal(t, "a", fieldSet[2][0]) + + require.Len(t, fieldSet[3], 3) + require.Equal(t, "b", fieldSet[3][0]) + require.Equal(t, "c", fieldSet[3][1]) + require.Equal(t, "d", fieldSet[3][2]) + + require.Len(t, fieldSet[4], 1) + require.Equal(t, "e", fieldSet[4][0]) +} + +func TestWithPrefix(t *testing.T) { + t.Run("prefix with len=capacity", func(t *testing.T) { + fieldSet := New("foo bar{id}", []string{"prefix"}) + + require.Len(t, fieldSet, 2) + + require.Len(t, fieldSet[0], 2) + require.Equal(t, "prefix", fieldSet[0][0]) + require.Equal(t, "foo", fieldSet[0][1]) + + require.Len(t, fieldSet[1], 3) + require.Equal(t, "prefix", fieldSet[1][0]) + require.Equal(t, "bar", fieldSet[1][1]) + require.Equal(t, "id", fieldSet[1][2]) + }) + t.Run("prefix with len<capacity", func(t *testing.T) { + prefix := make([]string, 0, 2) + prefix = append(prefix, "prefix") + fieldSet := New("foo bar{id}", prefix) + + require.Len(t, fieldSet, 2) + t.Log(fieldSet) + + require.Len(t, fieldSet[0], 2) + require.Equal(t, "prefix", fieldSet[0][0]) + require.Equal(t, "foo", fieldSet[0][1]) + + require.Len(t, fieldSet[1], 3) + require.Equal(t, "prefix", fieldSet[1][0]) + require.Equal(t, "bar", fieldSet[1][1]) + require.Equal(t, "id", fieldSet[1][2]) + }) +} + +func TestInvalid(t *testing.T) { + require.Panics(t, func() { + New("foo bar{baz", nil) + }) +} + +func TestToGo(t *testing.T) { + require.Equal(t, Field{"foo"}.ToGo(), "Foo") + require.Equal(t, Field{"foo", "bar"}.ToGo(), "FooBar") + require.Equal(t, Field{"bar", "id"}.ToGo(), "BarID") +} + +func TestToGoPrivate(t *testing.T) { + require.Equal(t, Field{"foo"}.ToGoPrivate(), "foo") + require.Equal(t, Field{"foo", "bar"}.ToGoPrivate(), "fooBar") + require.Equal(t, Field{"bar", "id"}.ToGoPrivate(), "barID") +} diff --git a/plugin/federation/readme.md b/plugin/federation/readme.md new file mode 100644 index 0000000..d5dd062 --- /dev/null +++ b/plugin/federation/readme.md @@ -0,0 +1,42 @@ +# Federation plugin + +Add support for graphql federation in your graphql Go server! + +TODO(miguel): add details. + +# Tests +There are several different tests. Some will process the configuration file directly. You can see those in the `federation_test.go`. There are also tests for entity resolvers, which will simulate requests from a federation server like Apollo Federation. + +Running entity resolver tests. +1. Go to `plugin/federation` +2. Run the command `go generate` +3. Run the tests with `go test ./...`. + +# Architecture + +TODO(miguel): add details. + +# Entity resolvers - GetMany entities + +The federation plugin implements `GetMany` semantics in which entity resolvers get the entire list of representations that need to be resolved. This functionality is currently optin tho, and to enable it you need to specify the directive `@entityResolver` in the federated entity you want this feature for. E.g. + +``` +directive @entityResolver(multi: Boolean) on OBJECT + +type MultiHello @key(fields: "name") @entityResolver(multi: true) { + name: String! +} +``` + +That allows the federation plugin to generate `GetMany` resolver function that can take a list of representations to be resolved. + +From that entity type, the resolver function would be + +``` +func (r *entityResolver) FindManyMultiHellosByName(ctx context.Context, reps []*generated.ManyMultiHellosByNameInput) ([]*generated.MultiHello, error) { + /// <Your code to resolve the list of items> +} +``` + +**Note:** +If you are using `omit_slice_element_pointers: true` option in your config yaml, your `GetMany` resolver will still generate in the example above the same signature `FindManyMultiHellosByName(ctx context.Context, reps []*generated.ManyMultiHellosByNameInput) ([]*generated.MultiHello, error)`. But all other instances will continue to honor `omit_slice_element_pointers: true` \ No newline at end of file diff --git a/plugin/federation/test_data/model/federation.go b/plugin/federation/test_data/model/federation.go new file mode 100644 index 0000000..9aba438 --- /dev/null +++ b/plugin/federation/test_data/model/federation.go @@ -0,0 +1,48 @@ +package model + +type _FieldSet string //nolint:deadcode,unused + +type Hello struct { + Name string + Secondary string +} + +func (Hello) IsEntity() {} + +type World struct { + Foo string + Bar int +} + +func (World) IsEntity() {} + +type ExternalExtension struct { + UPC string + Reviews []*World +} + +func (ExternalExtension) IsEntity() {} + +type NestedKey struct { + ID string + Hello *Hello +} + +func (NestedKey) IsEntity() {} + +type MoreNesting struct { + ID string + World *World +} + +func (MoreNesting) IsEntity() {} + +type VeryNestedKey struct { + ID string + Hello *Hello + World *World + Nested *NestedKey + More *MoreNesting +} + +func (VeryNestedKey) IsEntity() {} diff --git a/plugin/federation/test_data/model2/federation.go b/plugin/federation/test_data/model2/federation.go new file mode 100644 index 0000000..afa5cd6 --- /dev/null +++ b/plugin/federation/test_data/model2/federation.go @@ -0,0 +1,48 @@ +package model2 + +type FieldSet string //nolint:deadcode,unused + +type Hello struct { + Name string + Secondary string +} + +func (Hello) IsEntity() {} + +type World struct { + Foo string + Bar int +} + +func (World) IsEntity() {} + +type ExternalExtension struct { + UPC string + Reviews []*World +} + +func (ExternalExtension) IsEntity() {} + +type NestedKey struct { + ID string + Hello *Hello +} + +func (NestedKey) IsEntity() {} + +type MoreNesting struct { + ID string + World *World +} + +func (MoreNesting) IsEntity() {} + +type VeryNestedKey struct { + ID string + Hello *Hello + World *World + Nested *NestedKey + More *MoreNesting +} + +func (VeryNestedKey) IsEntity() {} diff --git a/plugin/federation/testdata/allthethings/generated/federation.go b/plugin/federation/testdata/allthethings/generated/federation.go new file mode 100644 index 0000000..50b0957 --- /dev/null +++ b/plugin/federation/testdata/allthethings/generated/federation.go @@ -0,0 +1,536 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package generated + +import ( + "context" + "errors" + "fmt" + "strings" + "sync" + + "github.com/niko0xdev/gqlgen/plugin/federation/fedruntime" + "github.com/niko0xdev/gqlgen/plugin/federation/testdata/allthethings/model" +) + +var ( + ErrUnknownType = errors.New("unknown type") + ErrTypeNotFound = errors.New("type not found") +) + +func (ec *executionContext) __resolve__service(ctx context.Context) (fedruntime.Service, error) { + if ec.DisableIntrospection { + return fedruntime.Service{}, errors.New("federated introspection disabled") + } + + var sdl []string + + for _, src := range sources { + if src.BuiltIn { + continue + } + sdl = append(sdl, src.Input) + } + + return fedruntime.Service{ + SDL: strings.Join(sdl, "\n"), + }, nil +} + +func (ec *executionContext) __resolve_entities(ctx context.Context, representations []map[string]interface{}) []fedruntime.Entity { + list := make([]fedruntime.Entity, len(representations)) + + repsMap := map[string]struct { + i []int + r []map[string]interface{} + }{} + + // We group entities by typename so that we can parallelize their resolution. + // This is particularly helpful when there are entity groups in multi mode. + buildRepresentationGroups := func(reps []map[string]interface{}) { + for i, rep := range reps { + typeName, ok := rep["__typename"].(string) + if !ok { + // If there is no __typename, we just skip the representation; + // we just won't be resolving these unknown types. + ec.Error(ctx, errors.New("__typename must be an existing string")) + continue + } + + _r := repsMap[typeName] + _r.i = append(_r.i, i) + _r.r = append(_r.r, rep) + repsMap[typeName] = _r + } + } + + isMulti := func(typeName string) bool { + switch typeName { + case "MultiHelloMultiKey": + return true + default: + return false + } + } + + resolveEntity := func(ctx context.Context, typeName string, rep map[string]interface{}, idx []int, i int) (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) + } + }() + + switch typeName { + case "ExternalExtension": + resolverName, err := entityResolverNameForExternalExtension(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "ExternalExtension": %w`, err) + } + switch resolverName { + + case "findExternalExtensionByUpc": + id0, err := ec.unmarshalNString2string(ctx, rep["upc"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findExternalExtensionByUpc(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindExternalExtensionByUpc(ctx, id0) + if err != nil { + return fmt.Errorf(`resolving Entity "ExternalExtension": %w`, err) + } + + list[idx[i]] = entity + return nil + } + case "Hello": + resolverName, err := entityResolverNameForHello(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "Hello": %w`, err) + } + switch resolverName { + + case "findHelloByName": + id0, err := ec.unmarshalNString2string(ctx, rep["name"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findHelloByName(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindHelloByName(ctx, id0) + if err != nil { + return fmt.Errorf(`resolving Entity "Hello": %w`, err) + } + + list[idx[i]] = entity + return nil + } + case "NestedKey": + resolverName, err := entityResolverNameForNestedKey(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "NestedKey": %w`, err) + } + switch resolverName { + + case "findNestedKeyByIDAndHelloName": + id0, err := ec.unmarshalNString2string(ctx, rep["id"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findNestedKeyByIDAndHelloName(): %w`, err) + } + id1, err := ec.unmarshalNString2string(ctx, rep["hello"].(map[string]interface{})["name"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 1 for findNestedKeyByIDAndHelloName(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindNestedKeyByIDAndHelloName(ctx, id0, id1) + if err != nil { + return fmt.Errorf(`resolving Entity "NestedKey": %w`, err) + } + + list[idx[i]] = entity + return nil + } + case "VeryNestedKey": + resolverName, err := entityResolverNameForVeryNestedKey(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "VeryNestedKey": %w`, err) + } + switch resolverName { + + case "findVeryNestedKeyByIDAndHelloNameAndWorldFooAndWorldBarAndMoreWorldFoo": + id0, err := ec.unmarshalNString2string(ctx, rep["id"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findVeryNestedKeyByIDAndHelloNameAndWorldFooAndWorldBarAndMoreWorldFoo(): %w`, err) + } + id1, err := ec.unmarshalNString2string(ctx, rep["hello"].(map[string]interface{})["name"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 1 for findVeryNestedKeyByIDAndHelloNameAndWorldFooAndWorldBarAndMoreWorldFoo(): %w`, err) + } + id2, err := ec.unmarshalNString2string(ctx, rep["world"].(map[string]interface{})["foo"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 2 for findVeryNestedKeyByIDAndHelloNameAndWorldFooAndWorldBarAndMoreWorldFoo(): %w`, err) + } + id3, err := ec.unmarshalNInt2int(ctx, rep["world"].(map[string]interface{})["bar"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 3 for findVeryNestedKeyByIDAndHelloNameAndWorldFooAndWorldBarAndMoreWorldFoo(): %w`, err) + } + id4, err := ec.unmarshalNString2string(ctx, rep["more"].(map[string]interface{})["world"].(map[string]interface{})["foo"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 4 for findVeryNestedKeyByIDAndHelloNameAndWorldFooAndWorldBarAndMoreWorldFoo(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindVeryNestedKeyByIDAndHelloNameAndWorldFooAndWorldBarAndMoreWorldFoo(ctx, id0, id1, id2, id3, id4) + if err != nil { + return fmt.Errorf(`resolving Entity "VeryNestedKey": %w`, err) + } + + entity.ID, err = ec.unmarshalNString2string(ctx, rep["id"]) + if err != nil { + return err + } + entity.Hello.Secondary, err = ec.unmarshalNString2string(ctx, rep["hello"].(map[string]interface{})["secondary"]) + if err != nil { + return err + } + list[idx[i]] = entity + return nil + } + case "World": + resolverName, err := entityResolverNameForWorld(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "World": %w`, err) + } + switch resolverName { + + case "findWorldByFoo": + id0, err := ec.unmarshalNString2string(ctx, rep["foo"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findWorldByFoo(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindWorldByFoo(ctx, id0) + if err != nil { + return fmt.Errorf(`resolving Entity "World": %w`, err) + } + + list[idx[i]] = entity + return nil + case "findWorldByBar": + id0, err := ec.unmarshalNInt2int(ctx, rep["bar"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findWorldByBar(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindWorldByBar(ctx, id0) + if err != nil { + return fmt.Errorf(`resolving Entity "World": %w`, err) + } + + list[idx[i]] = entity + return nil + } + + } + return fmt.Errorf("%w: %s", ErrUnknownType, typeName) + } + + resolveManyEntities := func(ctx context.Context, typeName string, reps []map[string]interface{}, idx []int) (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) + } + }() + + switch typeName { + + case "MultiHelloMultiKey": + resolverName, err := entityResolverNameForMultiHelloMultiKey(ctx, reps[0]) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "MultiHelloMultiKey": %w`, err) + } + switch resolverName { + + case "findManyMultiHelloMultiKeyByNames": + _reps := make([]*model.MultiHelloMultiKeyByNamesInput, len(reps)) + + for i, rep := range reps { + id0, err := ec.unmarshalNString2string(ctx, rep["name"]) + if err != nil { + return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name")) + } + + _reps[i] = &model.MultiHelloMultiKeyByNamesInput{ + Name: id0, + } + } + + entities, err := ec.resolvers.Entity().FindManyMultiHelloMultiKeyByNames(ctx, _reps) + if err != nil { + return err + } + + for i, entity := range entities { + list[idx[i]] = entity + } + return nil + + case "findManyMultiHelloMultiKeyByKey2s": + _reps := make([]*model.MultiHelloMultiKeyByKey2sInput, len(reps)) + + for i, rep := range reps { + id0, err := ec.unmarshalNString2string(ctx, rep["key2"]) + if err != nil { + return errors.New(fmt.Sprintf("Field %s undefined in schema.", "key2")) + } + + _reps[i] = &model.MultiHelloMultiKeyByKey2sInput{ + Key2: id0, + } + } + + entities, err := ec.resolvers.Entity().FindManyMultiHelloMultiKeyByKey2s(ctx, _reps) + if err != nil { + return err + } + + for i, entity := range entities { + list[idx[i]] = entity + } + return nil + + default: + return fmt.Errorf("unknown resolver: %s", resolverName) + } + + default: + return errors.New("unknown type: " + typeName) + } + } + + resolveEntityGroup := func(typeName string, reps []map[string]interface{}, idx []int) { + if isMulti(typeName) { + err := resolveManyEntities(ctx, typeName, reps, idx) + if err != nil { + ec.Error(ctx, err) + } + } else { + // if there are multiple entities to resolve, parallelize (similar to + // graphql.FieldSet.Dispatch) + var e sync.WaitGroup + e.Add(len(reps)) + for i, rep := range reps { + i, rep := i, rep + go func(i int, rep map[string]interface{}) { + err := resolveEntity(ctx, typeName, rep, idx, i) + if err != nil { + ec.Error(ctx, err) + } + e.Done() + }(i, rep) + } + e.Wait() + } + } + buildRepresentationGroups(representations) + + switch len(repsMap) { + case 0: + return list + case 1: + for typeName, reps := range repsMap { + resolveEntityGroup(typeName, reps.r, reps.i) + } + return list + default: + var g sync.WaitGroup + g.Add(len(repsMap)) + for typeName, reps := range repsMap { + go func(typeName string, reps []map[string]interface{}, idx []int) { + resolveEntityGroup(typeName, reps, idx) + g.Done() + }(typeName, reps.r, reps.i) + } + g.Wait() + return list + } +} + +func entityResolverNameForExternalExtension(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["upc"]; !ok { + break + } + return "findExternalExtensionByUpc", nil + } + return "", fmt.Errorf("%w for ExternalExtension", ErrTypeNotFound) +} + +func entityResolverNameForHello(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["name"]; !ok { + break + } + return "findHelloByName", nil + } + return "", fmt.Errorf("%w for Hello", ErrTypeNotFound) +} + +func entityResolverNameForMultiHelloMultiKey(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["name"]; !ok { + break + } + return "findManyMultiHelloMultiKeyByNames", nil + } + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["key2"]; !ok { + break + } + return "findManyMultiHelloMultiKeyByKey2s", nil + } + return "", fmt.Errorf("%w for MultiHelloMultiKey", ErrTypeNotFound) +} + +func entityResolverNameForNestedKey(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["id"]; !ok { + break + } + m = rep + if val, ok = m["hello"]; !ok { + break + } + if m, ok = val.(map[string]interface{}); !ok { + break + } + if _, ok = m["name"]; !ok { + break + } + return "findNestedKeyByIDAndHelloName", nil + } + return "", fmt.Errorf("%w for NestedKey", ErrTypeNotFound) +} + +func entityResolverNameForVeryNestedKey(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["id"]; !ok { + break + } + m = rep + if val, ok = m["hello"]; !ok { + break + } + if m, ok = val.(map[string]interface{}); !ok { + break + } + if _, ok = m["name"]; !ok { + break + } + m = rep + if val, ok = m["world"]; !ok { + break + } + if m, ok = val.(map[string]interface{}); !ok { + break + } + if _, ok = m["foo"]; !ok { + break + } + m = rep + if val, ok = m["world"]; !ok { + break + } + if m, ok = val.(map[string]interface{}); !ok { + break + } + if _, ok = m["bar"]; !ok { + break + } + m = rep + if val, ok = m["more"]; !ok { + break + } + if m, ok = val.(map[string]interface{}); !ok { + break + } + if val, ok = m["world"]; !ok { + break + } + if m, ok = val.(map[string]interface{}); !ok { + break + } + if _, ok = m["foo"]; !ok { + break + } + return "findVeryNestedKeyByIDAndHelloNameAndWorldFooAndWorldBarAndMoreWorldFoo", nil + } + return "", fmt.Errorf("%w for VeryNestedKey", ErrTypeNotFound) +} + +func entityResolverNameForWorld(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["foo"]; !ok { + break + } + return "findWorldByFoo", nil + } + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["bar"]; !ok { + break + } + return "findWorldByBar", nil + } + return "", fmt.Errorf("%w for World", ErrTypeNotFound) +} diff --git a/plugin/federation/testdata/allthethings/gqlgen.yml b/plugin/federation/testdata/allthethings/gqlgen.yml new file mode 100644 index 0000000..336975f --- /dev/null +++ b/plugin/federation/testdata/allthethings/gqlgen.yml @@ -0,0 +1,9 @@ +schema: + - "testdata/allthethings/schema.graphql" +exec: + filename: testdata/allthethings/generated/exec.go +federation: + filename: testdata/allthethings/generated/federation.go + +autobind: + - "github.com/niko0xdev/gqlgen/plugin/federation/testdata/allthethings/model" diff --git a/plugin/federation/testdata/allthethings/model/federation.go b/plugin/federation/testdata/allthethings/model/federation.go new file mode 100644 index 0000000..7836c21 --- /dev/null +++ b/plugin/federation/testdata/allthethings/model/federation.go @@ -0,0 +1,63 @@ +package model + +type _FieldSet string //nolint:deadcode,unused + +type Hello struct { + Name string + Secondary string +} + +func (Hello) IsEntity() {} + +type World struct { + Foo string + Bar int +} + +func (World) IsEntity() {} + +type MultiHelloMultiKey struct { + Name string + Key2 int +} + +func (MultiHelloMultiKey) IsEntity() {} + +type ExternalExtension struct { + UPC string + Reviews []*World +} + +func (ExternalExtension) IsEntity() {} + +type NestedKey struct { + ID string + Hello *Hello +} + +func (NestedKey) IsEntity() {} + +type MoreNesting struct { + ID string + World *World +} + +func (MoreNesting) IsEntity() {} + +type VeryNestedKey struct { + ID string + Hello *Hello + World *World + Nested *NestedKey + More *MoreNesting +} + +func (VeryNestedKey) IsEntity() {} + +type MultiHelloMultiKeyByNamesInput struct { + Names []string `json:"Names"` +} + +type MultiHelloMultiKeyByKey2sInput struct { + Key2s []string `json:"Key2s"` +} diff --git a/plugin/federation/testdata/allthethings/schema.graphql b/plugin/federation/testdata/allthethings/schema.graphql new file mode 100644 index 0000000..80e6dba --- /dev/null +++ b/plugin/federation/testdata/allthethings/schema.graphql @@ -0,0 +1,47 @@ +type Hello @key(fields: "name") { + name: String! + secondary: String! +} + +type World @key(fields: " foo ") @key(fields: "bar") { + foo: String! + bar: Int! +} + +directive @entityResolver(multi: Boolean) on OBJECT + +type MultiHelloMultiKey @key(fields: "name") @key(fields:"key2") @entityResolver(multi: true) { + name: String! + key2: String! +} + +extend type ExternalExtension @key(fields: " upc ") { + upc: String! @external + reviews: [World] +} + +extend type NestedKey @key(fields: "id hello { name}") { + id: String! @external + hello: Hello +} + +extend type MoreNesting @key(fields: "id") { + id: String! @external + world: World! @external +} + +extend type VeryNestedKey + @key( + fields: "id hello { name} world {foo } world{bar} more { world { foo }}" + ) { + id: String! @external + hello: Hello + world: World + nested: NestedKey @requires(fields: "id hello {secondary }") + more: MoreNesting +} + +type Query { + hello: Hello! + world: World! +} diff --git a/plugin/federation/testdata/entities/nokey.graphql b/plugin/federation/testdata/entities/nokey.graphql new file mode 100644 index 0000000..f337f0e --- /dev/null +++ b/plugin/federation/testdata/entities/nokey.graphql @@ -0,0 +1,8 @@ +type Hello { + name: String! +} + +type Query { + hello: Hello! +} + diff --git a/plugin/federation/testdata/entities/nokey.yml b/plugin/federation/testdata/entities/nokey.yml new file mode 100644 index 0000000..349b049 --- /dev/null +++ b/plugin/federation/testdata/entities/nokey.yml @@ -0,0 +1,9 @@ +schema: + - "testdata/entities/nokey.graphql" +exec: + filename: testdata/entities/generated/exec.go +federation: + filename: testdata/entities/generated/federation.go + +autobind: + - "github.com/niko0xdev/gqlgen/plugin/federation/test_data/model" diff --git a/plugin/federation/testdata/entityinterfaces/generated/exec.go b/plugin/federation/testdata/entityinterfaces/generated/exec.go new file mode 100644 index 0000000..ba39c57 --- /dev/null +++ b/plugin/federation/testdata/entityinterfaces/generated/exec.go @@ -0,0 +1,4098 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package generated + +import ( + "bytes" + "context" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + "github.com/niko0xdev/gqlgen/plugin/federation/fedruntime" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Entity() EntityResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + Entity struct { + FindHelloByID func(childComplexity int, id string) int + FindWorldByID func(childComplexity int, id string) int + } + + Query struct { + __resolve__service func(childComplexity int) int + __resolve_entities func(childComplexity int, representations []map[string]interface{}) int + } + + World struct { + ID func(childComplexity int) int + Title func(childComplexity int) int + } + + _Service struct { + SDL func(childComplexity int) int + } +} + +type EntityResolver interface { + FindHelloByID(ctx context.Context, id string) (Hello, error) + FindWorldByID(ctx context.Context, id string) (*World, error) +} + +type executableSchema struct { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = ec + switch typeName + "." + field { + + case "Entity.findHelloByID": + if e.complexity.Entity.FindHelloByID == nil { + break + } + + args, err := ec.field_Entity_findHelloByID_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindHelloByID(childComplexity, args["id"].(string)), true + + case "Entity.findWorldByID": + if e.complexity.Entity.FindWorldByID == nil { + break + } + + args, err := ec.field_Entity_findWorldByID_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindWorldByID(childComplexity, args["id"].(string)), true + + case "Query._service": + if e.complexity.Query.__resolve__service == nil { + break + } + + return e.complexity.Query.__resolve__service(childComplexity), true + + case "Query._entities": + if e.complexity.Query.__resolve_entities == nil { + break + } + + args, err := ec.field_Query__entities_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.__resolve_entities(childComplexity, args["representations"].([]map[string]interface{})), true + + case "World.id": + if e.complexity.World.ID == nil { + break + } + + return e.complexity.World.ID(childComplexity), true + + case "World.title": + if e.complexity.World.Title == nil { + break + } + + return e.complexity.World.Title(childComplexity), true + + case "_Service.sdl": + if e.complexity._Service.SDL == nil { + break + } + + return e.complexity._Service.SDL(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap() + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } +} + +type executionContext struct { + *graphql.OperationContext + *executableSchema + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + +var sources = []*ast.Source{ + {Name: "../interface.graphql", Input: `extend schema + @link(url: "https://specs.apollo.dev/federation/v2.3", + import: ["@key"]) + +interface Hello @key(fields: "id"){ + id: String! + title: String! +} + +type World implements Hello @key(fields: "id") { + id: String! + title: String! +}`, BuiltIn: false}, + {Name: "../../../federation/directives.graphql", Input: ` + directive @authenticated on FIELD_DEFINITION | OBJECT | INTERFACE | SCALAR | ENUM + directive @composeDirective(name: String!) repeatable on SCHEMA + directive @extends on OBJECT | INTERFACE + directive @external on OBJECT | FIELD_DEFINITION + directive @key(fields: FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE + directive @inaccessible on + | ARGUMENT_DEFINITION + | ENUM + | ENUM_VALUE + | FIELD_DEFINITION + | INPUT_FIELD_DEFINITION + | INPUT_OBJECT + | INTERFACE + | OBJECT + | SCALAR + | UNION + directive @interfaceObject on OBJECT + directive @link(import: [String!], url: String!) repeatable on SCHEMA + directive @override(from: String!) on FIELD_DEFINITION + directive @provides(fields: FieldSet!) on FIELD_DEFINITION + directive @requires(fields: FieldSet!) on FIELD_DEFINITION + directive @requiresScopes(scopes: [[federation__Scope!]!]!) on + | FIELD_DEFINITION + | OBJECT + | INTERFACE + | SCALAR + | ENUM + directive @shareable repeatable on FIELD_DEFINITION | OBJECT + directive @tag(name: String!) repeatable on + | ARGUMENT_DEFINITION + | ENUM + | ENUM_VALUE + | FIELD_DEFINITION + | INPUT_FIELD_DEFINITION + | INPUT_OBJECT + | INTERFACE + | OBJECT + | SCALAR + | UNION + scalar _Any + scalar FieldSet + scalar federation__Scope +`, BuiltIn: true}, + {Name: "../../../federation/entity.graphql", Input: ` +# a union of all types that use the @key directive +union _Entity = World + +# fake type to build resolver interfaces for users to implement +type Entity { + findHelloByID(id: String!,): Hello! + findWorldByID(id: String!,): World! + +} + +type _Service { + sdl: String +} + +extend type Query { + _entities(representations: [_Any!]!): [_Entity]! + _service: _Service! +} +`, BuiltIn: true}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (ec *executionContext) field_Entity_findHelloByID_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_findWorldByID_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_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__entities_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["representations"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("representations")) + arg0, err = ec.unmarshalN_Any2ᚕmapᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["representations"] = arg0 + return args, nil +} + +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) _Entity_findHelloByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findHelloByID(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindHelloByID(rctx, fc.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.(Hello) + fc.Result = res + return ec.marshalNHello2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityinterfacesᚋgeneratedᚐHello(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findHelloByID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findHelloByID_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Entity_findWorldByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findWorldByID(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindWorldByID(rctx, fc.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.(*World) + fc.Result = res + return ec.marshalNWorld2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityinterfacesᚋgeneratedᚐWorld(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findWorldByID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_World_id(ctx, field) + case "title": + return ec.fieldContext_World_title(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type World", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findWorldByID_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query__entities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query__entities(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.Args["representations"].([]map[string]interface{})), 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.([]fedruntime.Entity) + fc.Result = res + return ec.marshalN_Entity2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query__entities(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type _Entity does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query__entities_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query__service(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query__service(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.__resolve__service(ctx) + }) + 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.(fedruntime.Service) + fc.Result = res + return ec.marshalN_Service2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query__service(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "sdl": + return ec.fieldContext__Service_sdl(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type _Service", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _World_id(ctx context.Context, field graphql.CollectedField, obj *World) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_World_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_World_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "World", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _World_title(ctx context.Context, field graphql.CollectedField, obj *World) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_World_title(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Title, 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) fieldContext_World_title(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "World", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) __Service_sdl(ctx context.Context, field graphql.CollectedField, obj *fedruntime.Service) (ret graphql.Marshaler) { + fc, err := ec.fieldContext__Service_sdl(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SDL, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalOString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext__Service_sdl(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "_Service", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), 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.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), 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.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), 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.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +func (ec *executionContext) _Hello(ctx context.Context, sel ast.SelectionSet, obj Hello) graphql.Marshaler { + switch obj := (obj).(type) { + case nil: + return graphql.Null + case World: + return ec._World(ctx, sel, &obj) + case *World: + if obj == nil { + return graphql.Null + } + return ec._World(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, obj fedruntime.Entity) graphql.Marshaler { + switch obj := (obj).(type) { + case nil: + return graphql.Null + case World: + return ec._World(ctx, sel, &obj) + case *World: + if obj == nil { + return graphql.Null + } + return ec._World(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +// endregion ************************** interface.gotpl *************************** + +// 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", + }) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + 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 "findHelloByID": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Entity_findHelloByID(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "findWorldByID": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Entity_findWorldByID(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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 + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query__entities(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "_service": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query__service(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var worldImplementors = []string{"World", "Hello", "_Entity"} + +func (ec *executionContext) _World(ctx context.Context, sel ast.SelectionSet, obj *World) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, worldImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("World") + case "id": + out.Values[i] = ec._World_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "title": + out.Values[i] = ec._World_title(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("_Service") + case "sdl": + out.Values[i] = ec.__Service_sdl(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNFieldSet2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNFieldSet2string(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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNHello2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityinterfacesᚋgeneratedᚐHello(ctx context.Context, sel ast.SelectionSet, v Hello) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Hello(ctx, sel, v) +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNWorld2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityinterfacesᚋgeneratedᚐWorld(ctx context.Context, sel ast.SelectionSet, v World) graphql.Marshaler { + return ec._World(ctx, sel, &v) +} + +func (ec *executionContext) marshalNWorld2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityinterfacesᚋgeneratedᚐWorld(ctx context.Context, sel ast.SelectionSet, v *World) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._World(ctx, sel, v) +} + +func (ec *executionContext) unmarshalN_Any2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { + res, err := graphql.UnmarshalMap(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalN_Any2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + res := graphql.MarshalMap(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN_Any2ᚕmapᚄ(ctx context.Context, v interface{}) ([]map[string]interface{}, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]map[string]interface{}, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalN_Any2map(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalN_Any2ᚕmapᚄ(ctx context.Context, sel ast.SelectionSet, v []map[string]interface{}) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalN_Any2map(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalN_Entity2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v []fedruntime.Entity) 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.marshalO_Entity2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) marshalN_Service2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx context.Context, sel ast.SelectionSet, v fedruntime.Service) graphql.Marshaler { + return ec.__Service(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNfederation__Scope2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNfederation__Scope2string(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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNfederation__Scope2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNfederation__Scope2string(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalNfederation__Scope2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNfederation__Scope2string(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) unmarshalNfederation__Scope2ᚕᚕstringᚄ(ctx context.Context, v interface{}) ([][]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([][]string, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNfederation__Scope2ᚕstringᚄ(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalNfederation__Scope2ᚕᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v [][]string) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNfederation__Scope2ᚕstringᚄ(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +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) 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 { + vSlice = graphql.CoerceList(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 + } + 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) marshalO_Entity2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v fedruntime.Entity) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.__Entity(ctx, sel, v) +} + +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/plugin/federation/testdata/entityinterfaces/generated/federation.go b/plugin/federation/testdata/entityinterfaces/generated/federation.go new file mode 100644 index 0000000..52f652f --- /dev/null +++ b/plugin/federation/testdata/entityinterfaces/generated/federation.go @@ -0,0 +1,224 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package generated + +import ( + "context" + "errors" + "fmt" + "strings" + "sync" + + "github.com/niko0xdev/gqlgen/plugin/federation/fedruntime" +) + +var ( + ErrUnknownType = errors.New("unknown type") + ErrTypeNotFound = errors.New("type not found") +) + +func (ec *executionContext) __resolve__service(ctx context.Context) (fedruntime.Service, error) { + if ec.DisableIntrospection { + return fedruntime.Service{}, errors.New("federated introspection disabled") + } + + var sdl []string + + for _, src := range sources { + if src.BuiltIn { + continue + } + sdl = append(sdl, src.Input) + } + + return fedruntime.Service{ + SDL: strings.Join(sdl, "\n"), + }, nil +} + +func (ec *executionContext) __resolve_entities(ctx context.Context, representations []map[string]interface{}) []fedruntime.Entity { + list := make([]fedruntime.Entity, len(representations)) + + repsMap := map[string]struct { + i []int + r []map[string]interface{} + }{} + + // We group entities by typename so that we can parallelize their resolution. + // This is particularly helpful when there are entity groups in multi mode. + buildRepresentationGroups := func(reps []map[string]interface{}) { + for i, rep := range reps { + typeName, ok := rep["__typename"].(string) + if !ok { + // If there is no __typename, we just skip the representation; + // we just won't be resolving these unknown types. + ec.Error(ctx, errors.New("__typename must be an existing string")) + continue + } + + _r := repsMap[typeName] + _r.i = append(_r.i, i) + _r.r = append(_r.r, rep) + repsMap[typeName] = _r + } + } + + isMulti := func(typeName string) bool { + switch typeName { + default: + return false + } + } + + resolveEntity := func(ctx context.Context, typeName string, rep map[string]interface{}, idx []int, i int) (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) + } + }() + + switch typeName { + case "Hello": + resolverName, err := entityResolverNameForHello(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "Hello": %w`, err) + } + switch resolverName { + + case "findHelloByID": + id0, err := ec.unmarshalNString2string(ctx, rep["id"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findHelloByID(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindHelloByID(ctx, id0) + if err != nil { + return fmt.Errorf(`resolving Entity "Hello": %w`, err) + } + + list[idx[i]] = entity + return nil + } + case "World": + resolverName, err := entityResolverNameForWorld(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "World": %w`, err) + } + switch resolverName { + + case "findWorldByID": + id0, err := ec.unmarshalNString2string(ctx, rep["id"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findWorldByID(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindWorldByID(ctx, id0) + if err != nil { + return fmt.Errorf(`resolving Entity "World": %w`, err) + } + + list[idx[i]] = entity + return nil + } + + } + return fmt.Errorf("%w: %s", ErrUnknownType, typeName) + } + + resolveManyEntities := func(ctx context.Context, typeName string, reps []map[string]interface{}, idx []int) (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) + } + }() + + switch typeName { + + default: + return errors.New("unknown type: " + typeName) + } + } + + resolveEntityGroup := func(typeName string, reps []map[string]interface{}, idx []int) { + if isMulti(typeName) { + err := resolveManyEntities(ctx, typeName, reps, idx) + if err != nil { + ec.Error(ctx, err) + } + } else { + // if there are multiple entities to resolve, parallelize (similar to + // graphql.FieldSet.Dispatch) + var e sync.WaitGroup + e.Add(len(reps)) + for i, rep := range reps { + i, rep := i, rep + go func(i int, rep map[string]interface{}) { + err := resolveEntity(ctx, typeName, rep, idx, i) + if err != nil { + ec.Error(ctx, err) + } + e.Done() + }(i, rep) + } + e.Wait() + } + } + buildRepresentationGroups(representations) + + switch len(repsMap) { + case 0: + return list + case 1: + for typeName, reps := range repsMap { + resolveEntityGroup(typeName, reps.r, reps.i) + } + return list + default: + var g sync.WaitGroup + g.Add(len(repsMap)) + for typeName, reps := range repsMap { + go func(typeName string, reps []map[string]interface{}, idx []int) { + resolveEntityGroup(typeName, reps, idx) + g.Done() + }(typeName, reps.r, reps.i) + } + g.Wait() + return list + } +} + +func entityResolverNameForHello(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["id"]; !ok { + break + } + return "findHelloByID", nil + } + return "", fmt.Errorf("%w for Hello", ErrTypeNotFound) +} + +func entityResolverNameForWorld(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["id"]; !ok { + break + } + return "findWorldByID", nil + } + return "", fmt.Errorf("%w for World", ErrTypeNotFound) +} diff --git a/plugin/federation/testdata/entityinterfaces/generated/models_gen.go b/plugin/federation/testdata/entityinterfaces/generated/models_gen.go new file mode 100644 index 0000000..4747aea --- /dev/null +++ b/plugin/federation/testdata/entityinterfaces/generated/models_gen.go @@ -0,0 +1,24 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package generated + +type Hello interface { + IsEntity() + IsHello() + GetID() string + GetTitle() string +} + +type Query struct { +} + +type World struct { + ID string `json:"id"` + Title string `json:"title"` +} + +func (World) IsHello() {} +func (this World) GetID() string { return this.ID } +func (this World) GetTitle() string { return this.Title } + +func (World) IsEntity() {} diff --git a/plugin/federation/testdata/entityinterfaces/interface.graphql b/plugin/federation/testdata/entityinterfaces/interface.graphql new file mode 100644 index 0000000..cd6f76d --- /dev/null +++ b/plugin/federation/testdata/entityinterfaces/interface.graphql @@ -0,0 +1,13 @@ +extend schema + @link(url: "https://specs.apollo.dev/federation/v2.3", + import: ["@key"]) + +interface Hello @key(fields: "id"){ + id: String! + title: String! +} + +type World implements Hello @key(fields: "id") { + id: String! + title: String! +} \ No newline at end of file diff --git a/plugin/federation/testdata/entityinterfaces/interface.yml b/plugin/federation/testdata/entityinterfaces/interface.yml new file mode 100644 index 0000000..f9eaad5 --- /dev/null +++ b/plugin/federation/testdata/entityinterfaces/interface.yml @@ -0,0 +1,9 @@ +schema: + - "testdata/entityinterfaces/interface.graphql" +exec: + filename: testdata/entityinterfaces/generated/exec.go +federation: + filename: testdata/entityinterfaces/generated/federation.go + version: 2 +model: + filename: testdata/entityinterfaces/generated/models_gen.go \ No newline at end of file diff --git a/plugin/federation/testdata/entityresolver/entity.resolvers.go b/plugin/federation/testdata/entityresolver/entity.resolvers.go new file mode 100644 index 0000000..4c7bf75 --- /dev/null +++ b/plugin/federation/testdata/entityresolver/entity.resolvers.go @@ -0,0 +1,183 @@ +package entityresolver + +// 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. +// Code generated by github.com/niko0xdev/gqlgen version v0.17.42-dev + +import ( + "context" + "fmt" + + "github.com/niko0xdev/gqlgen/plugin/federation/testdata/entityresolver/generated" + "github.com/niko0xdev/gqlgen/plugin/federation/testdata/entityresolver/generated/model" +) + +// FindHelloByName is the resolver for the findHelloByName field. +func (r *entityResolver) FindHelloByName(ctx context.Context, name string) (*model.Hello, error) { + return &model.Hello{ + Name: name, + }, nil +} + +// FindHelloMultiSingleKeysByKey1AndKey2 is the resolver for the findHelloMultiSingleKeysByKey1AndKey2 field. +func (r *entityResolver) FindHelloMultiSingleKeysByKey1AndKey2(ctx context.Context, key1 string, key2 string) (*model.HelloMultiSingleKeys, error) { + panic(fmt.Errorf("not implemented")) +} + +// FindHelloWithErrorsByName is the resolver for the findHelloWithErrorsByName field. +func (r *entityResolver) FindHelloWithErrorsByName(ctx context.Context, name string) (*model.HelloWithErrors, error) { + if name == "inject error" { + return nil, generated.ErrResolvingHelloWithErrorsByName + } else if name == "" { + return nil, generated.ErrEmptyKeyResolvingHelloWithErrorsByName + } + + return &model.HelloWithErrors{ + Name: name, + }, nil +} + +// FindManyMultiHelloByNames is the resolver for the findManyMultiHelloByNames field. +func (r *entityResolver) FindManyMultiHelloByNames(ctx context.Context, reps []*model.MultiHelloByNamesInput) ([]*model.MultiHello, error) { + results := []*model.MultiHello{} + + for _, item := range reps { + results = append(results, &model.MultiHello{ + Name: item.Name + " - from multiget", + }) + } + + return results, nil +} + +// FindManyMultiHelloMultipleRequiresByNames is the resolver for the findManyMultiHelloMultipleRequiresByNames field. +func (r *entityResolver) FindManyMultiHelloMultipleRequiresByNames(ctx context.Context, reps []*model.MultiHelloMultipleRequiresByNamesInput) ([]*model.MultiHelloMultipleRequires, error) { + results := make([]*model.MultiHelloMultipleRequires, len(reps)) + + for i := range reps { + results[i] = &model.MultiHelloMultipleRequires{ + Name: reps[i].Name, + } + } + + return results, nil +} + +// FindManyMultiHelloRequiresByNames is the resolver for the findManyMultiHelloRequiresByNames field. +func (r *entityResolver) FindManyMultiHelloRequiresByNames(ctx context.Context, reps []*model.MultiHelloRequiresByNamesInput) ([]*model.MultiHelloRequires, error) { + results := make([]*model.MultiHelloRequires, len(reps)) + + for i := range reps { + results[i] = &model.MultiHelloRequires{ + Name: reps[i].Name, + } + } + + return results, nil +} + +// FindManyMultiHelloWithErrorByNames is the resolver for the findManyMultiHelloWithErrorByNames field. +func (r *entityResolver) FindManyMultiHelloWithErrorByNames(ctx context.Context, reps []*model.MultiHelloWithErrorByNamesInput) ([]*model.MultiHelloWithError, error) { + return nil, fmt.Errorf("error resolving MultiHelloWorldWithError") +} + +// FindManyMultiPlanetRequiresNestedByNames is the resolver for the findManyMultiPlanetRequiresNestedByNames field. +func (r *entityResolver) FindManyMultiPlanetRequiresNestedByNames(ctx context.Context, reps []*model.MultiPlanetRequiresNestedByNamesInput) ([]*model.MultiPlanetRequiresNested, error) { + worlds := map[string]*model.World{ + "earth": { + Foo: "A", + }, + "mars": { + Foo: "B", + }, + } + + results := make([]*model.MultiPlanetRequiresNested, len(reps)) + + for i := range reps { + name := reps[i].Name + world, ok := worlds[name] + if !ok { + return nil, fmt.Errorf("unknown planet: %s", name) + } + + results[i] = &model.MultiPlanetRequiresNested{ + Name: name, + World: world, + } + } + + return results, nil +} + +// FindPlanetMultipleRequiresByName is the resolver for the findPlanetMultipleRequiresByName field. +func (r *entityResolver) FindPlanetMultipleRequiresByName(ctx context.Context, name string) (*model.PlanetMultipleRequires, error) { + return &model.PlanetMultipleRequires{Name: name}, nil +} + +// FindPlanetRequiresByName is the resolver for the findPlanetRequiresByName field. +func (r *entityResolver) FindPlanetRequiresByName(ctx context.Context, name string) (*model.PlanetRequires, error) { + return &model.PlanetRequires{ + Name: name, + }, nil +} + +// FindPlanetRequiresNestedByName is the resolver for the findPlanetRequiresNestedByName field. +func (r *entityResolver) FindPlanetRequiresNestedByName(ctx context.Context, name string) (*model.PlanetRequiresNested, error) { + worlds := map[string]*model.World{ + "earth": { + Foo: "A", + }, + "mars": { + Foo: "B", + }, + } + world, ok := worlds[name] + if !ok { + return nil, fmt.Errorf("unknown planet: %s", name) + } + + return &model.PlanetRequiresNested{ + Name: name, + World: world, + }, nil +} + +// FindWorldByHelloNameAndFoo is the resolver for the findWorldByHelloNameAndFoo field. +func (r *entityResolver) FindWorldByHelloNameAndFoo(ctx context.Context, helloName string, foo string) (*model.World, error) { + return &model.World{ + Hello: &model.Hello{ + Name: helloName, + }, + Foo: foo, + }, nil +} + +// FindWorldNameByName is the resolver for the findWorldNameByName field. +func (r *entityResolver) FindWorldNameByName(ctx context.Context, name string) (*model.WorldName, error) { + return &model.WorldName{ + Name: name, + }, nil +} + +// FindWorldWithMultipleKeysByHelloNameAndFoo is the resolver for the findWorldWithMultipleKeysByHelloNameAndFoo field. +func (r *entityResolver) FindWorldWithMultipleKeysByHelloNameAndFoo(ctx context.Context, helloName string, foo string) (*model.WorldWithMultipleKeys, error) { + return &model.WorldWithMultipleKeys{ + Hello: &model.Hello{ + Name: helloName, + }, + Foo: foo, + }, nil +} + +// FindWorldWithMultipleKeysByBar is the resolver for the findWorldWithMultipleKeysByBar field. +func (r *entityResolver) FindWorldWithMultipleKeysByBar(ctx context.Context, bar int) (*model.WorldWithMultipleKeys, error) { + return &model.WorldWithMultipleKeys{ + Bar: bar, + }, nil +} + +// Entity returns generated.EntityResolver implementation. +func (r *Resolver) Entity() generated.EntityResolver { return &entityResolver{r} } + +type entityResolver struct{ *Resolver } diff --git a/plugin/federation/testdata/entityresolver/generated/errors.go b/plugin/federation/testdata/entityresolver/generated/errors.go new file mode 100644 index 0000000..ea311c6 --- /dev/null +++ b/plugin/federation/testdata/entityresolver/generated/errors.go @@ -0,0 +1,9 @@ +package generated + +import "errors" + +// Errors defined for retained code that we want to stick around between generations. +var ( + ErrResolvingHelloWithErrorsByName = errors.New("error resolving HelloWithErrorsByName") + ErrEmptyKeyResolvingHelloWithErrorsByName = errors.New("error (empty key) resolving HelloWithErrorsByName") +) diff --git a/plugin/federation/testdata/entityresolver/generated/exec.go b/plugin/federation/testdata/entityresolver/generated/exec.go new file mode 100644 index 0000000..b848889 --- /dev/null +++ b/plugin/federation/testdata/entityresolver/generated/exec.go @@ -0,0 +1,8680 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package generated + +import ( + "bytes" + "context" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + "github.com/niko0xdev/gqlgen/plugin/federation/fedruntime" + "github.com/niko0xdev/gqlgen/plugin/federation/testdata/entityresolver/generated/model" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + schema: cfg.Schema, + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Schema *ast.Schema + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Entity() EntityResolver +} + +type DirectiveRoot struct { + EntityResolver func(ctx context.Context, obj interface{}, next graphql.Resolver, multi *bool) (res interface{}, err error) +} + +type ComplexityRoot struct { + Entity struct { + FindHelloByName func(childComplexity int, name string) int + FindHelloMultiSingleKeysByKey1AndKey2 func(childComplexity int, key1 string, key2 string) int + FindHelloWithErrorsByName func(childComplexity int, name string) int + FindManyMultiHelloByNames func(childComplexity int, reps []*model.MultiHelloByNamesInput) int + FindManyMultiHelloMultipleRequiresByNames func(childComplexity int, reps []*model.MultiHelloMultipleRequiresByNamesInput) int + FindManyMultiHelloRequiresByNames func(childComplexity int, reps []*model.MultiHelloRequiresByNamesInput) int + FindManyMultiHelloWithErrorByNames func(childComplexity int, reps []*model.MultiHelloWithErrorByNamesInput) int + FindManyMultiPlanetRequiresNestedByNames func(childComplexity int, reps []*model.MultiPlanetRequiresNestedByNamesInput) int + FindPlanetMultipleRequiresByName func(childComplexity int, name string) int + FindPlanetRequiresByName func(childComplexity int, name string) int + FindPlanetRequiresNestedByName func(childComplexity int, name string) int + FindWorldByHelloNameAndFoo func(childComplexity int, helloName string, foo string) int + FindWorldNameByName func(childComplexity int, name string) int + FindWorldWithMultipleKeysByBar func(childComplexity int, bar int) int + FindWorldWithMultipleKeysByHelloNameAndFoo func(childComplexity int, helloName string, foo string) int + } + + Hello struct { + Name func(childComplexity int) int + Secondary func(childComplexity int) int + } + + HelloMultiSingleKeys struct { + Key1 func(childComplexity int) int + Key2 func(childComplexity int) int + } + + HelloWithErrors struct { + Name func(childComplexity int) int + } + + MultiHello struct { + Name func(childComplexity int) int + } + + MultiHelloMultipleRequires struct { + Key1 func(childComplexity int) int + Key2 func(childComplexity int) int + Key3 func(childComplexity int) int + Name func(childComplexity int) int + } + + MultiHelloRequires struct { + Key1 func(childComplexity int) int + Key2 func(childComplexity int) int + Name func(childComplexity int) int + } + + MultiHelloWithError struct { + Name func(childComplexity int) int + } + + MultiPlanetRequiresNested struct { + Name func(childComplexity int) int + Size func(childComplexity int) int + World func(childComplexity int) int + } + + PlanetMultipleRequires struct { + Density func(childComplexity int) int + Diameter func(childComplexity int) int + Name func(childComplexity int) int + Weight func(childComplexity int) int + } + + PlanetRequires struct { + Diameter func(childComplexity int) int + Name func(childComplexity int) int + Size func(childComplexity int) int + } + + PlanetRequiresNested struct { + Name func(childComplexity int) int + Size func(childComplexity int) int + World func(childComplexity int) int + } + + Query struct { + __resolve__service func(childComplexity int) int + __resolve_entities func(childComplexity int, representations []map[string]interface{}) int + } + + World struct { + Bar func(childComplexity int) int + Foo func(childComplexity int) int + Hello func(childComplexity int) int + } + + WorldName struct { + Name func(childComplexity int) int + } + + WorldWithMultipleKeys struct { + Bar func(childComplexity int) int + Foo func(childComplexity int) int + Hello func(childComplexity int) int + } + + _Service struct { + SDL func(childComplexity int) int + } +} + +type EntityResolver interface { + FindHelloByName(ctx context.Context, name string) (*model.Hello, error) + FindHelloMultiSingleKeysByKey1AndKey2(ctx context.Context, key1 string, key2 string) (*model.HelloMultiSingleKeys, error) + FindHelloWithErrorsByName(ctx context.Context, name string) (*model.HelloWithErrors, error) + FindManyMultiHelloByNames(ctx context.Context, reps []*model.MultiHelloByNamesInput) ([]*model.MultiHello, error) + FindManyMultiHelloMultipleRequiresByNames(ctx context.Context, reps []*model.MultiHelloMultipleRequiresByNamesInput) ([]*model.MultiHelloMultipleRequires, error) + FindManyMultiHelloRequiresByNames(ctx context.Context, reps []*model.MultiHelloRequiresByNamesInput) ([]*model.MultiHelloRequires, error) + FindManyMultiHelloWithErrorByNames(ctx context.Context, reps []*model.MultiHelloWithErrorByNamesInput) ([]*model.MultiHelloWithError, error) + FindManyMultiPlanetRequiresNestedByNames(ctx context.Context, reps []*model.MultiPlanetRequiresNestedByNamesInput) ([]*model.MultiPlanetRequiresNested, error) + FindPlanetMultipleRequiresByName(ctx context.Context, name string) (*model.PlanetMultipleRequires, error) + FindPlanetRequiresByName(ctx context.Context, name string) (*model.PlanetRequires, error) + FindPlanetRequiresNestedByName(ctx context.Context, name string) (*model.PlanetRequiresNested, error) + FindWorldByHelloNameAndFoo(ctx context.Context, helloName string, foo string) (*model.World, error) + FindWorldNameByName(ctx context.Context, name string) (*model.WorldName, error) + FindWorldWithMultipleKeysByHelloNameAndFoo(ctx context.Context, helloName string, foo string) (*model.WorldWithMultipleKeys, error) + FindWorldWithMultipleKeysByBar(ctx context.Context, bar int) (*model.WorldWithMultipleKeys, error) +} + +type executableSchema struct { + schema *ast.Schema + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + if e.schema != nil { + return e.schema + } + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e, 0, 0, nil} + _ = ec + switch typeName + "." + field { + + case "Entity.findHelloByName": + if e.complexity.Entity.FindHelloByName == nil { + break + } + + args, err := ec.field_Entity_findHelloByName_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindHelloByName(childComplexity, args["name"].(string)), true + + case "Entity.findHelloMultiSingleKeysByKey1AndKey2": + if e.complexity.Entity.FindHelloMultiSingleKeysByKey1AndKey2 == nil { + break + } + + args, err := ec.field_Entity_findHelloMultiSingleKeysByKey1AndKey2_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindHelloMultiSingleKeysByKey1AndKey2(childComplexity, args["key1"].(string), args["key2"].(string)), true + + case "Entity.findHelloWithErrorsByName": + if e.complexity.Entity.FindHelloWithErrorsByName == nil { + break + } + + args, err := ec.field_Entity_findHelloWithErrorsByName_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindHelloWithErrorsByName(childComplexity, args["name"].(string)), true + + case "Entity.findManyMultiHelloByNames": + if e.complexity.Entity.FindManyMultiHelloByNames == nil { + break + } + + args, err := ec.field_Entity_findManyMultiHelloByNames_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindManyMultiHelloByNames(childComplexity, args["reps"].([]*model.MultiHelloByNamesInput)), true + + case "Entity.findManyMultiHelloMultipleRequiresByNames": + if e.complexity.Entity.FindManyMultiHelloMultipleRequiresByNames == nil { + break + } + + args, err := ec.field_Entity_findManyMultiHelloMultipleRequiresByNames_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindManyMultiHelloMultipleRequiresByNames(childComplexity, args["reps"].([]*model.MultiHelloMultipleRequiresByNamesInput)), true + + case "Entity.findManyMultiHelloRequiresByNames": + if e.complexity.Entity.FindManyMultiHelloRequiresByNames == nil { + break + } + + args, err := ec.field_Entity_findManyMultiHelloRequiresByNames_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindManyMultiHelloRequiresByNames(childComplexity, args["reps"].([]*model.MultiHelloRequiresByNamesInput)), true + + case "Entity.findManyMultiHelloWithErrorByNames": + if e.complexity.Entity.FindManyMultiHelloWithErrorByNames == nil { + break + } + + args, err := ec.field_Entity_findManyMultiHelloWithErrorByNames_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindManyMultiHelloWithErrorByNames(childComplexity, args["reps"].([]*model.MultiHelloWithErrorByNamesInput)), true + + case "Entity.findManyMultiPlanetRequiresNestedByNames": + if e.complexity.Entity.FindManyMultiPlanetRequiresNestedByNames == nil { + break + } + + args, err := ec.field_Entity_findManyMultiPlanetRequiresNestedByNames_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindManyMultiPlanetRequiresNestedByNames(childComplexity, args["reps"].([]*model.MultiPlanetRequiresNestedByNamesInput)), true + + case "Entity.findPlanetMultipleRequiresByName": + if e.complexity.Entity.FindPlanetMultipleRequiresByName == nil { + break + } + + args, err := ec.field_Entity_findPlanetMultipleRequiresByName_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindPlanetMultipleRequiresByName(childComplexity, args["name"].(string)), true + + case "Entity.findPlanetRequiresByName": + if e.complexity.Entity.FindPlanetRequiresByName == nil { + break + } + + args, err := ec.field_Entity_findPlanetRequiresByName_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindPlanetRequiresByName(childComplexity, args["name"].(string)), true + + case "Entity.findPlanetRequiresNestedByName": + if e.complexity.Entity.FindPlanetRequiresNestedByName == nil { + break + } + + args, err := ec.field_Entity_findPlanetRequiresNestedByName_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindPlanetRequiresNestedByName(childComplexity, args["name"].(string)), true + + case "Entity.findWorldByHelloNameAndFoo": + if e.complexity.Entity.FindWorldByHelloNameAndFoo == nil { + break + } + + args, err := ec.field_Entity_findWorldByHelloNameAndFoo_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindWorldByHelloNameAndFoo(childComplexity, args["helloName"].(string), args["foo"].(string)), true + + case "Entity.findWorldNameByName": + if e.complexity.Entity.FindWorldNameByName == nil { + break + } + + args, err := ec.field_Entity_findWorldNameByName_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindWorldNameByName(childComplexity, args["name"].(string)), true + + case "Entity.findWorldWithMultipleKeysByBar": + if e.complexity.Entity.FindWorldWithMultipleKeysByBar == nil { + break + } + + args, err := ec.field_Entity_findWorldWithMultipleKeysByBar_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindWorldWithMultipleKeysByBar(childComplexity, args["bar"].(int)), true + + case "Entity.findWorldWithMultipleKeysByHelloNameAndFoo": + if e.complexity.Entity.FindWorldWithMultipleKeysByHelloNameAndFoo == nil { + break + } + + args, err := ec.field_Entity_findWorldWithMultipleKeysByHelloNameAndFoo_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindWorldWithMultipleKeysByHelloNameAndFoo(childComplexity, args["helloName"].(string), args["foo"].(string)), true + + case "Hello.name": + if e.complexity.Hello.Name == nil { + break + } + + return e.complexity.Hello.Name(childComplexity), true + + case "Hello.secondary": + if e.complexity.Hello.Secondary == nil { + break + } + + return e.complexity.Hello.Secondary(childComplexity), true + + case "HelloMultiSingleKeys.key1": + if e.complexity.HelloMultiSingleKeys.Key1 == nil { + break + } + + return e.complexity.HelloMultiSingleKeys.Key1(childComplexity), true + + case "HelloMultiSingleKeys.key2": + if e.complexity.HelloMultiSingleKeys.Key2 == nil { + break + } + + return e.complexity.HelloMultiSingleKeys.Key2(childComplexity), true + + case "HelloWithErrors.name": + if e.complexity.HelloWithErrors.Name == nil { + break + } + + return e.complexity.HelloWithErrors.Name(childComplexity), true + + case "MultiHello.name": + if e.complexity.MultiHello.Name == nil { + break + } + + return e.complexity.MultiHello.Name(childComplexity), true + + case "MultiHelloMultipleRequires.key1": + if e.complexity.MultiHelloMultipleRequires.Key1 == nil { + break + } + + return e.complexity.MultiHelloMultipleRequires.Key1(childComplexity), true + + case "MultiHelloMultipleRequires.key2": + if e.complexity.MultiHelloMultipleRequires.Key2 == nil { + break + } + + return e.complexity.MultiHelloMultipleRequires.Key2(childComplexity), true + + case "MultiHelloMultipleRequires.key3": + if e.complexity.MultiHelloMultipleRequires.Key3 == nil { + break + } + + return e.complexity.MultiHelloMultipleRequires.Key3(childComplexity), true + + case "MultiHelloMultipleRequires.name": + if e.complexity.MultiHelloMultipleRequires.Name == nil { + break + } + + return e.complexity.MultiHelloMultipleRequires.Name(childComplexity), true + + case "MultiHelloRequires.key1": + if e.complexity.MultiHelloRequires.Key1 == nil { + break + } + + return e.complexity.MultiHelloRequires.Key1(childComplexity), true + + case "MultiHelloRequires.key2": + if e.complexity.MultiHelloRequires.Key2 == nil { + break + } + + return e.complexity.MultiHelloRequires.Key2(childComplexity), true + + case "MultiHelloRequires.name": + if e.complexity.MultiHelloRequires.Name == nil { + break + } + + return e.complexity.MultiHelloRequires.Name(childComplexity), true + + case "MultiHelloWithError.name": + if e.complexity.MultiHelloWithError.Name == nil { + break + } + + return e.complexity.MultiHelloWithError.Name(childComplexity), true + + case "MultiPlanetRequiresNested.name": + if e.complexity.MultiPlanetRequiresNested.Name == nil { + break + } + + return e.complexity.MultiPlanetRequiresNested.Name(childComplexity), true + + case "MultiPlanetRequiresNested.size": + if e.complexity.MultiPlanetRequiresNested.Size == nil { + break + } + + return e.complexity.MultiPlanetRequiresNested.Size(childComplexity), true + + case "MultiPlanetRequiresNested.world": + if e.complexity.MultiPlanetRequiresNested.World == nil { + break + } + + return e.complexity.MultiPlanetRequiresNested.World(childComplexity), true + + case "PlanetMultipleRequires.density": + if e.complexity.PlanetMultipleRequires.Density == nil { + break + } + + return e.complexity.PlanetMultipleRequires.Density(childComplexity), true + + case "PlanetMultipleRequires.diameter": + if e.complexity.PlanetMultipleRequires.Diameter == nil { + break + } + + return e.complexity.PlanetMultipleRequires.Diameter(childComplexity), true + + case "PlanetMultipleRequires.name": + if e.complexity.PlanetMultipleRequires.Name == nil { + break + } + + return e.complexity.PlanetMultipleRequires.Name(childComplexity), true + + case "PlanetMultipleRequires.weight": + if e.complexity.PlanetMultipleRequires.Weight == nil { + break + } + + return e.complexity.PlanetMultipleRequires.Weight(childComplexity), true + + case "PlanetRequires.diameter": + if e.complexity.PlanetRequires.Diameter == nil { + break + } + + return e.complexity.PlanetRequires.Diameter(childComplexity), true + + case "PlanetRequires.name": + if e.complexity.PlanetRequires.Name == nil { + break + } + + return e.complexity.PlanetRequires.Name(childComplexity), true + + case "PlanetRequires.size": + if e.complexity.PlanetRequires.Size == nil { + break + } + + return e.complexity.PlanetRequires.Size(childComplexity), true + + case "PlanetRequiresNested.name": + if e.complexity.PlanetRequiresNested.Name == nil { + break + } + + return e.complexity.PlanetRequiresNested.Name(childComplexity), true + + case "PlanetRequiresNested.size": + if e.complexity.PlanetRequiresNested.Size == nil { + break + } + + return e.complexity.PlanetRequiresNested.Size(childComplexity), true + + case "PlanetRequiresNested.world": + if e.complexity.PlanetRequiresNested.World == nil { + break + } + + return e.complexity.PlanetRequiresNested.World(childComplexity), true + + case "Query._service": + if e.complexity.Query.__resolve__service == nil { + break + } + + return e.complexity.Query.__resolve__service(childComplexity), true + + case "Query._entities": + if e.complexity.Query.__resolve_entities == nil { + break + } + + args, err := ec.field_Query__entities_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.__resolve_entities(childComplexity, args["representations"].([]map[string]interface{})), true + + case "World.bar": + if e.complexity.World.Bar == nil { + break + } + + return e.complexity.World.Bar(childComplexity), true + + case "World.foo": + if e.complexity.World.Foo == nil { + break + } + + return e.complexity.World.Foo(childComplexity), true + + case "World.hello": + if e.complexity.World.Hello == nil { + break + } + + return e.complexity.World.Hello(childComplexity), true + + case "WorldName.name": + if e.complexity.WorldName.Name == nil { + break + } + + return e.complexity.WorldName.Name(childComplexity), true + + case "WorldWithMultipleKeys.bar": + if e.complexity.WorldWithMultipleKeys.Bar == nil { + break + } + + return e.complexity.WorldWithMultipleKeys.Bar(childComplexity), true + + case "WorldWithMultipleKeys.foo": + if e.complexity.WorldWithMultipleKeys.Foo == nil { + break + } + + return e.complexity.WorldWithMultipleKeys.Foo(childComplexity), true + + case "WorldWithMultipleKeys.hello": + if e.complexity.WorldWithMultipleKeys.Hello == nil { + break + } + + return e.complexity.WorldWithMultipleKeys.Hello(childComplexity), true + + case "_Service.sdl": + if e.complexity._Service.SDL == nil { + break + } + + return e.complexity._Service.SDL(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} + inputUnmarshalMap := graphql.BuildUnmarshalerMap( + ec.unmarshalInputMultiHelloByNamesInput, + ec.unmarshalInputMultiHelloMultipleRequiresByNamesInput, + ec.unmarshalInputMultiHelloRequiresByNamesInput, + ec.unmarshalInputMultiHelloWithErrorByNamesInput, + ec.unmarshalInputMultiPlanetRequiresNestedByNamesInput, + ) + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + var response graphql.Response + var data graphql.Marshaler + if first { + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data = ec._Query(ctx, rc.Operation.SelectionSet) + } else { + if atomic.LoadInt32(&ec.pendingDeferred) > 0 { + result := <-ec.deferredResults + atomic.AddInt32(&ec.pendingDeferred, -1) + data = result.Result + response.Path = result.Path + response.Label = result.Label + response.Errors = result.Errors + } else { + return nil + } + } + var buf bytes.Buffer + data.MarshalGQL(&buf) + response.Data = buf.Bytes() + if atomic.LoadInt32(&ec.deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + response.HasNext = &hasNext + } + + return &response + } + + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } +} + +type executionContext struct { + *graphql.OperationContext + *executableSchema + deferred int32 + pendingDeferred int32 + deferredResults chan graphql.DeferredResult +} + +func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { + atomic.AddInt32(&ec.pendingDeferred, 1) + go func() { + ctx := graphql.WithFreshResponseContext(dg.Context) + dg.FieldSet.Dispatch(ctx) + ds := graphql.DeferredResult{ + Path: dg.Path, + Label: dg.Label, + Result: dg.FieldSet, + Errors: graphql.GetErrors(ctx), + } + // null fields should bubble up + if dg.FieldSet.Invalids > 0 { + ds.Result = graphql.Null + } + ec.deferredResults <- ds + }() +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(ec.Schema()), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil +} + +var sources = []*ast.Source{ + {Name: "../schema.graphql", Input: `directive @entityResolver(multi: Boolean) on OBJECT + +type Hello @key(fields: "name") { + name: String! + secondary: String! +} + +type World @key(fields: "hello { name } foo ") { + foo: String! + bar: Int! + hello: Hello +} + +type WorldWithMultipleKeys @key(fields: "hello { name } foo ") @key(fields: "bar") { + foo: String! + bar: Int! + hello: Hello +} + +type WorldName @key(fields: "name") { + name: String! +} + +type HelloWithErrors @key(fields: "name") { + name: String! +} + +type PlanetRequires @key(fields: "name") { + name: String! + size: Int! @requires(fields: "diameter") + diameter: Int! +} + +type PlanetMultipleRequires @key(fields: "name") { + name: String! @external + diameter: Int! @external + density: Int! @external + weight: Int! @requires(fields: "diameter density") +} + +type PlanetRequiresNested @key(fields: "name") { + name: String! @external + world: World! @external + size: Int! @requires(fields: "world{ foo }") +} + +type MultiPlanetRequiresNested @key(fields: "name") @entityResolver(multi: true) { + name: String! @external + world: World! @external + size: Int! @requires(fields: "world{ foo }") +} + +type MultiHello @key(fields: "name") @entityResolver(multi: true) { + name: String! +} + +type MultiHelloWithError @key(fields: "name") @entityResolver(multi: true) { + name: String! +} + +type HelloMultiSingleKeys @key(fields: "key1 key2") { + key1: String! + key2: String! +} + +type MultiHelloRequires @key(fields: "name") @entityResolver(multi: true) { + name: String! @external + key1: String! @external + key2: String! @requires(fields: "key1") +} + +type MultiHelloMultipleRequires @key(fields: "name") @entityResolver(multi: true) { + name: String! @external + key1: String! @external + key2: String! @external + key3: String! @requires(fields: "key1 key2") +} +`, BuiltIn: false}, + {Name: "../../../federation/directives.graphql", Input: ` + directive @key(fields: _FieldSet!) repeatable on OBJECT | INTERFACE + directive @requires(fields: _FieldSet!) on FIELD_DEFINITION + directive @provides(fields: _FieldSet!) on FIELD_DEFINITION + directive @extends on OBJECT | INTERFACE + directive @external on FIELD_DEFINITION + scalar _Any + scalar _FieldSet +`, BuiltIn: true}, + {Name: "../../../federation/entity.graphql", Input: ` +# a union of all types that use the @key directive +union _Entity = Hello | HelloMultiSingleKeys | HelloWithErrors | MultiHello | MultiHelloMultipleRequires | MultiHelloRequires | MultiHelloWithError | MultiPlanetRequiresNested | PlanetMultipleRequires | PlanetRequires | PlanetRequiresNested | World | WorldName | WorldWithMultipleKeys + +input MultiHelloByNamesInput { + Name: String! +} + +input MultiHelloMultipleRequiresByNamesInput { + Name: String! +} + +input MultiHelloRequiresByNamesInput { + Name: String! +} + +input MultiHelloWithErrorByNamesInput { + Name: String! +} + +input MultiPlanetRequiresNestedByNamesInput { + Name: String! +} + +# fake type to build resolver interfaces for users to implement +type Entity { + findHelloByName(name: String!,): Hello! + findHelloMultiSingleKeysByKey1AndKey2(key1: String!,key2: String!,): HelloMultiSingleKeys! + findHelloWithErrorsByName(name: String!,): HelloWithErrors! + findManyMultiHelloByNames(reps: [MultiHelloByNamesInput]!): [MultiHello] + findManyMultiHelloMultipleRequiresByNames(reps: [MultiHelloMultipleRequiresByNamesInput]!): [MultiHelloMultipleRequires] + findManyMultiHelloRequiresByNames(reps: [MultiHelloRequiresByNamesInput]!): [MultiHelloRequires] + findManyMultiHelloWithErrorByNames(reps: [MultiHelloWithErrorByNamesInput]!): [MultiHelloWithError] + findManyMultiPlanetRequiresNestedByNames(reps: [MultiPlanetRequiresNestedByNamesInput]!): [MultiPlanetRequiresNested] + findPlanetMultipleRequiresByName(name: String!,): PlanetMultipleRequires! + findPlanetRequiresByName(name: String!,): PlanetRequires! + findPlanetRequiresNestedByName(name: String!,): PlanetRequiresNested! + findWorldByHelloNameAndFoo(helloName: String!,foo: String!,): World! + findWorldNameByName(name: String!,): WorldName! + findWorldWithMultipleKeysByHelloNameAndFoo(helloName: String!,foo: String!,): WorldWithMultipleKeys! + findWorldWithMultipleKeysByBar(bar: Int!,): WorldWithMultipleKeys! + +} + +type _Service { + sdl: String +} + +extend type Query { + _entities(representations: [_Any!]!): [_Entity]! + _service: _Service! +} +`, BuiltIn: true}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (ec *executionContext) dir_entityResolver_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["multi"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("multi")) + arg0, err = ec.unmarshalOBoolean2ᚖbool(ctx, tmp) + if err != nil { + return nil, err + } + } + args["multi"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Entity_findHelloByName_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_Entity_findHelloMultiSingleKeysByKey1AndKey2_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["key1"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("key1")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["key1"] = arg0 + var arg1 string + if tmp, ok := rawArgs["key2"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("key2")) + arg1, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["key2"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Entity_findHelloWithErrorsByName_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_Entity_findManyMultiHelloByNames_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 []*model.MultiHelloByNamesInput + if tmp, ok := rawArgs["reps"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("reps")) + arg0, err = ec.unmarshalNMultiHelloByNamesInput2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloByNamesInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["reps"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Entity_findManyMultiHelloMultipleRequiresByNames_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 []*model.MultiHelloMultipleRequiresByNamesInput + if tmp, ok := rawArgs["reps"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("reps")) + arg0, err = ec.unmarshalNMultiHelloMultipleRequiresByNamesInput2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloMultipleRequiresByNamesInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["reps"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Entity_findManyMultiHelloRequiresByNames_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 []*model.MultiHelloRequiresByNamesInput + if tmp, ok := rawArgs["reps"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("reps")) + arg0, err = ec.unmarshalNMultiHelloRequiresByNamesInput2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloRequiresByNamesInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["reps"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Entity_findManyMultiHelloWithErrorByNames_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 []*model.MultiHelloWithErrorByNamesInput + if tmp, ok := rawArgs["reps"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("reps")) + arg0, err = ec.unmarshalNMultiHelloWithErrorByNamesInput2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloWithErrorByNamesInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["reps"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Entity_findManyMultiPlanetRequiresNestedByNames_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 []*model.MultiPlanetRequiresNestedByNamesInput + if tmp, ok := rawArgs["reps"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("reps")) + arg0, err = ec.unmarshalNMultiPlanetRequiresNestedByNamesInput2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiPlanetRequiresNestedByNamesInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["reps"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Entity_findPlanetMultipleRequiresByName_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_Entity_findPlanetRequiresByName_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_Entity_findPlanetRequiresNestedByName_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_Entity_findWorldByHelloNameAndFoo_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["helloName"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("helloName")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["helloName"] = arg0 + var arg1 string + if tmp, ok := rawArgs["foo"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("foo")) + arg1, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["foo"] = arg1 + return args, nil +} + +func (ec *executionContext) field_Entity_findWorldNameByName_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_Entity_findWorldWithMultipleKeysByBar_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["bar"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("bar")) + arg0, err = ec.unmarshalNInt2int(ctx, tmp) + if err != nil { + return nil, err + } + } + args["bar"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Entity_findWorldWithMultipleKeysByHelloNameAndFoo_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["helloName"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("helloName")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["helloName"] = arg0 + var arg1 string + if tmp, ok := rawArgs["foo"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("foo")) + arg1, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["foo"] = arg1 + return args, nil +} + +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__entities_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["representations"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("representations")) + arg0, err = ec.unmarshalN_Any2ᚕmapᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["representations"] = arg0 + return args, nil +} + +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) _Entity_findHelloByName(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findHelloByName(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindHelloByName(rctx, fc.Args["name"].(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.Hello) + fc.Result = res + return ec.marshalNHello2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐHello(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findHelloByName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_Hello_name(ctx, field) + case "secondary": + return ec.fieldContext_Hello_secondary(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Hello", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findHelloByName_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Entity_findHelloMultiSingleKeysByKey1AndKey2(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findHelloMultiSingleKeysByKey1AndKey2(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindHelloMultiSingleKeysByKey1AndKey2(rctx, fc.Args["key1"].(string), fc.Args["key2"].(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.HelloMultiSingleKeys) + fc.Result = res + return ec.marshalNHelloMultiSingleKeys2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐHelloMultiSingleKeys(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findHelloMultiSingleKeysByKey1AndKey2(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "key1": + return ec.fieldContext_HelloMultiSingleKeys_key1(ctx, field) + case "key2": + return ec.fieldContext_HelloMultiSingleKeys_key2(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HelloMultiSingleKeys", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findHelloMultiSingleKeysByKey1AndKey2_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Entity_findHelloWithErrorsByName(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findHelloWithErrorsByName(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindHelloWithErrorsByName(rctx, fc.Args["name"].(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.HelloWithErrors) + fc.Result = res + return ec.marshalNHelloWithErrors2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐHelloWithErrors(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findHelloWithErrorsByName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_HelloWithErrors_name(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HelloWithErrors", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findHelloWithErrorsByName_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Entity_findManyMultiHelloByNames(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findManyMultiHelloByNames(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, 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.Entity().FindManyMultiHelloByNames(rctx, fc.Args["reps"].([]*model.MultiHelloByNamesInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + multi, err := ec.unmarshalOBoolean2ᚖbool(ctx, true) + if err != nil { + return nil, err + } + if ec.directives.EntityResolver == nil { + return nil, errors.New("directive entityResolver is not implemented") + } + return ec.directives.EntityResolver(ctx, nil, directive0, multi) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*model.MultiHello); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/niko0xdev/gqlgen/plugin/federation/testdata/entityresolver/generated/model.MultiHello`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*model.MultiHello) + fc.Result = res + return ec.marshalOMultiHello2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHello(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findManyMultiHelloByNames(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_MultiHello_name(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type MultiHello", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findManyMultiHelloByNames_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Entity_findManyMultiHelloMultipleRequiresByNames(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findManyMultiHelloMultipleRequiresByNames(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, 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.Entity().FindManyMultiHelloMultipleRequiresByNames(rctx, fc.Args["reps"].([]*model.MultiHelloMultipleRequiresByNamesInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + multi, err := ec.unmarshalOBoolean2ᚖbool(ctx, true) + if err != nil { + return nil, err + } + if ec.directives.EntityResolver == nil { + return nil, errors.New("directive entityResolver is not implemented") + } + return ec.directives.EntityResolver(ctx, nil, directive0, multi) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*model.MultiHelloMultipleRequires); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/niko0xdev/gqlgen/plugin/federation/testdata/entityresolver/generated/model.MultiHelloMultipleRequires`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*model.MultiHelloMultipleRequires) + fc.Result = res + return ec.marshalOMultiHelloMultipleRequires2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloMultipleRequires(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findManyMultiHelloMultipleRequiresByNames(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_MultiHelloMultipleRequires_name(ctx, field) + case "key1": + return ec.fieldContext_MultiHelloMultipleRequires_key1(ctx, field) + case "key2": + return ec.fieldContext_MultiHelloMultipleRequires_key2(ctx, field) + case "key3": + return ec.fieldContext_MultiHelloMultipleRequires_key3(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type MultiHelloMultipleRequires", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findManyMultiHelloMultipleRequiresByNames_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Entity_findManyMultiHelloRequiresByNames(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findManyMultiHelloRequiresByNames(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, 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.Entity().FindManyMultiHelloRequiresByNames(rctx, fc.Args["reps"].([]*model.MultiHelloRequiresByNamesInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + multi, err := ec.unmarshalOBoolean2ᚖbool(ctx, true) + if err != nil { + return nil, err + } + if ec.directives.EntityResolver == nil { + return nil, errors.New("directive entityResolver is not implemented") + } + return ec.directives.EntityResolver(ctx, nil, directive0, multi) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*model.MultiHelloRequires); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/niko0xdev/gqlgen/plugin/federation/testdata/entityresolver/generated/model.MultiHelloRequires`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*model.MultiHelloRequires) + fc.Result = res + return ec.marshalOMultiHelloRequires2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloRequires(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findManyMultiHelloRequiresByNames(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_MultiHelloRequires_name(ctx, field) + case "key1": + return ec.fieldContext_MultiHelloRequires_key1(ctx, field) + case "key2": + return ec.fieldContext_MultiHelloRequires_key2(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type MultiHelloRequires", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findManyMultiHelloRequiresByNames_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Entity_findManyMultiHelloWithErrorByNames(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findManyMultiHelloWithErrorByNames(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, 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.Entity().FindManyMultiHelloWithErrorByNames(rctx, fc.Args["reps"].([]*model.MultiHelloWithErrorByNamesInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + multi, err := ec.unmarshalOBoolean2ᚖbool(ctx, true) + if err != nil { + return nil, err + } + if ec.directives.EntityResolver == nil { + return nil, errors.New("directive entityResolver is not implemented") + } + return ec.directives.EntityResolver(ctx, nil, directive0, multi) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*model.MultiHelloWithError); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/niko0xdev/gqlgen/plugin/federation/testdata/entityresolver/generated/model.MultiHelloWithError`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*model.MultiHelloWithError) + fc.Result = res + return ec.marshalOMultiHelloWithError2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloWithError(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findManyMultiHelloWithErrorByNames(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_MultiHelloWithError_name(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type MultiHelloWithError", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findManyMultiHelloWithErrorByNames_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Entity_findManyMultiPlanetRequiresNestedByNames(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findManyMultiPlanetRequiresNestedByNames(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, 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.Entity().FindManyMultiPlanetRequiresNestedByNames(rctx, fc.Args["reps"].([]*model.MultiPlanetRequiresNestedByNamesInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + multi, err := ec.unmarshalOBoolean2ᚖbool(ctx, true) + if err != nil { + return nil, err + } + if ec.directives.EntityResolver == nil { + return nil, errors.New("directive entityResolver is not implemented") + } + return ec.directives.EntityResolver(ctx, nil, directive0, multi) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*model.MultiPlanetRequiresNested); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/niko0xdev/gqlgen/plugin/federation/testdata/entityresolver/generated/model.MultiPlanetRequiresNested`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*model.MultiPlanetRequiresNested) + fc.Result = res + return ec.marshalOMultiPlanetRequiresNested2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiPlanetRequiresNested(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findManyMultiPlanetRequiresNestedByNames(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_MultiPlanetRequiresNested_name(ctx, field) + case "world": + return ec.fieldContext_MultiPlanetRequiresNested_world(ctx, field) + case "size": + return ec.fieldContext_MultiPlanetRequiresNested_size(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type MultiPlanetRequiresNested", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findManyMultiPlanetRequiresNestedByNames_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Entity_findPlanetMultipleRequiresByName(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findPlanetMultipleRequiresByName(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindPlanetMultipleRequiresByName(rctx, fc.Args["name"].(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.PlanetMultipleRequires) + fc.Result = res + return ec.marshalNPlanetMultipleRequires2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐPlanetMultipleRequires(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findPlanetMultipleRequiresByName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_PlanetMultipleRequires_name(ctx, field) + case "diameter": + return ec.fieldContext_PlanetMultipleRequires_diameter(ctx, field) + case "density": + return ec.fieldContext_PlanetMultipleRequires_density(ctx, field) + case "weight": + return ec.fieldContext_PlanetMultipleRequires_weight(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PlanetMultipleRequires", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findPlanetMultipleRequiresByName_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Entity_findPlanetRequiresByName(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findPlanetRequiresByName(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindPlanetRequiresByName(rctx, fc.Args["name"].(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.PlanetRequires) + fc.Result = res + return ec.marshalNPlanetRequires2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐPlanetRequires(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findPlanetRequiresByName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_PlanetRequires_name(ctx, field) + case "size": + return ec.fieldContext_PlanetRequires_size(ctx, field) + case "diameter": + return ec.fieldContext_PlanetRequires_diameter(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PlanetRequires", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findPlanetRequiresByName_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Entity_findPlanetRequiresNestedByName(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findPlanetRequiresNestedByName(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindPlanetRequiresNestedByName(rctx, fc.Args["name"].(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.PlanetRequiresNested) + fc.Result = res + return ec.marshalNPlanetRequiresNested2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐPlanetRequiresNested(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findPlanetRequiresNestedByName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_PlanetRequiresNested_name(ctx, field) + case "world": + return ec.fieldContext_PlanetRequiresNested_world(ctx, field) + case "size": + return ec.fieldContext_PlanetRequiresNested_size(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PlanetRequiresNested", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findPlanetRequiresNestedByName_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Entity_findWorldByHelloNameAndFoo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findWorldByHelloNameAndFoo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindWorldByHelloNameAndFoo(rctx, fc.Args["helloName"].(string), fc.Args["foo"].(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.World) + fc.Result = res + return ec.marshalNWorld2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐWorld(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findWorldByHelloNameAndFoo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "foo": + return ec.fieldContext_World_foo(ctx, field) + case "bar": + return ec.fieldContext_World_bar(ctx, field) + case "hello": + return ec.fieldContext_World_hello(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type World", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findWorldByHelloNameAndFoo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Entity_findWorldNameByName(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findWorldNameByName(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindWorldNameByName(rctx, fc.Args["name"].(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.WorldName) + fc.Result = res + return ec.marshalNWorldName2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐWorldName(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findWorldNameByName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_WorldName_name(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type WorldName", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findWorldNameByName_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Entity_findWorldWithMultipleKeysByHelloNameAndFoo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findWorldWithMultipleKeysByHelloNameAndFoo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindWorldWithMultipleKeysByHelloNameAndFoo(rctx, fc.Args["helloName"].(string), fc.Args["foo"].(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.WorldWithMultipleKeys) + fc.Result = res + return ec.marshalNWorldWithMultipleKeys2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐWorldWithMultipleKeys(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findWorldWithMultipleKeysByHelloNameAndFoo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "foo": + return ec.fieldContext_WorldWithMultipleKeys_foo(ctx, field) + case "bar": + return ec.fieldContext_WorldWithMultipleKeys_bar(ctx, field) + case "hello": + return ec.fieldContext_WorldWithMultipleKeys_hello(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type WorldWithMultipleKeys", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findWorldWithMultipleKeysByHelloNameAndFoo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Entity_findWorldWithMultipleKeysByBar(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findWorldWithMultipleKeysByBar(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindWorldWithMultipleKeysByBar(rctx, fc.Args["bar"].(int)) + }) + 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.WorldWithMultipleKeys) + fc.Result = res + return ec.marshalNWorldWithMultipleKeys2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐWorldWithMultipleKeys(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findWorldWithMultipleKeysByBar(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "foo": + return ec.fieldContext_WorldWithMultipleKeys_foo(ctx, field) + case "bar": + return ec.fieldContext_WorldWithMultipleKeys_bar(ctx, field) + case "hello": + return ec.fieldContext_WorldWithMultipleKeys_hello(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type WorldWithMultipleKeys", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findWorldWithMultipleKeysByBar_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Hello_name(ctx context.Context, field graphql.CollectedField, obj *model.Hello) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Hello_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_Hello_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Hello", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Hello_secondary(ctx context.Context, field graphql.CollectedField, obj *model.Hello) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Hello_secondary(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Secondary, 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) fieldContext_Hello_secondary(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Hello", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _HelloMultiSingleKeys_key1(ctx context.Context, field graphql.CollectedField, obj *model.HelloMultiSingleKeys) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HelloMultiSingleKeys_key1(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Key1, 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) fieldContext_HelloMultiSingleKeys_key1(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HelloMultiSingleKeys", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _HelloMultiSingleKeys_key2(ctx context.Context, field graphql.CollectedField, obj *model.HelloMultiSingleKeys) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HelloMultiSingleKeys_key2(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Key2, 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) fieldContext_HelloMultiSingleKeys_key2(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HelloMultiSingleKeys", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _HelloWithErrors_name(ctx context.Context, field graphql.CollectedField, obj *model.HelloWithErrors) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HelloWithErrors_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_HelloWithErrors_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HelloWithErrors", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MultiHello_name(ctx context.Context, field graphql.CollectedField, obj *model.MultiHello) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MultiHello_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_MultiHello_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MultiHello", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MultiHelloMultipleRequires_name(ctx context.Context, field graphql.CollectedField, obj *model.MultiHelloMultipleRequires) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MultiHelloMultipleRequires_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_MultiHelloMultipleRequires_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MultiHelloMultipleRequires", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MultiHelloMultipleRequires_key1(ctx context.Context, field graphql.CollectedField, obj *model.MultiHelloMultipleRequires) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MultiHelloMultipleRequires_key1(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Key1, 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) fieldContext_MultiHelloMultipleRequires_key1(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MultiHelloMultipleRequires", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MultiHelloMultipleRequires_key2(ctx context.Context, field graphql.CollectedField, obj *model.MultiHelloMultipleRequires) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MultiHelloMultipleRequires_key2(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Key2, 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) fieldContext_MultiHelloMultipleRequires_key2(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MultiHelloMultipleRequires", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MultiHelloMultipleRequires_key3(ctx context.Context, field graphql.CollectedField, obj *model.MultiHelloMultipleRequires) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MultiHelloMultipleRequires_key3(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Key3, 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) fieldContext_MultiHelloMultipleRequires_key3(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MultiHelloMultipleRequires", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MultiHelloRequires_name(ctx context.Context, field graphql.CollectedField, obj *model.MultiHelloRequires) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MultiHelloRequires_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_MultiHelloRequires_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MultiHelloRequires", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MultiHelloRequires_key1(ctx context.Context, field graphql.CollectedField, obj *model.MultiHelloRequires) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MultiHelloRequires_key1(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Key1, 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) fieldContext_MultiHelloRequires_key1(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MultiHelloRequires", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MultiHelloRequires_key2(ctx context.Context, field graphql.CollectedField, obj *model.MultiHelloRequires) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MultiHelloRequires_key2(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Key2, 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) fieldContext_MultiHelloRequires_key2(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MultiHelloRequires", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MultiHelloWithError_name(ctx context.Context, field graphql.CollectedField, obj *model.MultiHelloWithError) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MultiHelloWithError_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_MultiHelloWithError_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MultiHelloWithError", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MultiPlanetRequiresNested_name(ctx context.Context, field graphql.CollectedField, obj *model.MultiPlanetRequiresNested) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MultiPlanetRequiresNested_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_MultiPlanetRequiresNested_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MultiPlanetRequiresNested", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _MultiPlanetRequiresNested_world(ctx context.Context, field graphql.CollectedField, obj *model.MultiPlanetRequiresNested) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MultiPlanetRequiresNested_world(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.World, 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.World) + fc.Result = res + return ec.marshalNWorld2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐWorld(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MultiPlanetRequiresNested_world(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MultiPlanetRequiresNested", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "foo": + return ec.fieldContext_World_foo(ctx, field) + case "bar": + return ec.fieldContext_World_bar(ctx, field) + case "hello": + return ec.fieldContext_World_hello(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type World", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _MultiPlanetRequiresNested_size(ctx context.Context, field graphql.CollectedField, obj *model.MultiPlanetRequiresNested) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_MultiPlanetRequiresNested_size(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Size, 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.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_MultiPlanetRequiresNested_size(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "MultiPlanetRequiresNested", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PlanetMultipleRequires_name(ctx context.Context, field graphql.CollectedField, obj *model.PlanetMultipleRequires) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PlanetMultipleRequires_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_PlanetMultipleRequires_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PlanetMultipleRequires", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PlanetMultipleRequires_diameter(ctx context.Context, field graphql.CollectedField, obj *model.PlanetMultipleRequires) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PlanetMultipleRequires_diameter(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Diameter, 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.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PlanetMultipleRequires_diameter(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PlanetMultipleRequires", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PlanetMultipleRequires_density(ctx context.Context, field graphql.CollectedField, obj *model.PlanetMultipleRequires) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PlanetMultipleRequires_density(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Density, 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.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PlanetMultipleRequires_density(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PlanetMultipleRequires", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PlanetMultipleRequires_weight(ctx context.Context, field graphql.CollectedField, obj *model.PlanetMultipleRequires) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PlanetMultipleRequires_weight(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Weight, 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.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PlanetMultipleRequires_weight(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PlanetMultipleRequires", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PlanetRequires_name(ctx context.Context, field graphql.CollectedField, obj *model.PlanetRequires) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PlanetRequires_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_PlanetRequires_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PlanetRequires", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PlanetRequires_size(ctx context.Context, field graphql.CollectedField, obj *model.PlanetRequires) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PlanetRequires_size(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Size, 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.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PlanetRequires_size(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PlanetRequires", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PlanetRequires_diameter(ctx context.Context, field graphql.CollectedField, obj *model.PlanetRequires) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PlanetRequires_diameter(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Diameter, 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.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PlanetRequires_diameter(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PlanetRequires", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PlanetRequiresNested_name(ctx context.Context, field graphql.CollectedField, obj *model.PlanetRequiresNested) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PlanetRequiresNested_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_PlanetRequiresNested_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PlanetRequiresNested", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PlanetRequiresNested_world(ctx context.Context, field graphql.CollectedField, obj *model.PlanetRequiresNested) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PlanetRequiresNested_world(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.World, 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.World) + fc.Result = res + return ec.marshalNWorld2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐWorld(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PlanetRequiresNested_world(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PlanetRequiresNested", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "foo": + return ec.fieldContext_World_foo(ctx, field) + case "bar": + return ec.fieldContext_World_bar(ctx, field) + case "hello": + return ec.fieldContext_World_hello(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type World", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _PlanetRequiresNested_size(ctx context.Context, field graphql.CollectedField, obj *model.PlanetRequiresNested) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PlanetRequiresNested_size(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Size, 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.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PlanetRequiresNested_size(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PlanetRequiresNested", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Query__entities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query__entities(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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, fc.Args["representations"].([]map[string]interface{})), 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.([]fedruntime.Entity) + fc.Result = res + return ec.marshalN_Entity2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query__entities(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type _Entity does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query__entities_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query__service(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query__service(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.__resolve__service(ctx) + }) + 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.(fedruntime.Service) + fc.Result = res + return ec.marshalN_Service2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query__service(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "sdl": + return ec.fieldContext__Service_sdl(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type _Service", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _World_foo(ctx context.Context, field graphql.CollectedField, obj *model.World) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_World_foo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Foo, 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) fieldContext_World_foo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "World", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _World_bar(ctx context.Context, field graphql.CollectedField, obj *model.World) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_World_bar(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Bar, 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.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_World_bar(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "World", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _World_hello(ctx context.Context, field graphql.CollectedField, obj *model.World) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_World_hello(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Hello, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.Hello) + fc.Result = res + return ec.marshalOHello2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐHello(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_World_hello(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "World", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_Hello_name(ctx, field) + case "secondary": + return ec.fieldContext_Hello_secondary(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Hello", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _WorldName_name(ctx context.Context, field graphql.CollectedField, obj *model.WorldName) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_WorldName_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_WorldName_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "WorldName", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _WorldWithMultipleKeys_foo(ctx context.Context, field graphql.CollectedField, obj *model.WorldWithMultipleKeys) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_WorldWithMultipleKeys_foo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Foo, 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) fieldContext_WorldWithMultipleKeys_foo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "WorldWithMultipleKeys", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _WorldWithMultipleKeys_bar(ctx context.Context, field graphql.CollectedField, obj *model.WorldWithMultipleKeys) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_WorldWithMultipleKeys_bar(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Bar, 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.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_WorldWithMultipleKeys_bar(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "WorldWithMultipleKeys", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _WorldWithMultipleKeys_hello(ctx context.Context, field graphql.CollectedField, obj *model.WorldWithMultipleKeys) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_WorldWithMultipleKeys_hello(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Hello, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.Hello) + fc.Result = res + return ec.marshalOHello2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐHello(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_WorldWithMultipleKeys_hello(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "WorldWithMultipleKeys", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_Hello_name(ctx, field) + case "secondary": + return ec.fieldContext_Hello_secondary(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Hello", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) __Service_sdl(ctx context.Context, field graphql.CollectedField, obj *fedruntime.Service) (ret graphql.Marshaler) { + fc, err := ec.fieldContext__Service_sdl(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SDL, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalOString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext__Service_sdl(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "_Service", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), 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.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), 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.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), 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.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputMultiHelloByNamesInput(ctx context.Context, obj interface{}) (model.MultiHelloByNamesInput, error) { + var it model.MultiHelloByNamesInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"Name"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "Name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Name")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Name = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputMultiHelloMultipleRequiresByNamesInput(ctx context.Context, obj interface{}) (model.MultiHelloMultipleRequiresByNamesInput, error) { + var it model.MultiHelloMultipleRequiresByNamesInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"Name"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "Name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Name")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Name = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputMultiHelloRequiresByNamesInput(ctx context.Context, obj interface{}) (model.MultiHelloRequiresByNamesInput, error) { + var it model.MultiHelloRequiresByNamesInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"Name"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "Name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Name")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Name = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputMultiHelloWithErrorByNamesInput(ctx context.Context, obj interface{}) (model.MultiHelloWithErrorByNamesInput, error) { + var it model.MultiHelloWithErrorByNamesInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"Name"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "Name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Name")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Name = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputMultiPlanetRequiresNestedByNamesInput(ctx context.Context, obj interface{}) (model.MultiPlanetRequiresNestedByNamesInput, error) { + var it model.MultiPlanetRequiresNestedByNamesInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"Name"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "Name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Name")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Name = data + } + } + + return it, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, obj fedruntime.Entity) graphql.Marshaler { + switch obj := (obj).(type) { + case nil: + return graphql.Null + case model.Hello: + return ec._Hello(ctx, sel, &obj) + case *model.Hello: + if obj == nil { + return graphql.Null + } + return ec._Hello(ctx, sel, obj) + case model.HelloMultiSingleKeys: + return ec._HelloMultiSingleKeys(ctx, sel, &obj) + case *model.HelloMultiSingleKeys: + if obj == nil { + return graphql.Null + } + return ec._HelloMultiSingleKeys(ctx, sel, obj) + case model.HelloWithErrors: + return ec._HelloWithErrors(ctx, sel, &obj) + case *model.HelloWithErrors: + if obj == nil { + return graphql.Null + } + return ec._HelloWithErrors(ctx, sel, obj) + case model.MultiHello: + return ec._MultiHello(ctx, sel, &obj) + case *model.MultiHello: + if obj == nil { + return graphql.Null + } + return ec._MultiHello(ctx, sel, obj) + case model.MultiHelloMultipleRequires: + return ec._MultiHelloMultipleRequires(ctx, sel, &obj) + case *model.MultiHelloMultipleRequires: + if obj == nil { + return graphql.Null + } + return ec._MultiHelloMultipleRequires(ctx, sel, obj) + case model.MultiHelloRequires: + return ec._MultiHelloRequires(ctx, sel, &obj) + case *model.MultiHelloRequires: + if obj == nil { + return graphql.Null + } + return ec._MultiHelloRequires(ctx, sel, obj) + case model.MultiHelloWithError: + return ec._MultiHelloWithError(ctx, sel, &obj) + case *model.MultiHelloWithError: + if obj == nil { + return graphql.Null + } + return ec._MultiHelloWithError(ctx, sel, obj) + case model.MultiPlanetRequiresNested: + return ec._MultiPlanetRequiresNested(ctx, sel, &obj) + case *model.MultiPlanetRequiresNested: + if obj == nil { + return graphql.Null + } + return ec._MultiPlanetRequiresNested(ctx, sel, obj) + case model.PlanetMultipleRequires: + return ec._PlanetMultipleRequires(ctx, sel, &obj) + case *model.PlanetMultipleRequires: + if obj == nil { + return graphql.Null + } + return ec._PlanetMultipleRequires(ctx, sel, obj) + case model.PlanetRequires: + return ec._PlanetRequires(ctx, sel, &obj) + case *model.PlanetRequires: + if obj == nil { + return graphql.Null + } + return ec._PlanetRequires(ctx, sel, obj) + case model.PlanetRequiresNested: + return ec._PlanetRequiresNested(ctx, sel, &obj) + case *model.PlanetRequiresNested: + if obj == nil { + return graphql.Null + } + return ec._PlanetRequiresNested(ctx, sel, obj) + case model.World: + return ec._World(ctx, sel, &obj) + case *model.World: + if obj == nil { + return graphql.Null + } + return ec._World(ctx, sel, obj) + case model.WorldName: + return ec._WorldName(ctx, sel, &obj) + case *model.WorldName: + if obj == nil { + return graphql.Null + } + return ec._WorldName(ctx, sel, obj) + case model.WorldWithMultipleKeys: + return ec._WorldWithMultipleKeys(ctx, sel, &obj) + case *model.WorldWithMultipleKeys: + if obj == nil { + return graphql.Null + } + return ec._WorldWithMultipleKeys(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +// endregion ************************** interface.gotpl *************************** + +// 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", + }) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + 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 "findHelloByName": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Entity_findHelloByName(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "findHelloMultiSingleKeysByKey1AndKey2": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Entity_findHelloMultiSingleKeysByKey1AndKey2(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "findHelloWithErrorsByName": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Entity_findHelloWithErrorsByName(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "findManyMultiHelloByNames": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Entity_findManyMultiHelloByNames(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "findManyMultiHelloMultipleRequiresByNames": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Entity_findManyMultiHelloMultipleRequiresByNames(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "findManyMultiHelloRequiresByNames": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Entity_findManyMultiHelloRequiresByNames(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "findManyMultiHelloWithErrorByNames": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Entity_findManyMultiHelloWithErrorByNames(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "findManyMultiPlanetRequiresNestedByNames": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Entity_findManyMultiPlanetRequiresNestedByNames(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "findPlanetMultipleRequiresByName": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Entity_findPlanetMultipleRequiresByName(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "findPlanetRequiresByName": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Entity_findPlanetRequiresByName(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "findPlanetRequiresNestedByName": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Entity_findPlanetRequiresNestedByName(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "findWorldByHelloNameAndFoo": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Entity_findWorldByHelloNameAndFoo(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "findWorldNameByName": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Entity_findWorldNameByName(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "findWorldWithMultipleKeysByHelloNameAndFoo": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Entity_findWorldWithMultipleKeysByHelloNameAndFoo(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "findWorldWithMultipleKeysByBar": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Entity_findWorldWithMultipleKeysByBar(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var helloImplementors = []string{"Hello", "_Entity"} + +func (ec *executionContext) _Hello(ctx context.Context, sel ast.SelectionSet, obj *model.Hello) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, helloImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Hello") + case "name": + out.Values[i] = ec._Hello_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "secondary": + out.Values[i] = ec._Hello_secondary(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var helloMultiSingleKeysImplementors = []string{"HelloMultiSingleKeys", "_Entity"} + +func (ec *executionContext) _HelloMultiSingleKeys(ctx context.Context, sel ast.SelectionSet, obj *model.HelloMultiSingleKeys) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, helloMultiSingleKeysImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("HelloMultiSingleKeys") + case "key1": + out.Values[i] = ec._HelloMultiSingleKeys_key1(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "key2": + out.Values[i] = ec._HelloMultiSingleKeys_key2(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var helloWithErrorsImplementors = []string{"HelloWithErrors", "_Entity"} + +func (ec *executionContext) _HelloWithErrors(ctx context.Context, sel ast.SelectionSet, obj *model.HelloWithErrors) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, helloWithErrorsImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("HelloWithErrors") + case "name": + out.Values[i] = ec._HelloWithErrors_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var multiHelloImplementors = []string{"MultiHello", "_Entity"} + +func (ec *executionContext) _MultiHello(ctx context.Context, sel ast.SelectionSet, obj *model.MultiHello) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, multiHelloImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("MultiHello") + case "name": + out.Values[i] = ec._MultiHello_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var multiHelloMultipleRequiresImplementors = []string{"MultiHelloMultipleRequires", "_Entity"} + +func (ec *executionContext) _MultiHelloMultipleRequires(ctx context.Context, sel ast.SelectionSet, obj *model.MultiHelloMultipleRequires) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, multiHelloMultipleRequiresImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("MultiHelloMultipleRequires") + case "name": + out.Values[i] = ec._MultiHelloMultipleRequires_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "key1": + out.Values[i] = ec._MultiHelloMultipleRequires_key1(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "key2": + out.Values[i] = ec._MultiHelloMultipleRequires_key2(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "key3": + out.Values[i] = ec._MultiHelloMultipleRequires_key3(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var multiHelloRequiresImplementors = []string{"MultiHelloRequires", "_Entity"} + +func (ec *executionContext) _MultiHelloRequires(ctx context.Context, sel ast.SelectionSet, obj *model.MultiHelloRequires) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, multiHelloRequiresImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("MultiHelloRequires") + case "name": + out.Values[i] = ec._MultiHelloRequires_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "key1": + out.Values[i] = ec._MultiHelloRequires_key1(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "key2": + out.Values[i] = ec._MultiHelloRequires_key2(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var multiHelloWithErrorImplementors = []string{"MultiHelloWithError", "_Entity"} + +func (ec *executionContext) _MultiHelloWithError(ctx context.Context, sel ast.SelectionSet, obj *model.MultiHelloWithError) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, multiHelloWithErrorImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("MultiHelloWithError") + case "name": + out.Values[i] = ec._MultiHelloWithError_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var multiPlanetRequiresNestedImplementors = []string{"MultiPlanetRequiresNested", "_Entity"} + +func (ec *executionContext) _MultiPlanetRequiresNested(ctx context.Context, sel ast.SelectionSet, obj *model.MultiPlanetRequiresNested) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, multiPlanetRequiresNestedImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("MultiPlanetRequiresNested") + case "name": + out.Values[i] = ec._MultiPlanetRequiresNested_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "world": + out.Values[i] = ec._MultiPlanetRequiresNested_world(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "size": + out.Values[i] = ec._MultiPlanetRequiresNested_size(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var planetMultipleRequiresImplementors = []string{"PlanetMultipleRequires", "_Entity"} + +func (ec *executionContext) _PlanetMultipleRequires(ctx context.Context, sel ast.SelectionSet, obj *model.PlanetMultipleRequires) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, planetMultipleRequiresImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("PlanetMultipleRequires") + case "name": + out.Values[i] = ec._PlanetMultipleRequires_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "diameter": + out.Values[i] = ec._PlanetMultipleRequires_diameter(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "density": + out.Values[i] = ec._PlanetMultipleRequires_density(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "weight": + out.Values[i] = ec._PlanetMultipleRequires_weight(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var planetRequiresImplementors = []string{"PlanetRequires", "_Entity"} + +func (ec *executionContext) _PlanetRequires(ctx context.Context, sel ast.SelectionSet, obj *model.PlanetRequires) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, planetRequiresImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("PlanetRequires") + case "name": + out.Values[i] = ec._PlanetRequires_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "size": + out.Values[i] = ec._PlanetRequires_size(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "diameter": + out.Values[i] = ec._PlanetRequires_diameter(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var planetRequiresNestedImplementors = []string{"PlanetRequiresNested", "_Entity"} + +func (ec *executionContext) _PlanetRequiresNested(ctx context.Context, sel ast.SelectionSet, obj *model.PlanetRequiresNested) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, planetRequiresNestedImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("PlanetRequiresNested") + case "name": + out.Values[i] = ec._PlanetRequiresNested_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "world": + out.Values[i] = ec._PlanetRequiresNested_world(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "size": + out.Values[i] = ec._PlanetRequiresNested_size(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + 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 + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query__entities(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "_service": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query__service(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "__type": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + case "__schema": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var worldImplementors = []string{"World", "_Entity"} + +func (ec *executionContext) _World(ctx context.Context, sel ast.SelectionSet, obj *model.World) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, worldImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("World") + case "foo": + out.Values[i] = ec._World_foo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "bar": + out.Values[i] = ec._World_bar(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "hello": + out.Values[i] = ec._World_hello(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var worldNameImplementors = []string{"WorldName", "_Entity"} + +func (ec *executionContext) _WorldName(ctx context.Context, sel ast.SelectionSet, obj *model.WorldName) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, worldNameImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("WorldName") + case "name": + out.Values[i] = ec._WorldName_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var worldWithMultipleKeysImplementors = []string{"WorldWithMultipleKeys", "_Entity"} + +func (ec *executionContext) _WorldWithMultipleKeys(ctx context.Context, sel ast.SelectionSet, obj *model.WorldWithMultipleKeys) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, worldWithMultipleKeysImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("WorldWithMultipleKeys") + case "foo": + out.Values[i] = ec._WorldWithMultipleKeys_foo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "bar": + out.Values[i] = ec._WorldWithMultipleKeys_bar(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "hello": + out.Values[i] = ec._WorldWithMultipleKeys_hello(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("_Service") + case "sdl": + out.Values[i] = ec.__Service_sdl(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + out.Values[i] = ec.___Schema_description(ctx, field, obj) + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + case "specifiedByURL": + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNHello2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐHello(ctx context.Context, sel ast.SelectionSet, v model.Hello) graphql.Marshaler { + return ec._Hello(ctx, sel, &v) +} + +func (ec *executionContext) marshalNHello2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐHello(ctx context.Context, sel ast.SelectionSet, v *model.Hello) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Hello(ctx, sel, v) +} + +func (ec *executionContext) marshalNHelloMultiSingleKeys2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐHelloMultiSingleKeys(ctx context.Context, sel ast.SelectionSet, v model.HelloMultiSingleKeys) graphql.Marshaler { + return ec._HelloMultiSingleKeys(ctx, sel, &v) +} + +func (ec *executionContext) marshalNHelloMultiSingleKeys2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐHelloMultiSingleKeys(ctx context.Context, sel ast.SelectionSet, v *model.HelloMultiSingleKeys) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._HelloMultiSingleKeys(ctx, sel, v) +} + +func (ec *executionContext) marshalNHelloWithErrors2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐHelloWithErrors(ctx context.Context, sel ast.SelectionSet, v model.HelloWithErrors) graphql.Marshaler { + return ec._HelloWithErrors(ctx, sel, &v) +} + +func (ec *executionContext) marshalNHelloWithErrors2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐHelloWithErrors(ctx context.Context, sel ast.SelectionSet, v *model.HelloWithErrors) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._HelloWithErrors(ctx, sel, v) +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNMultiHelloByNamesInput2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloByNamesInput(ctx context.Context, v interface{}) ([]*model.MultiHelloByNamesInput, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*model.MultiHelloByNamesInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalOMultiHelloByNamesInput2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloByNamesInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalNMultiHelloMultipleRequiresByNamesInput2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloMultipleRequiresByNamesInput(ctx context.Context, v interface{}) ([]*model.MultiHelloMultipleRequiresByNamesInput, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*model.MultiHelloMultipleRequiresByNamesInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalOMultiHelloMultipleRequiresByNamesInput2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloMultipleRequiresByNamesInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalNMultiHelloRequiresByNamesInput2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloRequiresByNamesInput(ctx context.Context, v interface{}) ([]*model.MultiHelloRequiresByNamesInput, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*model.MultiHelloRequiresByNamesInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalOMultiHelloRequiresByNamesInput2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloRequiresByNamesInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalNMultiHelloWithErrorByNamesInput2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloWithErrorByNamesInput(ctx context.Context, v interface{}) ([]*model.MultiHelloWithErrorByNamesInput, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*model.MultiHelloWithErrorByNamesInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalOMultiHelloWithErrorByNamesInput2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloWithErrorByNamesInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalNMultiPlanetRequiresNestedByNamesInput2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiPlanetRequiresNestedByNamesInput(ctx context.Context, v interface{}) ([]*model.MultiPlanetRequiresNestedByNamesInput, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*model.MultiPlanetRequiresNestedByNamesInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalOMultiPlanetRequiresNestedByNamesInput2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiPlanetRequiresNestedByNamesInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalNPlanetMultipleRequires2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐPlanetMultipleRequires(ctx context.Context, sel ast.SelectionSet, v model.PlanetMultipleRequires) graphql.Marshaler { + return ec._PlanetMultipleRequires(ctx, sel, &v) +} + +func (ec *executionContext) marshalNPlanetMultipleRequires2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐPlanetMultipleRequires(ctx context.Context, sel ast.SelectionSet, v *model.PlanetMultipleRequires) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._PlanetMultipleRequires(ctx, sel, v) +} + +func (ec *executionContext) marshalNPlanetRequires2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐPlanetRequires(ctx context.Context, sel ast.SelectionSet, v model.PlanetRequires) graphql.Marshaler { + return ec._PlanetRequires(ctx, sel, &v) +} + +func (ec *executionContext) marshalNPlanetRequires2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐPlanetRequires(ctx context.Context, sel ast.SelectionSet, v *model.PlanetRequires) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._PlanetRequires(ctx, sel, v) +} + +func (ec *executionContext) marshalNPlanetRequiresNested2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐPlanetRequiresNested(ctx context.Context, sel ast.SelectionSet, v model.PlanetRequiresNested) graphql.Marshaler { + return ec._PlanetRequiresNested(ctx, sel, &v) +} + +func (ec *executionContext) marshalNPlanetRequiresNested2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐPlanetRequiresNested(ctx context.Context, sel ast.SelectionSet, v *model.PlanetRequiresNested) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._PlanetRequiresNested(ctx, sel, v) +} + +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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNWorld2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐWorld(ctx context.Context, sel ast.SelectionSet, v model.World) graphql.Marshaler { + return ec._World(ctx, sel, &v) +} + +func (ec *executionContext) marshalNWorld2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐWorld(ctx context.Context, sel ast.SelectionSet, v *model.World) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._World(ctx, sel, v) +} + +func (ec *executionContext) marshalNWorldName2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐWorldName(ctx context.Context, sel ast.SelectionSet, v model.WorldName) graphql.Marshaler { + return ec._WorldName(ctx, sel, &v) +} + +func (ec *executionContext) marshalNWorldName2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐWorldName(ctx context.Context, sel ast.SelectionSet, v *model.WorldName) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._WorldName(ctx, sel, v) +} + +func (ec *executionContext) marshalNWorldWithMultipleKeys2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐWorldWithMultipleKeys(ctx context.Context, sel ast.SelectionSet, v model.WorldWithMultipleKeys) graphql.Marshaler { + return ec._WorldWithMultipleKeys(ctx, sel, &v) +} + +func (ec *executionContext) marshalNWorldWithMultipleKeys2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐWorldWithMultipleKeys(ctx context.Context, sel ast.SelectionSet, v *model.WorldWithMultipleKeys) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._WorldWithMultipleKeys(ctx, sel, v) +} + +func (ec *executionContext) unmarshalN_Any2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { + res, err := graphql.UnmarshalMap(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalN_Any2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + res := graphql.MarshalMap(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN_Any2ᚕmapᚄ(ctx context.Context, v interface{}) ([]map[string]interface{}, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]map[string]interface{}, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalN_Any2map(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalN_Any2ᚕmapᚄ(ctx context.Context, sel ast.SelectionSet, v []map[string]interface{}) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalN_Any2map(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalN_Entity2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v []fedruntime.Entity) 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.marshalO_Entity2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) unmarshalN_FieldSet2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalN_FieldSet2string(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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalN_Service2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx context.Context, sel ast.SelectionSet, v fedruntime.Service) graphql.Marshaler { + return ec.__Service(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + 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) marshalOHello2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐHello(ctx context.Context, sel ast.SelectionSet, v *model.Hello) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Hello(ctx, sel, v) +} + +func (ec *executionContext) marshalOMultiHello2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHello(ctx context.Context, sel ast.SelectionSet, v []*model.MultiHello) 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.marshalOMultiHello2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHello(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) marshalOMultiHello2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHello(ctx context.Context, sel ast.SelectionSet, v *model.MultiHello) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._MultiHello(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOMultiHelloByNamesInput2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloByNamesInput(ctx context.Context, v interface{}) (*model.MultiHelloByNamesInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMultiHelloByNamesInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOMultiHelloMultipleRequires2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloMultipleRequires(ctx context.Context, sel ast.SelectionSet, v []*model.MultiHelloMultipleRequires) 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.marshalOMultiHelloMultipleRequires2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloMultipleRequires(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) marshalOMultiHelloMultipleRequires2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloMultipleRequires(ctx context.Context, sel ast.SelectionSet, v *model.MultiHelloMultipleRequires) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._MultiHelloMultipleRequires(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOMultiHelloMultipleRequiresByNamesInput2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloMultipleRequiresByNamesInput(ctx context.Context, v interface{}) (*model.MultiHelloMultipleRequiresByNamesInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMultiHelloMultipleRequiresByNamesInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOMultiHelloRequires2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloRequires(ctx context.Context, sel ast.SelectionSet, v []*model.MultiHelloRequires) 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.marshalOMultiHelloRequires2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloRequires(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) marshalOMultiHelloRequires2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloRequires(ctx context.Context, sel ast.SelectionSet, v *model.MultiHelloRequires) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._MultiHelloRequires(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOMultiHelloRequiresByNamesInput2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloRequiresByNamesInput(ctx context.Context, v interface{}) (*model.MultiHelloRequiresByNamesInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMultiHelloRequiresByNamesInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOMultiHelloWithError2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloWithError(ctx context.Context, sel ast.SelectionSet, v []*model.MultiHelloWithError) 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.marshalOMultiHelloWithError2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloWithError(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) marshalOMultiHelloWithError2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloWithError(ctx context.Context, sel ast.SelectionSet, v *model.MultiHelloWithError) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._MultiHelloWithError(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOMultiHelloWithErrorByNamesInput2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloWithErrorByNamesInput(ctx context.Context, v interface{}) (*model.MultiHelloWithErrorByNamesInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMultiHelloWithErrorByNamesInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOMultiPlanetRequiresNested2ᚕᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiPlanetRequiresNested(ctx context.Context, sel ast.SelectionSet, v []*model.MultiPlanetRequiresNested) 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.marshalOMultiPlanetRequiresNested2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiPlanetRequiresNested(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) marshalOMultiPlanetRequiresNested2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiPlanetRequiresNested(ctx context.Context, sel ast.SelectionSet, v *model.MultiPlanetRequiresNested) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._MultiPlanetRequiresNested(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOMultiPlanetRequiresNestedByNamesInput2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiPlanetRequiresNestedByNamesInput(ctx context.Context, v interface{}) (*model.MultiPlanetRequiresNestedByNamesInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputMultiPlanetRequiresNestedByNamesInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +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 + } + 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) marshalO_Entity2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v fedruntime.Entity) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.__Entity(ctx, sel, v) +} + +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/plugin/federation/testdata/entityresolver/generated/federation.go b/plugin/federation/testdata/entityresolver/generated/federation.go new file mode 100644 index 0000000..7d28d58 --- /dev/null +++ b/plugin/federation/testdata/entityresolver/generated/federation.go @@ -0,0 +1,847 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package generated + +import ( + "context" + "errors" + "fmt" + "strings" + "sync" + + "github.com/niko0xdev/gqlgen/plugin/federation/fedruntime" + "github.com/niko0xdev/gqlgen/plugin/federation/testdata/entityresolver/generated/model" +) + +var ( + ErrUnknownType = errors.New("unknown type") + ErrTypeNotFound = errors.New("type not found") +) + +func (ec *executionContext) __resolve__service(ctx context.Context) (fedruntime.Service, error) { + if ec.DisableIntrospection { + return fedruntime.Service{}, errors.New("federated introspection disabled") + } + + var sdl []string + + for _, src := range sources { + if src.BuiltIn { + continue + } + sdl = append(sdl, src.Input) + } + + return fedruntime.Service{ + SDL: strings.Join(sdl, "\n"), + }, nil +} + +func (ec *executionContext) __resolve_entities(ctx context.Context, representations []map[string]interface{}) []fedruntime.Entity { + list := make([]fedruntime.Entity, len(representations)) + + repsMap := map[string]struct { + i []int + r []map[string]interface{} + }{} + + // We group entities by typename so that we can parallelize their resolution. + // This is particularly helpful when there are entity groups in multi mode. + buildRepresentationGroups := func(reps []map[string]interface{}) { + for i, rep := range reps { + typeName, ok := rep["__typename"].(string) + if !ok { + // If there is no __typename, we just skip the representation; + // we just won't be resolving these unknown types. + ec.Error(ctx, errors.New("__typename must be an existing string")) + continue + } + + _r := repsMap[typeName] + _r.i = append(_r.i, i) + _r.r = append(_r.r, rep) + repsMap[typeName] = _r + } + } + + isMulti := func(typeName string) bool { + switch typeName { + case "MultiHello": + return true + case "MultiHelloMultipleRequires": + return true + case "MultiHelloRequires": + return true + case "MultiHelloWithError": + return true + case "MultiPlanetRequiresNested": + return true + default: + return false + } + } + + resolveEntity := func(ctx context.Context, typeName string, rep map[string]interface{}, idx []int, i int) (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) + } + }() + + switch typeName { + case "Hello": + resolverName, err := entityResolverNameForHello(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "Hello": %w`, err) + } + switch resolverName { + + case "findHelloByName": + id0, err := ec.unmarshalNString2string(ctx, rep["name"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findHelloByName(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindHelloByName(ctx, id0) + if err != nil { + return fmt.Errorf(`resolving Entity "Hello": %w`, err) + } + + list[idx[i]] = entity + return nil + } + case "HelloMultiSingleKeys": + resolverName, err := entityResolverNameForHelloMultiSingleKeys(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "HelloMultiSingleKeys": %w`, err) + } + switch resolverName { + + case "findHelloMultiSingleKeysByKey1AndKey2": + id0, err := ec.unmarshalNString2string(ctx, rep["key1"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findHelloMultiSingleKeysByKey1AndKey2(): %w`, err) + } + id1, err := ec.unmarshalNString2string(ctx, rep["key2"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 1 for findHelloMultiSingleKeysByKey1AndKey2(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindHelloMultiSingleKeysByKey1AndKey2(ctx, id0, id1) + if err != nil { + return fmt.Errorf(`resolving Entity "HelloMultiSingleKeys": %w`, err) + } + + list[idx[i]] = entity + return nil + } + case "HelloWithErrors": + resolverName, err := entityResolverNameForHelloWithErrors(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "HelloWithErrors": %w`, err) + } + switch resolverName { + + case "findHelloWithErrorsByName": + id0, err := ec.unmarshalNString2string(ctx, rep["name"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findHelloWithErrorsByName(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindHelloWithErrorsByName(ctx, id0) + if err != nil { + return fmt.Errorf(`resolving Entity "HelloWithErrors": %w`, err) + } + + list[idx[i]] = entity + return nil + } + case "PlanetMultipleRequires": + resolverName, err := entityResolverNameForPlanetMultipleRequires(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "PlanetMultipleRequires": %w`, err) + } + switch resolverName { + + case "findPlanetMultipleRequiresByName": + id0, err := ec.unmarshalNString2string(ctx, rep["name"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findPlanetMultipleRequiresByName(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindPlanetMultipleRequiresByName(ctx, id0) + if err != nil { + return fmt.Errorf(`resolving Entity "PlanetMultipleRequires": %w`, err) + } + + entity.Diameter, err = ec.unmarshalNInt2int(ctx, rep["diameter"]) + if err != nil { + return err + } + entity.Density, err = ec.unmarshalNInt2int(ctx, rep["density"]) + if err != nil { + return err + } + list[idx[i]] = entity + return nil + } + case "PlanetRequires": + resolverName, err := entityResolverNameForPlanetRequires(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "PlanetRequires": %w`, err) + } + switch resolverName { + + case "findPlanetRequiresByName": + id0, err := ec.unmarshalNString2string(ctx, rep["name"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findPlanetRequiresByName(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindPlanetRequiresByName(ctx, id0) + if err != nil { + return fmt.Errorf(`resolving Entity "PlanetRequires": %w`, err) + } + + entity.Diameter, err = ec.unmarshalNInt2int(ctx, rep["diameter"]) + if err != nil { + return err + } + list[idx[i]] = entity + return nil + } + case "PlanetRequiresNested": + resolverName, err := entityResolverNameForPlanetRequiresNested(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "PlanetRequiresNested": %w`, err) + } + switch resolverName { + + case "findPlanetRequiresNestedByName": + id0, err := ec.unmarshalNString2string(ctx, rep["name"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findPlanetRequiresNestedByName(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindPlanetRequiresNestedByName(ctx, id0) + if err != nil { + return fmt.Errorf(`resolving Entity "PlanetRequiresNested": %w`, err) + } + + entity.World.Foo, err = ec.unmarshalNString2string(ctx, rep["world"].(map[string]interface{})["foo"]) + if err != nil { + return err + } + list[idx[i]] = entity + return nil + } + case "World": + resolverName, err := entityResolverNameForWorld(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "World": %w`, err) + } + switch resolverName { + + case "findWorldByHelloNameAndFoo": + id0, err := ec.unmarshalNString2string(ctx, rep["hello"].(map[string]interface{})["name"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findWorldByHelloNameAndFoo(): %w`, err) + } + id1, err := ec.unmarshalNString2string(ctx, rep["foo"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 1 for findWorldByHelloNameAndFoo(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindWorldByHelloNameAndFoo(ctx, id0, id1) + if err != nil { + return fmt.Errorf(`resolving Entity "World": %w`, err) + } + + list[idx[i]] = entity + return nil + } + case "WorldName": + resolverName, err := entityResolverNameForWorldName(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "WorldName": %w`, err) + } + switch resolverName { + + case "findWorldNameByName": + id0, err := ec.unmarshalNString2string(ctx, rep["name"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findWorldNameByName(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindWorldNameByName(ctx, id0) + if err != nil { + return fmt.Errorf(`resolving Entity "WorldName": %w`, err) + } + + list[idx[i]] = entity + return nil + } + case "WorldWithMultipleKeys": + resolverName, err := entityResolverNameForWorldWithMultipleKeys(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "WorldWithMultipleKeys": %w`, err) + } + switch resolverName { + + case "findWorldWithMultipleKeysByHelloNameAndFoo": + id0, err := ec.unmarshalNString2string(ctx, rep["hello"].(map[string]interface{})["name"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findWorldWithMultipleKeysByHelloNameAndFoo(): %w`, err) + } + id1, err := ec.unmarshalNString2string(ctx, rep["foo"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 1 for findWorldWithMultipleKeysByHelloNameAndFoo(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindWorldWithMultipleKeysByHelloNameAndFoo(ctx, id0, id1) + if err != nil { + return fmt.Errorf(`resolving Entity "WorldWithMultipleKeys": %w`, err) + } + + list[idx[i]] = entity + return nil + case "findWorldWithMultipleKeysByBar": + id0, err := ec.unmarshalNInt2int(ctx, rep["bar"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findWorldWithMultipleKeysByBar(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindWorldWithMultipleKeysByBar(ctx, id0) + if err != nil { + return fmt.Errorf(`resolving Entity "WorldWithMultipleKeys": %w`, err) + } + + list[idx[i]] = entity + return nil + } + + } + return fmt.Errorf("%w: %s", ErrUnknownType, typeName) + } + + resolveManyEntities := func(ctx context.Context, typeName string, reps []map[string]interface{}, idx []int) (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) + } + }() + + switch typeName { + + case "MultiHello": + resolverName, err := entityResolverNameForMultiHello(ctx, reps[0]) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "MultiHello": %w`, err) + } + switch resolverName { + + case "findManyMultiHelloByNames": + _reps := make([]*model.MultiHelloByNamesInput, len(reps)) + + for i, rep := range reps { + id0, err := ec.unmarshalNString2string(ctx, rep["name"]) + if err != nil { + return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name")) + } + + _reps[i] = &model.MultiHelloByNamesInput{ + Name: id0, + } + } + + entities, err := ec.resolvers.Entity().FindManyMultiHelloByNames(ctx, _reps) + if err != nil { + return err + } + + for i, entity := range entities { + list[idx[i]] = entity + } + return nil + + default: + return fmt.Errorf("unknown resolver: %s", resolverName) + } + + case "MultiHelloMultipleRequires": + resolverName, err := entityResolverNameForMultiHelloMultipleRequires(ctx, reps[0]) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "MultiHelloMultipleRequires": %w`, err) + } + switch resolverName { + + case "findManyMultiHelloMultipleRequiresByNames": + _reps := make([]*model.MultiHelloMultipleRequiresByNamesInput, len(reps)) + + for i, rep := range reps { + id0, err := ec.unmarshalNString2string(ctx, rep["name"]) + if err != nil { + return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name")) + } + + _reps[i] = &model.MultiHelloMultipleRequiresByNamesInput{ + Name: id0, + } + } + + entities, err := ec.resolvers.Entity().FindManyMultiHelloMultipleRequiresByNames(ctx, _reps) + if err != nil { + return err + } + + for i, entity := range entities { + entity.Key1, err = ec.unmarshalNString2string(ctx, reps[i]["key1"]) + if err != nil { + return err + } + entity.Key2, err = ec.unmarshalNString2string(ctx, reps[i]["key2"]) + if err != nil { + return err + } + list[idx[i]] = entity + } + return nil + + default: + return fmt.Errorf("unknown resolver: %s", resolverName) + } + + case "MultiHelloRequires": + resolverName, err := entityResolverNameForMultiHelloRequires(ctx, reps[0]) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "MultiHelloRequires": %w`, err) + } + switch resolverName { + + case "findManyMultiHelloRequiresByNames": + _reps := make([]*model.MultiHelloRequiresByNamesInput, len(reps)) + + for i, rep := range reps { + id0, err := ec.unmarshalNString2string(ctx, rep["name"]) + if err != nil { + return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name")) + } + + _reps[i] = &model.MultiHelloRequiresByNamesInput{ + Name: id0, + } + } + + entities, err := ec.resolvers.Entity().FindManyMultiHelloRequiresByNames(ctx, _reps) + if err != nil { + return err + } + + for i, entity := range entities { + entity.Key1, err = ec.unmarshalNString2string(ctx, reps[i]["key1"]) + if err != nil { + return err + } + list[idx[i]] = entity + } + return nil + + default: + return fmt.Errorf("unknown resolver: %s", resolverName) + } + + case "MultiHelloWithError": + resolverName, err := entityResolverNameForMultiHelloWithError(ctx, reps[0]) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "MultiHelloWithError": %w`, err) + } + switch resolverName { + + case "findManyMultiHelloWithErrorByNames": + _reps := make([]*model.MultiHelloWithErrorByNamesInput, len(reps)) + + for i, rep := range reps { + id0, err := ec.unmarshalNString2string(ctx, rep["name"]) + if err != nil { + return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name")) + } + + _reps[i] = &model.MultiHelloWithErrorByNamesInput{ + Name: id0, + } + } + + entities, err := ec.resolvers.Entity().FindManyMultiHelloWithErrorByNames(ctx, _reps) + if err != nil { + return err + } + + for i, entity := range entities { + list[idx[i]] = entity + } + return nil + + default: + return fmt.Errorf("unknown resolver: %s", resolverName) + } + + case "MultiPlanetRequiresNested": + resolverName, err := entityResolverNameForMultiPlanetRequiresNested(ctx, reps[0]) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "MultiPlanetRequiresNested": %w`, err) + } + switch resolverName { + + case "findManyMultiPlanetRequiresNestedByNames": + _reps := make([]*model.MultiPlanetRequiresNestedByNamesInput, len(reps)) + + for i, rep := range reps { + id0, err := ec.unmarshalNString2string(ctx, rep["name"]) + if err != nil { + return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name")) + } + + _reps[i] = &model.MultiPlanetRequiresNestedByNamesInput{ + Name: id0, + } + } + + entities, err := ec.resolvers.Entity().FindManyMultiPlanetRequiresNestedByNames(ctx, _reps) + if err != nil { + return err + } + + for i, entity := range entities { + entity.World.Foo, err = ec.unmarshalNString2string(ctx, reps[i]["world"].(map[string]interface{})["foo"]) + if err != nil { + return err + } + list[idx[i]] = entity + } + return nil + + default: + return fmt.Errorf("unknown resolver: %s", resolverName) + } + + default: + return errors.New("unknown type: " + typeName) + } + } + + resolveEntityGroup := func(typeName string, reps []map[string]interface{}, idx []int) { + if isMulti(typeName) { + err := resolveManyEntities(ctx, typeName, reps, idx) + if err != nil { + ec.Error(ctx, err) + } + } else { + // if there are multiple entities to resolve, parallelize (similar to + // graphql.FieldSet.Dispatch) + var e sync.WaitGroup + e.Add(len(reps)) + for i, rep := range reps { + i, rep := i, rep + go func(i int, rep map[string]interface{}) { + err := resolveEntity(ctx, typeName, rep, idx, i) + if err != nil { + ec.Error(ctx, err) + } + e.Done() + }(i, rep) + } + e.Wait() + } + } + buildRepresentationGroups(representations) + + switch len(repsMap) { + case 0: + return list + case 1: + for typeName, reps := range repsMap { + resolveEntityGroup(typeName, reps.r, reps.i) + } + return list + default: + var g sync.WaitGroup + g.Add(len(repsMap)) + for typeName, reps := range repsMap { + go func(typeName string, reps []map[string]interface{}, idx []int) { + resolveEntityGroup(typeName, reps, idx) + g.Done() + }(typeName, reps.r, reps.i) + } + g.Wait() + return list + } +} + +func entityResolverNameForHello(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["name"]; !ok { + break + } + return "findHelloByName", nil + } + return "", fmt.Errorf("%w for Hello", ErrTypeNotFound) +} + +func entityResolverNameForHelloMultiSingleKeys(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["key1"]; !ok { + break + } + m = rep + if _, ok = m["key2"]; !ok { + break + } + return "findHelloMultiSingleKeysByKey1AndKey2", nil + } + return "", fmt.Errorf("%w for HelloMultiSingleKeys", ErrTypeNotFound) +} + +func entityResolverNameForHelloWithErrors(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["name"]; !ok { + break + } + return "findHelloWithErrorsByName", nil + } + return "", fmt.Errorf("%w for HelloWithErrors", ErrTypeNotFound) +} + +func entityResolverNameForMultiHello(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["name"]; !ok { + break + } + return "findManyMultiHelloByNames", nil + } + return "", fmt.Errorf("%w for MultiHello", ErrTypeNotFound) +} + +func entityResolverNameForMultiHelloMultipleRequires(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["name"]; !ok { + break + } + return "findManyMultiHelloMultipleRequiresByNames", nil + } + return "", fmt.Errorf("%w for MultiHelloMultipleRequires", ErrTypeNotFound) +} + +func entityResolverNameForMultiHelloRequires(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["name"]; !ok { + break + } + return "findManyMultiHelloRequiresByNames", nil + } + return "", fmt.Errorf("%w for MultiHelloRequires", ErrTypeNotFound) +} + +func entityResolverNameForMultiHelloWithError(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["name"]; !ok { + break + } + return "findManyMultiHelloWithErrorByNames", nil + } + return "", fmt.Errorf("%w for MultiHelloWithError", ErrTypeNotFound) +} + +func entityResolverNameForMultiPlanetRequiresNested(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["name"]; !ok { + break + } + return "findManyMultiPlanetRequiresNestedByNames", nil + } + return "", fmt.Errorf("%w for MultiPlanetRequiresNested", ErrTypeNotFound) +} + +func entityResolverNameForPlanetMultipleRequires(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["name"]; !ok { + break + } + return "findPlanetMultipleRequiresByName", nil + } + return "", fmt.Errorf("%w for PlanetMultipleRequires", ErrTypeNotFound) +} + +func entityResolverNameForPlanetRequires(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["name"]; !ok { + break + } + return "findPlanetRequiresByName", nil + } + return "", fmt.Errorf("%w for PlanetRequires", ErrTypeNotFound) +} + +func entityResolverNameForPlanetRequiresNested(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["name"]; !ok { + break + } + return "findPlanetRequiresNestedByName", nil + } + return "", fmt.Errorf("%w for PlanetRequiresNested", ErrTypeNotFound) +} + +func entityResolverNameForWorld(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if val, ok = m["hello"]; !ok { + break + } + if m, ok = val.(map[string]interface{}); !ok { + break + } + if _, ok = m["name"]; !ok { + break + } + m = rep + if _, ok = m["foo"]; !ok { + break + } + return "findWorldByHelloNameAndFoo", nil + } + return "", fmt.Errorf("%w for World", ErrTypeNotFound) +} + +func entityResolverNameForWorldName(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["name"]; !ok { + break + } + return "findWorldNameByName", nil + } + return "", fmt.Errorf("%w for WorldName", ErrTypeNotFound) +} + +func entityResolverNameForWorldWithMultipleKeys(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if val, ok = m["hello"]; !ok { + break + } + if m, ok = val.(map[string]interface{}); !ok { + break + } + if _, ok = m["name"]; !ok { + break + } + m = rep + if _, ok = m["foo"]; !ok { + break + } + return "findWorldWithMultipleKeysByHelloNameAndFoo", nil + } + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["bar"]; !ok { + break + } + return "findWorldWithMultipleKeysByBar", nil + } + return "", fmt.Errorf("%w for WorldWithMultipleKeys", ErrTypeNotFound) +} diff --git a/plugin/federation/testdata/entityresolver/generated/model/models.go b/plugin/federation/testdata/entityresolver/generated/model/models.go new file mode 100644 index 0000000..7859a7a --- /dev/null +++ b/plugin/federation/testdata/entityresolver/generated/model/models.go @@ -0,0 +1,130 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package model + +type Hello struct { + Name string `json:"name"` + Secondary string `json:"secondary"` +} + +func (Hello) IsEntity() {} + +type HelloMultiSingleKeys struct { + Key1 string `json:"key1"` + Key2 string `json:"key2"` +} + +func (HelloMultiSingleKeys) IsEntity() {} + +type HelloWithErrors struct { + Name string `json:"name"` +} + +func (HelloWithErrors) IsEntity() {} + +type MultiHello struct { + Name string `json:"name"` +} + +func (MultiHello) IsEntity() {} + +type MultiHelloByNamesInput struct { + Name string `json:"Name"` +} + +type MultiHelloMultipleRequires struct { + Name string `json:"name"` + Key1 string `json:"key1"` + Key2 string `json:"key2"` + Key3 string `json:"key3"` +} + +func (MultiHelloMultipleRequires) IsEntity() {} + +type MultiHelloMultipleRequiresByNamesInput struct { + Name string `json:"Name"` +} + +type MultiHelloRequires struct { + Name string `json:"name"` + Key1 string `json:"key1"` + Key2 string `json:"key2"` +} + +func (MultiHelloRequires) IsEntity() {} + +type MultiHelloRequiresByNamesInput struct { + Name string `json:"Name"` +} + +type MultiHelloWithError struct { + Name string `json:"name"` +} + +func (MultiHelloWithError) IsEntity() {} + +type MultiHelloWithErrorByNamesInput struct { + Name string `json:"Name"` +} + +type MultiPlanetRequiresNested struct { + Name string `json:"name"` + World *World `json:"world"` + Size int `json:"size"` +} + +func (MultiPlanetRequiresNested) IsEntity() {} + +type MultiPlanetRequiresNestedByNamesInput struct { + Name string `json:"Name"` +} + +type PlanetMultipleRequires struct { + Name string `json:"name"` + Diameter int `json:"diameter"` + Density int `json:"density"` + Weight int `json:"weight"` +} + +func (PlanetMultipleRequires) IsEntity() {} + +type PlanetRequires struct { + Name string `json:"name"` + Size int `json:"size"` + Diameter int `json:"diameter"` +} + +func (PlanetRequires) IsEntity() {} + +type PlanetRequiresNested struct { + Name string `json:"name"` + World *World `json:"world"` + Size int `json:"size"` +} + +func (PlanetRequiresNested) IsEntity() {} + +type Query struct { +} + +type World struct { + Foo string `json:"foo"` + Bar int `json:"bar"` + Hello *Hello `json:"hello,omitempty"` +} + +func (World) IsEntity() {} + +type WorldName struct { + Name string `json:"name"` +} + +func (WorldName) IsEntity() {} + +type WorldWithMultipleKeys struct { + Foo string `json:"foo"` + Bar int `json:"bar"` + Hello *Hello `json:"hello,omitempty"` +} + +func (WorldWithMultipleKeys) IsEntity() {} diff --git a/plugin/federation/testdata/entityresolver/gqlgen.yml b/plugin/federation/testdata/entityresolver/gqlgen.yml new file mode 100644 index 0000000..c576080 --- /dev/null +++ b/plugin/federation/testdata/entityresolver/gqlgen.yml @@ -0,0 +1,14 @@ +schema: + - "testdata/entityresolver/schema.graphql" +exec: + filename: testdata/entityresolver/generated/exec.go +federation: + filename: testdata/entityresolver/generated/federation.go +model: + filename: testdata/entityresolver/generated/model/models.go + package: model +resolver: + filename: testdata/entityresolver/resolver.go + layout: follow-schema + dir: testdata/entityresolver + package: entityresolver diff --git a/plugin/federation/testdata/entityresolver/resolver.go b/plugin/federation/testdata/entityresolver/resolver.go new file mode 100644 index 0000000..3ac5a8b --- /dev/null +++ b/plugin/federation/testdata/entityresolver/resolver.go @@ -0,0 +1,7 @@ +package entityresolver + +// This file will not be regenerated automatically. +// +// It serves as dependency injection for your app, add any dependencies you require here. + +type Resolver struct{} diff --git a/plugin/federation/testdata/entityresolver/schema.graphql b/plugin/federation/testdata/entityresolver/schema.graphql new file mode 100644 index 0000000..a5588d8 --- /dev/null +++ b/plugin/federation/testdata/entityresolver/schema.graphql @@ -0,0 +1,77 @@ +directive @entityResolver(multi: Boolean) on OBJECT + +type Hello @key(fields: "name") { + name: String! + secondary: String! +} + +type World @key(fields: "hello { name } foo ") { + foo: String! + bar: Int! + hello: Hello +} + +type WorldWithMultipleKeys @key(fields: "hello { name } foo ") @key(fields: "bar") { + foo: String! + bar: Int! + hello: Hello +} + +type WorldName @key(fields: "name") { + name: String! +} + +type HelloWithErrors @key(fields: "name") { + name: String! +} + +type PlanetRequires @key(fields: "name") { + name: String! + size: Int! @requires(fields: "diameter") + diameter: Int! +} + +type PlanetMultipleRequires @key(fields: "name") { + name: String! @external + diameter: Int! @external + density: Int! @external + weight: Int! @requires(fields: "diameter density") +} + +type PlanetRequiresNested @key(fields: "name") { + name: String! @external + world: World! @external + size: Int! @requires(fields: "world{ foo }") +} + +type MultiPlanetRequiresNested @key(fields: "name") @entityResolver(multi: true) { + name: String! @external + world: World! @external + size: Int! @requires(fields: "world{ foo }") +} + +type MultiHello @key(fields: "name") @entityResolver(multi: true) { + name: String! +} + +type MultiHelloWithError @key(fields: "name") @entityResolver(multi: true) { + name: String! +} + +type HelloMultiSingleKeys @key(fields: "key1 key2") { + key1: String! + key2: String! +} + +type MultiHelloRequires @key(fields: "name") @entityResolver(multi: true) { + name: String! @external + key1: String! @external + key2: String! @requires(fields: "key1") +} + +type MultiHelloMultipleRequires @key(fields: "name") @entityResolver(multi: true) { + name: String! @external + key1: String! @external + key2: String! @external + key3: String! @requires(fields: "key1 key2") +} diff --git a/plugin/federation/testdata/entityresolver/schema.resolvers.go b/plugin/federation/testdata/entityresolver/schema.resolvers.go new file mode 100644 index 0000000..2f55aa7 --- /dev/null +++ b/plugin/federation/testdata/entityresolver/schema.resolvers.go @@ -0,0 +1,4 @@ +package entityresolver + +// 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. diff --git a/plugin/federation/testdata/federation2/federation2.graphql b/plugin/federation/testdata/federation2/federation2.graphql new file mode 100644 index 0000000..5355cb8 --- /dev/null +++ b/plugin/federation/testdata/federation2/federation2.graphql @@ -0,0 +1,25 @@ +extend schema + @link(url: "https://specs.apollo.dev/federation/v2.3", + import: ["@key", "@shareable", "@provides", "@external", "@tag", "@extends", "@override", "@inaccessible", "@interfaceObject"]) + +schema { + query: CustomQuery +} + +type Hello @key(fields:"name", resolvable: false) { + name: String! +} + +type World @key(fields: "foo bar", resolvable: false) { + foo: String! + bar: Int! +} + +extend type ExternalExtension @key(fields: " upc ") { + upc: String! + reviews: [Hello] +} + +type CustomQuery { + hello: Hello! +} diff --git a/plugin/federation/testdata/federation2/federation2.yml b/plugin/federation/testdata/federation2/federation2.yml new file mode 100644 index 0000000..7ba709b --- /dev/null +++ b/plugin/federation/testdata/federation2/federation2.yml @@ -0,0 +1,10 @@ +schema: + - "testdata/federation2/federation2.graphql" +exec: + filename: testdata/federation2/generated/exec.go +federation: + filename: testdata/federation2/generated/federation.go + version: 2 + +autobind: + - "github.com/niko0xdev/gqlgen/plugin/federation/test_data/model2" diff --git a/plugin/federation/testdata/federation2/generated/federation.go b/plugin/federation/testdata/federation2/generated/federation.go new file mode 100644 index 0000000..4d0d8c8 --- /dev/null +++ b/plugin/federation/testdata/federation2/generated/federation.go @@ -0,0 +1,187 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package generated + +import ( + "context" + "errors" + "fmt" + "strings" + "sync" + + "github.com/niko0xdev/gqlgen/plugin/federation/fedruntime" +) + +var ( + ErrUnknownType = errors.New("unknown type") + ErrTypeNotFound = errors.New("type not found") +) + +func (ec *executionContext) __resolve__service(ctx context.Context) (fedruntime.Service, error) { + if ec.DisableIntrospection { + return fedruntime.Service{}, errors.New("federated introspection disabled") + } + + var sdl []string + + for _, src := range sources { + if src.BuiltIn { + continue + } + sdl = append(sdl, src.Input) + } + + return fedruntime.Service{ + SDL: strings.Join(sdl, "\n"), + }, nil +} + +func (ec *executionContext) __resolve_entities(ctx context.Context, representations []map[string]interface{}) []fedruntime.Entity { + list := make([]fedruntime.Entity, len(representations)) + + repsMap := map[string]struct { + i []int + r []map[string]interface{} + }{} + + // We group entities by typename so that we can parallelize their resolution. + // This is particularly helpful when there are entity groups in multi mode. + buildRepresentationGroups := func(reps []map[string]interface{}) { + for i, rep := range reps { + typeName, ok := rep["__typename"].(string) + if !ok { + // If there is no __typename, we just skip the representation; + // we just won't be resolving these unknown types. + ec.Error(ctx, errors.New("__typename must be an existing string")) + continue + } + + _r := repsMap[typeName] + _r.i = append(_r.i, i) + _r.r = append(_r.r, rep) + repsMap[typeName] = _r + } + } + + isMulti := func(typeName string) bool { + switch typeName { + default: + return false + } + } + + resolveEntity := func(ctx context.Context, typeName string, rep map[string]interface{}, idx []int, i int) (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) + } + }() + + switch typeName { + case "ExternalExtension": + resolverName, err := entityResolverNameForExternalExtension(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "ExternalExtension": %w`, err) + } + switch resolverName { + + case "findExternalExtensionByUpc": + id0, err := ec.unmarshalNString2string(ctx, rep["upc"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findExternalExtensionByUpc(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindExternalExtensionByUpc(ctx, id0) + if err != nil { + return fmt.Errorf(`resolving Entity "ExternalExtension": %w`, err) + } + + list[idx[i]] = entity + return nil + } + + } + return fmt.Errorf("%w: %s", ErrUnknownType, typeName) + } + + resolveManyEntities := func(ctx context.Context, typeName string, reps []map[string]interface{}, idx []int) (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) + } + }() + + switch typeName { + + default: + return errors.New("unknown type: " + typeName) + } + } + + resolveEntityGroup := func(typeName string, reps []map[string]interface{}, idx []int) { + if isMulti(typeName) { + err := resolveManyEntities(ctx, typeName, reps, idx) + if err != nil { + ec.Error(ctx, err) + } + } else { + // if there are multiple entities to resolve, parallelize (similar to + // graphql.FieldSet.Dispatch) + var e sync.WaitGroup + e.Add(len(reps)) + for i, rep := range reps { + i, rep := i, rep + go func(i int, rep map[string]interface{}) { + err := resolveEntity(ctx, typeName, rep, idx, i) + if err != nil { + ec.Error(ctx, err) + } + e.Done() + }(i, rep) + } + e.Wait() + } + } + buildRepresentationGroups(representations) + + switch len(repsMap) { + case 0: + return list + case 1: + for typeName, reps := range repsMap { + resolveEntityGroup(typeName, reps.r, reps.i) + } + return list + default: + var g sync.WaitGroup + g.Add(len(repsMap)) + for typeName, reps := range repsMap { + go func(typeName string, reps []map[string]interface{}, idx []int) { + resolveEntityGroup(typeName, reps, idx) + g.Done() + }(typeName, reps.r, reps.i) + } + g.Wait() + return list + } +} + +func entityResolverNameForExternalExtension(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["upc"]; !ok { + break + } + return "findExternalExtensionByUpc", nil + } + return "", fmt.Errorf("%w for ExternalExtension", ErrTypeNotFound) +} diff --git a/plugin/federation/testdata/interfaces/extends.graphqls b/plugin/federation/testdata/interfaces/extends.graphqls new file mode 100644 index 0000000..0151d8e --- /dev/null +++ b/plugin/federation/testdata/interfaces/extends.graphqls @@ -0,0 +1,11 @@ +interface Hello @extends { + name: String! + secondary: String! +} + +extend type World implements Hello @key(fields: "name") { + name: String! @external + secondary: String! + + tertiary: String! +} diff --git a/plugin/federation/testdata/interfaces/extends.yml b/plugin/federation/testdata/interfaces/extends.yml new file mode 100644 index 0000000..00fa0ce --- /dev/null +++ b/plugin/federation/testdata/interfaces/extends.yml @@ -0,0 +1,6 @@ +schema: + - "testdata/interfaces/extends.graphqls" +exec: + filename: testdata/interfaces/generated/exec.go +federation: + filename: testdata/interfaces/generated/federation.go diff --git a/plugin/federation/testdata/interfaces/key.graphqls b/plugin/federation/testdata/interfaces/key.graphqls new file mode 100644 index 0000000..d77f5e1 --- /dev/null +++ b/plugin/federation/testdata/interfaces/key.graphqls @@ -0,0 +1,9 @@ +extend interface Hello @key(fields: "name") { + name: String! + secondary: String! +} + +type World implements Hello @key(fields: "name") { + name: String! + secondary: String! +} diff --git a/plugin/federation/testdata/interfaces/key.yml b/plugin/federation/testdata/interfaces/key.yml new file mode 100644 index 0000000..86b89ad --- /dev/null +++ b/plugin/federation/testdata/interfaces/key.yml @@ -0,0 +1,6 @@ +schema: + - "testdata/interfaces/key.graphqls" +exec: + filename: testdata/interfaces/generated/exec.go +federation: + filename: testdata/interfaces/generated/federation.go diff --git a/plugin/federation/testdata/interfaces/unused_key.graphqls b/plugin/federation/testdata/interfaces/unused_key.graphqls new file mode 100644 index 0000000..b0abaca --- /dev/null +++ b/plugin/federation/testdata/interfaces/unused_key.graphqls @@ -0,0 +1,4 @@ +extend interface Hello @key(fields: "name") { + name: String! + secondary: String! +} diff --git a/plugin/federation/testdata/interfaces/unused_key.yml b/plugin/federation/testdata/interfaces/unused_key.yml new file mode 100644 index 0000000..dd196d2 --- /dev/null +++ b/plugin/federation/testdata/interfaces/unused_key.yml @@ -0,0 +1,6 @@ +schema: + - "testdata/interfaces/unused_key.graphqls" +exec: + filename: testdata/interfaces/generated/exec.go +federation: + filename: testdata/interfaces/generated/federation.go diff --git a/plugin/federation/testdata/multi/multi.graphqls b/plugin/federation/testdata/multi/multi.graphqls new file mode 100644 index 0000000..bf37c5a --- /dev/null +++ b/plugin/federation/testdata/multi/multi.graphqls @@ -0,0 +1,10 @@ +extend schema + @link(url: "https://specs.apollo.dev/federation/v2.3", + import: ["@key"]) + +directive @entityResolver(multi: Boolean) on OBJECT + +type Hello @key(fields: "name") @entityResolver(multi: true) { + name: String! + secondary: String! +} diff --git a/plugin/federation/testdata/multi/multi.yml b/plugin/federation/testdata/multi/multi.yml new file mode 100644 index 0000000..891466c --- /dev/null +++ b/plugin/federation/testdata/multi/multi.yml @@ -0,0 +1,8 @@ +schema: + - "testdata/multi/multi.graphqls" +exec: + filename: testdata/multi/generated/exec.go +federation: + version: 2 + filename: testdata/multi/generated/federation.go +omit_slice_element_pointers: true \ No newline at end of file diff --git a/plugin/federation/testdata/schema/customquerytype.graphql b/plugin/federation/testdata/schema/customquerytype.graphql new file mode 100644 index 0000000..b6e227a --- /dev/null +++ b/plugin/federation/testdata/schema/customquerytype.graphql @@ -0,0 +1,12 @@ +schema { + query: CustomQuery +} + +type Hello { + name: String! +} + +type CustomQuery { + hello: Hello! +} + diff --git a/plugin/federation/testdata/schema/customquerytype.yml b/plugin/federation/testdata/schema/customquerytype.yml new file mode 100644 index 0000000..0e20da6 --- /dev/null +++ b/plugin/federation/testdata/schema/customquerytype.yml @@ -0,0 +1,9 @@ +schema: + - "testdata/schema/customquerytype.graphql" +exec: + filename: testdata/schema/generated/exec.go +federation: + filename: testdata/schema/generated/federation.go + +autobind: + - "github.com/niko0xdev/gqlgen/plugin/federation/test_data/model" diff --git a/plugin/modelgen/internal/extrafields/types.go b/plugin/modelgen/internal/extrafields/types.go new file mode 100644 index 0000000..680effd --- /dev/null +++ b/plugin/modelgen/internal/extrafields/types.go @@ -0,0 +1,3 @@ +package extrafields + +type Type struct{} diff --git a/plugin/modelgen/models.go b/plugin/modelgen/models.go new file mode 100644 index 0000000..3ddb937 --- /dev/null +++ b/plugin/modelgen/models.go @@ -0,0 +1,688 @@ +package modelgen + +import ( + _ "embed" + "fmt" + "go/types" + "os" + "sort" + "strings" + "text/template" + + "github.com/vektah/gqlparser/v2/ast" + + "github.com/niko0xdev/gqlgen/codegen/config" + "github.com/niko0xdev/gqlgen/codegen/templates" + "github.com/niko0xdev/gqlgen/plugin" +) + +//go:embed models.gotpl +var modelTemplate string + +type ( + BuildMutateHook = func(b *ModelBuild) *ModelBuild + FieldMutateHook = func(td *ast.Definition, fd *ast.FieldDefinition, f *Field) (*Field, error) +) + +// DefaultFieldMutateHook is the default hook for the Plugin which applies the GoFieldHook and GoTagFieldHook. +func DefaultFieldMutateHook(td *ast.Definition, fd *ast.FieldDefinition, f *Field) (*Field, error) { + var err error + f, err = GoFieldHook(td, fd, f) + if err != nil { + return f, err + } + return GoTagFieldHook(td, fd, f) +} + +// DefaultBuildMutateHook is the default hook for the Plugin which mutate ModelBuild. +func DefaultBuildMutateHook(b *ModelBuild) *ModelBuild { + return b +} + +type ModelBuild struct { + PackageName string + Interfaces []*Interface + Models []*Object + Enums []*Enum + Scalars []string +} + +type Interface struct { + Description string + Name string + Fields []*Field + Implements []string + OmitCheck bool + Models []*Object +} + +type Object struct { + Description string + Name string + Fields []*Field + Implements []string +} + +type Field struct { + Description string + // Name is the field's name as it appears in the schema + Name string + // GoName is the field's name as it appears in the generated Go code + GoName string + Type types.Type + Tag string + Omittable bool +} + +type Enum struct { + Description string + Name string + Values []*EnumValue +} + +type EnumValue struct { + Description string + Name string +} + +func New() plugin.Plugin { + return &Plugin{ + MutateHook: DefaultBuildMutateHook, + FieldHook: DefaultFieldMutateHook, + } +} + +type Plugin struct { + MutateHook BuildMutateHook + FieldHook FieldMutateHook +} + +var _ plugin.ConfigMutator = &Plugin{} + +func (m *Plugin) Name() string { + return "modelgen" +} + +func (m *Plugin) MutateConfig(cfg *config.Config) error { + b := &ModelBuild{ + PackageName: cfg.Model.Package, + } + + for _, schemaType := range cfg.Schema.Types { + if cfg.Models.UserDefined(schemaType.Name) { + continue + } + switch schemaType.Kind { + case ast.Interface, ast.Union: + var fields []*Field + var err error + if !cfg.OmitGetters { + fields, err = m.generateFields(cfg, schemaType) + if err != nil { + return err + } + } + + it := &Interface{ + Description: schemaType.Description, + Name: schemaType.Name, + Implements: schemaType.Interfaces, + Fields: fields, + OmitCheck: cfg.OmitInterfaceChecks, + } + + // if the interface has a key directive as an entity interface, allow it to implement _Entity + if schemaType.Directives.ForName("key") != nil { + it.Implements = append(it.Implements, "_Entity") + } + + b.Interfaces = append(b.Interfaces, it) + case ast.Object, ast.InputObject: + if cfg.IsRoot(schemaType) { + if !cfg.OmitRootModels { + b.Models = append(b.Models, &Object{ + Description: schemaType.Description, + Name: schemaType.Name, + }) + } + continue + } + + fields, err := m.generateFields(cfg, schemaType) + if err != nil { + return err + } + + it := &Object{ + Description: schemaType.Description, + Name: schemaType.Name, + Fields: fields, + } + + // If Interface A implements interface B, and Interface C also implements interface B + // then both A and C have methods of B. + // The reason for checking unique is to prevent the same method B from being generated twice. + uniqueMap := map[string]bool{} + for _, implementor := range cfg.Schema.GetImplements(schemaType) { + if !uniqueMap[implementor.Name] { + it.Implements = append(it.Implements, implementor.Name) + uniqueMap[implementor.Name] = true + } + // for interface implements + for _, iface := range implementor.Interfaces { + if !uniqueMap[iface] { + it.Implements = append(it.Implements, iface) + uniqueMap[iface] = true + } + } + + } + + b.Models = append(b.Models, it) + case ast.Enum: + it := &Enum{ + Name: schemaType.Name, + Description: schemaType.Description, + } + + for _, v := range schemaType.EnumValues { + it.Values = append(it.Values, &EnumValue{ + Name: v.Name, + Description: v.Description, + }) + } + + b.Enums = append(b.Enums, it) + case ast.Scalar: + b.Scalars = append(b.Scalars, schemaType.Name) + } + } + sort.Slice(b.Enums, func(i, j int) bool { return b.Enums[i].Name < b.Enums[j].Name }) + sort.Slice(b.Models, func(i, j int) bool { return b.Models[i].Name < b.Models[j].Name }) + sort.Slice(b.Interfaces, func(i, j int) bool { return b.Interfaces[i].Name < b.Interfaces[j].Name }) + + // if we are not just turning all struct-type fields in generated structs into pointers, we need to at least + // check for cyclical relationships and recursive structs + if !cfg.StructFieldsAlwaysPointers { + findAndHandleCyclicalRelationships(b) + } + + for _, it := range b.Enums { + cfg.Models.Add(it.Name, cfg.Model.ImportPath()+"."+templates.ToGo(it.Name)) + } + for _, it := range b.Models { + cfg.Models.Add(it.Name, cfg.Model.ImportPath()+"."+templates.ToGo(it.Name)) + } + for _, it := range b.Interfaces { + // On a given interface we want to keep a reference to all the models that implement it + for _, model := range b.Models { + for _, impl := range model.Implements { + if impl == it.Name { + // check if this isn't an implementation of an entity interface + if impl != "_Entity" { + // If this model has an implementation, add it to the Interface's Models + it.Models = append(it.Models, model) + } + } + } + } + cfg.Models.Add(it.Name, cfg.Model.ImportPath()+"."+templates.ToGo(it.Name)) + } + for _, it := range b.Scalars { + cfg.Models.Add(it, "github.com/niko0xdev/gqlgen/graphql.String") + } + + if len(b.Models) == 0 && len(b.Enums) == 0 && len(b.Interfaces) == 0 && len(b.Scalars) == 0 { + return nil + } + + if m.MutateHook != nil { + b = m.MutateHook(b) + } + + getInterfaceByName := func(name string) *Interface { + // Allow looking up interfaces, so template can generate getters for each field + for _, i := range b.Interfaces { + if i.Name == name { + return i + } + } + + return nil + } + gettersGenerated := make(map[string]map[string]struct{}) + generateGetter := func(model *Object, field *Field) string { + if model == nil || field == nil { + return "" + } + + // Let templates check if a given getter has been generated already + typeGetters, exists := gettersGenerated[model.Name] + if !exists { + typeGetters = make(map[string]struct{}) + gettersGenerated[model.Name] = typeGetters + } + + _, exists = typeGetters[field.GoName] + typeGetters[field.GoName] = struct{}{} + if exists { + return "" + } + + _, interfaceFieldTypeIsPointer := field.Type.(*types.Pointer) + var structFieldTypeIsPointer bool + for _, f := range model.Fields { + if f.GoName == field.GoName { + _, structFieldTypeIsPointer = f.Type.(*types.Pointer) + break + } + } + goType := templates.CurrentImports.LookupType(field.Type) + if strings.HasPrefix(goType, "[]") { + getter := fmt.Sprintf("func (this %s) Get%s() %s {\n", templates.ToGo(model.Name), field.GoName, goType) + getter += fmt.Sprintf("\tif this.%s == nil { return nil }\n", field.GoName) + getter += fmt.Sprintf("\tinterfaceSlice := make(%s, 0, len(this.%s))\n", goType, field.GoName) + getter += fmt.Sprintf("\tfor _, concrete := range this.%s { interfaceSlice = append(interfaceSlice, ", field.GoName) + if interfaceFieldTypeIsPointer && !structFieldTypeIsPointer { + getter += "&" + } else if !interfaceFieldTypeIsPointer && structFieldTypeIsPointer { + getter += "*" + } + getter += "concrete) }\n" + getter += "\treturn interfaceSlice\n" + getter += "}" + return getter + } else { + getter := fmt.Sprintf("func (this %s) Get%s() %s { return ", templates.ToGo(model.Name), field.GoName, goType) + + if interfaceFieldTypeIsPointer && !structFieldTypeIsPointer { + getter += "&" + } else if !interfaceFieldTypeIsPointer && structFieldTypeIsPointer { + getter += "*" + } + + getter += fmt.Sprintf("this.%s }", field.GoName) + return getter + } + } + funcMap := template.FuncMap{ + "getInterfaceByName": getInterfaceByName, + "generateGetter": generateGetter, + } + newModelTemplate := modelTemplate + if cfg.Model.ModelTemplate != "" { + newModelTemplate = readModelTemplate(cfg.Model.ModelTemplate) + } + + err := templates.Render(templates.Options{ + PackageName: cfg.Model.Package, + Filename: cfg.Model.Filename, + Data: b, + GeneratedHeader: true, + Packages: cfg.Packages, + Template: newModelTemplate, + Funcs: funcMap, + }) + if err != nil { + return err + } + + // We may have generated code in a package we already loaded, so we reload all packages + // to allow packages to be compared correctly + cfg.ReloadAllPackages() + + return nil +} + +func (m *Plugin) generateFields(cfg *config.Config, schemaType *ast.Definition) ([]*Field, error) { + binder := cfg.NewBinder() + fields := make([]*Field, 0) + + var omittableType types.Type + + for _, field := range schemaType.Fields { + var typ types.Type + fieldDef := cfg.Schema.Types[field.Type.Name()] + + if cfg.Models.UserDefined(field.Type.Name()) { + var err error + typ, err = binder.FindTypeFromName(cfg.Models[field.Type.Name()].Model[0]) + if err != nil { + return nil, err + } + } else { + switch fieldDef.Kind { + case ast.Scalar: + // no user defined model, referencing a default scalar + typ = types.NewNamed( + types.NewTypeName(0, cfg.Model.Pkg(), "string", nil), + nil, + nil, + ) + + case ast.Interface, ast.Union: + // no user defined model, referencing a generated interface type + typ = types.NewNamed( + types.NewTypeName(0, cfg.Model.Pkg(), templates.ToGo(field.Type.Name()), nil), + types.NewInterfaceType([]*types.Func{}, []types.Type{}), + nil, + ) + + case ast.Enum: + // no user defined model, must reference a generated enum + typ = types.NewNamed( + types.NewTypeName(0, cfg.Model.Pkg(), templates.ToGo(field.Type.Name()), nil), + nil, + nil, + ) + + case ast.Object, ast.InputObject: + // no user defined model, must reference a generated struct + typ = types.NewNamed( + types.NewTypeName(0, cfg.Model.Pkg(), templates.ToGo(field.Type.Name()), nil), + types.NewStruct(nil, nil), + nil, + ) + + default: + panic(fmt.Errorf("unknown ast type %s", fieldDef.Kind)) + } + } + + name := templates.ToGo(field.Name) + if nameOveride := cfg.Models[schemaType.Name].Fields[field.Name].FieldName; nameOveride != "" { + name = nameOveride + } + + typ = binder.CopyModifiersFromAst(field.Type, typ) + + if cfg.StructFieldsAlwaysPointers { + if isStruct(typ) && (fieldDef.Kind == ast.Object || fieldDef.Kind == ast.InputObject) { + typ = types.NewPointer(typ) + } + } + + f := &Field{ + Name: field.Name, + GoName: name, + Type: typ, + Description: field.Description, + Tag: getStructTagFromField(cfg, field), + Omittable: cfg.NullableInputOmittable && schemaType.Kind == ast.InputObject && !field.Type.NonNull, + } + + if m.FieldHook != nil { + mf, err := m.FieldHook(schemaType, field, f) + if err != nil { + return nil, fmt.Errorf("generror: field %v.%v: %w", schemaType.Name, field.Name, err) + } + f = mf + } + + if f.Omittable { + if schemaType.Kind != ast.InputObject || field.Type.NonNull { + return nil, fmt.Errorf("generror: field %v.%v: omittable is only applicable to nullable input fields", schemaType.Name, field.Name) + } + + var err error + + if omittableType == nil { + omittableType, err = binder.FindTypeFromName("github.com/niko0xdev/gqlgen/graphql.Omittable") + if err != nil { + return nil, err + } + } + + f.Type, err = binder.InstantiateType(omittableType, []types.Type{f.Type}) + if err != nil { + return nil, fmt.Errorf("generror: field %v.%v: %w", schemaType.Name, field.Name, err) + } + } + + fields = append(fields, f) + } + + // appending extra fields at the end of the fields list. + modelcfg := cfg.Models[schemaType.Name] + if len(modelcfg.ExtraFields) > 0 { + ff := make([]*Field, 0, len(modelcfg.ExtraFields)) + for fname, fspec := range modelcfg.ExtraFields { + ftype := buildType(fspec.Type) + + tag := `json:"-"` + if fspec.OverrideTags != "" { + tag = fspec.OverrideTags + } + + ff = append(ff, + &Field{ + Name: fname, + GoName: fname, + Type: ftype, + Description: fspec.Description, + Tag: tag, + }) + } + + sort.Slice(ff, func(i, j int) bool { + return ff[i].Name < ff[j].Name + }) + + fields = append(fields, ff...) + } + + return fields, nil +} + +func getStructTagFromField(cfg *config.Config, field *ast.FieldDefinition) string { + if !field.Type.NonNull && (cfg.EnableModelJsonOmitemptyTag == nil || *cfg.EnableModelJsonOmitemptyTag) { + return `json:"` + field.Name + `,omitempty"` + } + return `json:"` + field.Name + `"` +} + +// GoTagFieldHook prepends the goTag directive to the generated Field f. +// When applying the Tag to the field, the field +// name is used if no value argument is present. +func GoTagFieldHook(td *ast.Definition, fd *ast.FieldDefinition, f *Field) (*Field, error) { + args := make([]string, 0) + for _, goTag := range fd.Directives.ForNames("goTag") { + key := "" + value := fd.Name + + if arg := goTag.Arguments.ForName("key"); arg != nil { + if k, err := arg.Value.Value(nil); err == nil { + key = k.(string) + } + } + + if arg := goTag.Arguments.ForName("value"); arg != nil { + if v, err := arg.Value.Value(nil); err == nil { + value = v.(string) + } + } + + args = append(args, key+":\""+value+"\"") + } + + if len(args) > 0 { + f.Tag = removeDuplicateTags(f.Tag + " " + strings.Join(args, " ")) + } + + return f, nil +} + +// splitTagsBySpace split tags by space, except when space is inside quotes +func splitTagsBySpace(tagsString string) []string { + var tags []string + var currentTag string + inQuotes := false + + for _, c := range tagsString { + if c == '"' { + inQuotes = !inQuotes + } + if c == ' ' && !inQuotes { + tags = append(tags, currentTag) + currentTag = "" + } else { + currentTag += string(c) + } + } + tags = append(tags, currentTag) + + return tags +} + +// containsInvalidSpace checks if the tagsString contains invalid space +func containsInvalidSpace(valuesString string) bool { + // get rid of quotes + valuesString = strings.ReplaceAll(valuesString, "\"", "") + if strings.Contains(valuesString, ",") { + // split by comma, + values := strings.Split(valuesString, ",") + for _, value := range values { + if strings.TrimSpace(value) != value { + return true + } + } + return false + } + if strings.Contains(valuesString, ";") { + // split by semicolon, which is common in gorm + values := strings.Split(valuesString, ";") + for _, value := range values { + if strings.TrimSpace(value) != value { + return true + } + } + return false + } + // single value + if strings.TrimSpace(valuesString) != valuesString { + return true + } + return false +} + +func removeDuplicateTags(t string) string { + processed := make(map[string]bool) + tt := splitTagsBySpace(t) + returnTags := "" + + // iterate backwards through tags so appended goTag directives are prioritized + for i := len(tt) - 1; i >= 0; i-- { + ti := tt[i] + // check if ti contains ":", and not contains any empty space. if not, tag is in wrong format + // correct example: json:"name" + if !strings.Contains(ti, ":") { + panic(fmt.Errorf("wrong format of tags: %s. goTag directive should be in format: @goTag(key: \"something\", value:\"value\"), ", t)) + } + + kv := strings.Split(ti, ":") + if len(kv) == 0 || processed[kv[0]] { + continue + } + + key := kv[0] + value := strings.Join(kv[1:], ":") + processed[key] = true + if len(returnTags) > 0 { + returnTags = " " + returnTags + } + + isContained := containsInvalidSpace(value) + if isContained { + panic(fmt.Errorf("tag value should not contain any leading or trailing spaces: %s", value)) + } + + returnTags = key + ":" + value + returnTags + } + + return returnTags +} + +// GoFieldHook applies the goField directive to the generated Field f. +func GoFieldHook(td *ast.Definition, fd *ast.FieldDefinition, f *Field) (*Field, error) { + args := make([]string, 0) + _ = args + for _, goField := range fd.Directives.ForNames("goField") { + if arg := goField.Arguments.ForName("name"); arg != nil { + if k, err := arg.Value.Value(nil); err == nil { + f.GoName = k.(string) + } + } + + if arg := goField.Arguments.ForName("omittable"); arg != nil { + if k, err := arg.Value.Value(nil); err == nil { + f.Omittable = k.(bool) + } + } + } + return f, nil +} + +func isStruct(t types.Type) bool { + _, is := t.Underlying().(*types.Struct) + return is +} + +// findAndHandleCyclicalRelationships checks for cyclical relationships between generated structs and replaces them +// with pointers. These relationships will produce compilation errors if they are not pointers. +// Also handles recursive structs. +func findAndHandleCyclicalRelationships(b *ModelBuild) { + for ii, structA := range b.Models { + for _, fieldA := range structA.Fields { + if strings.Contains(fieldA.Type.String(), "NotCyclicalA") { + fmt.Print() + } + if !isStruct(fieldA.Type) { + continue + } + + // the field Type string will be in the form "github.com/niko0xdev/gqlgen/codegen/testserver/followschema.LoopA" + // we only want the part after the last dot: "LoopA" + // this could lead to false positives, as we are only checking the name of the struct type, but these + // should be extremely rare, if it is even possible at all. + fieldAStructNameParts := strings.Split(fieldA.Type.String(), ".") + fieldAStructName := fieldAStructNameParts[len(fieldAStructNameParts)-1] + + // find this struct type amongst the generated structs + for jj, structB := range b.Models { + if structB.Name != fieldAStructName { + continue + } + + // check if structB contains a cyclical reference back to structA + var cyclicalReferenceFound bool + for _, fieldB := range structB.Fields { + if !isStruct(fieldB.Type) { + continue + } + + fieldBStructNameParts := strings.Split(fieldB.Type.String(), ".") + fieldBStructName := fieldBStructNameParts[len(fieldBStructNameParts)-1] + if fieldBStructName == structA.Name { + cyclicalReferenceFound = true + fieldB.Type = types.NewPointer(fieldB.Type) + // keep looping in case this struct has additional fields of this type + } + } + + // if this is a recursive struct (i.e. structA == structB), ensure that we only change this field to a pointer once + if cyclicalReferenceFound && ii != jj { + fieldA.Type = types.NewPointer(fieldA.Type) + break + } + } + } + } +} + +func readModelTemplate(customModelTemplate string) string { + contentBytes, err := os.ReadFile(customModelTemplate) + if err != nil { + panic(err) + } + return string(contentBytes) +} diff --git a/plugin/modelgen/models.gotpl b/plugin/modelgen/models.gotpl new file mode 100644 index 0000000..112cf50 --- /dev/null +++ b/plugin/modelgen/models.gotpl @@ -0,0 +1,104 @@ +{{ reserveImport "context" }} +{{ reserveImport "fmt" }} +{{ reserveImport "io" }} +{{ reserveImport "strconv" }} +{{ reserveImport "time" }} +{{ reserveImport "sync" }} +{{ reserveImport "errors" }} +{{ reserveImport "bytes" }} + +{{ reserveImport "github.com/vektah/gqlparser/v2" }} +{{ reserveImport "github.com/vektah/gqlparser/v2/ast" }} +{{ reserveImport "github.com/niko0xdev/gqlgen/graphql" }} +{{ reserveImport "github.com/niko0xdev/gqlgen/graphql/introspection" }} + +{{- range $model := .Interfaces }} + {{ with .Description }} {{.|prefixLines "// "}} {{ end }} + type {{ goModelName .Name }} interface { + {{- if not .OmitCheck }} + {{- range $impl := .Implements }} + Is{{ goModelName $impl }}() + {{- end }} + Is{{ goModelName .Name }}() + {{- end }} + {{- range $field := .Fields }} + {{- with .Description }} + {{.|prefixLines "// "}} + {{- end}} + Get{{ $field.GoName }}() {{ $field.Type | ref }} + {{- end }} + } +{{- end }} + +{{ range $model := .Models }} + {{with .Description }} {{.|prefixLines "// "}} {{end}} + type {{ goModelName .Name }} struct { + {{- range $field := .Fields }} + {{- with .Description }} + {{.|prefixLines "// "}} + {{- end}} + {{ $field.GoName }} {{$field.Type | ref}} `{{$field.Tag}}` + {{- end }} + } + + {{ range .Implements }} + func ({{ goModelName $model.Name }}) Is{{ goModelName . }}() {} + {{- with getInterfaceByName . }} + {{- range .Fields }} + {{- with .Description }} + {{.|prefixLines "// "}} + {{- end}} + {{ generateGetter $model . }} + {{- end }} + {{- end }} + {{ end }} +{{- end}} + +{{ range $enum := .Enums }} + {{ with .Description }} {{.|prefixLines "// "}} {{end}} + type {{ goModelName .Name }} string + const ( + {{- range $value := .Values}} + {{- with .Description}} + {{.|prefixLines "// "}} + {{- end}} + {{ goModelName $enum.Name .Name }} {{ goModelName $enum.Name }} = {{ .Name|quote }} + {{- end }} + ) + + var All{{ goModelName .Name }} = []{{ goModelName .Name }}{ + {{- range $value := .Values}} + {{ goModelName $enum.Name .Name }}, + {{- end }} + } + + func (e {{ goModelName .Name }}) IsValid() bool { + switch e { + case {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ goModelName $enum.Name $element.Name }}{{end}}: + return true + } + return false + } + + func (e {{ goModelName .Name }}) String() string { + return string(e) + } + + func (e *{{ goModelName .Name }}) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = {{ goModelName .Name }}(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid {{ .Name }}", str) + } + return nil + } + + func (e {{ goModelName .Name }}) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) + } + +{{- end }} diff --git a/plugin/modelgen/models_test.go b/plugin/modelgen/models_test.go new file mode 100644 index 0000000..009d701 --- /dev/null +++ b/plugin/modelgen/models_test.go @@ -0,0 +1,684 @@ +package modelgen + +import ( + "errors" + "fmt" + "go/ast" + "go/parser" + "go/token" + "os" + "os/exec" + "path/filepath" + "reflect" + "sort" + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/niko0xdev/gqlgen/codegen/config" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/plugin/modelgen/internal/extrafields" + "github.com/niko0xdev/gqlgen/plugin/modelgen/out" + "github.com/niko0xdev/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_false" + "github.com/niko0xdev/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_nil" + "github.com/niko0xdev/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_true" + "github.com/niko0xdev/gqlgen/plugin/modelgen/out_nullable_input_omittable" + "github.com/niko0xdev/gqlgen/plugin/modelgen/out_struct_pointers" +) + +func TestModelGeneration(t *testing.T) { + cfg, err := config.LoadConfig("testdata/gqlgen.yml") + require.NoError(t, err) + require.NoError(t, cfg.Init()) + p := Plugin{ + MutateHook: mutateHook, + FieldHook: DefaultFieldMutateHook, + } + require.NoError(t, p.MutateConfig(cfg)) + require.NoError(t, goBuild(t, "./out/")) + + require.True(t, cfg.Models.UserDefined("MissingTypeNotNull")) + require.True(t, cfg.Models.UserDefined("MissingTypeNullable")) + require.True(t, cfg.Models.UserDefined("MissingEnum")) + require.True(t, cfg.Models.UserDefined("MissingUnion")) + require.True(t, cfg.Models.UserDefined("MissingInterface")) + require.True(t, cfg.Models.UserDefined("TypeWithDescription")) + require.True(t, cfg.Models.UserDefined("EnumWithDescription")) + require.True(t, cfg.Models.UserDefined("InterfaceWithDescription")) + require.True(t, cfg.Models.UserDefined("UnionWithDescription")) + require.True(t, cfg.Models.UserDefined("RenameFieldTest")) + require.True(t, cfg.Models.UserDefined("ExtraFieldsTest")) + + t.Run("no pointer pointers", func(t *testing.T) { + generated, err := os.ReadFile("./out/generated.go") + require.NoError(t, err) + require.NotContains(t, string(generated), "**") + }) + + t.Run("description is generated", func(t *testing.T) { + node, err := parser.ParseFile(token.NewFileSet(), "./out/generated.go", nil, parser.ParseComments) + require.NoError(t, err) + for _, commentGroup := range node.Comments { + text := commentGroup.Text() + words := strings.Split(text, " ") + require.True(t, len(words) > 1, "expected description %q to have more than one word", text) + } + }) + + t.Run("tags are applied", func(t *testing.T) { + file, err := os.ReadFile("./out/generated.go") + require.NoError(t, err) + + fileText := string(file) + + expectedTags := []string{ + `json:"missing2" database:"MissingTypeNotNullmissing2"`, + `json:"name,omitempty" database:"MissingInputname"`, + `json:"missing2,omitempty" database:"MissingTypeNullablemissing2"`, + `json:"name,omitempty" database:"TypeWithDescriptionname"`, + } + + for _, tag := range expectedTags { + require.True(t, strings.Contains(fileText, tag), "\nexpected:\n"+tag+"\ngot\n"+fileText) + } + }) + + t.Run("field hooks are applied", func(t *testing.T) { + file, err := os.ReadFile("./out/generated.go") + require.NoError(t, err) + + fileText := string(file) + + expectedTags := []string{ + `json:"name,omitempty" anotherTag:"tag"`, + `json:"enum,omitempty" yetAnotherTag:"12"`, + `json:"noVal,omitempty" yaml:"noVal" repeated:"true"`, + `json:"repeated,omitempty" someTag:"value" repeated:"true"`, + } + + for _, tag := range expectedTags { + require.True(t, strings.Contains(fileText, tag), "\nexpected:\n"+tag+"\ngot\n"+fileText) + } + }) + + t.Run("concrete types implement interface", func(t *testing.T) { + var _ out.FooBarer = out.FooBarr{} + }) + + t.Run("implemented interfaces", func(t *testing.T) { + pkg, err := parseAst("out") + require.NoError(t, err) + + path := filepath.Join("out", "generated.go") + generated := pkg.Files[path] + + type field struct { + typ string + name string + } + cases := []struct { + name string + wantFields []field + }{ + { + name: "A", + wantFields: []field{ + { + typ: "method", + name: "IsA", + }, + { + typ: "method", + name: "GetA", + }, + }, + }, + { + name: "B", + wantFields: []field{ + { + typ: "method", + name: "IsB", + }, + { + typ: "method", + name: "GetB", + }, + }, + }, + { + name: "C", + wantFields: []field{ + { + typ: "method", + name: "IsA", + }, + { + typ: "method", + name: "IsC", + }, + { + typ: "method", + name: "GetA", + }, + { + typ: "method", + name: "GetC", + }, + }, + }, + { + name: "D", + wantFields: []field{ + { + typ: "method", + name: "IsA", + }, + { + typ: "method", + name: "IsB", + }, + { + typ: "method", + name: "IsD", + }, + { + typ: "method", + name: "GetA", + }, + { + typ: "method", + name: "GetB", + }, + { + typ: "method", + name: "GetD", + }, + }, + }, + } + for _, tc := range cases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + typeSpec, ok := generated.Scope.Lookup(tc.name).Decl.(*ast.TypeSpec) + require.True(t, ok) + + fields := typeSpec.Type.(*ast.InterfaceType).Methods.List + for i, want := range tc.wantFields { + if want.typ == "ident" { + ident, ok := fields[i].Type.(*ast.Ident) + require.True(t, ok) + assert.Equal(t, want.name, ident.Name) + } + if want.typ == "method" { + require.GreaterOrEqual(t, 1, len(fields[i].Names)) + name := fields[i].Names[0].Name + assert.Equal(t, want.name, name) + } + } + }) + } + }) + + t.Run("implemented interfaces type CDImplemented", func(t *testing.T) { + pkg, err := parseAst("out") + require.NoError(t, err) + + path := filepath.Join("out", "generated.go") + generated := pkg.Files[path] + + wantMethods := []string{ + "IsA", + "IsB", + "IsC", + "IsD", + } + + gots := make([]string, 0, len(wantMethods)) + for _, decl := range generated.Decls { + if funcDecl, ok := decl.(*ast.FuncDecl); ok { + switch funcDecl.Name.Name { + case "IsA", "IsB", "IsC", "IsD": + gots = append(gots, funcDecl.Name.Name) + require.Len(t, funcDecl.Recv.List, 1) + recvIdent, ok := funcDecl.Recv.List[0].Type.(*ast.Ident) + require.True(t, ok) + require.Equal(t, "CDImplemented", recvIdent.Name) + } + } + } + + sort.Strings(gots) + require.Equal(t, wantMethods, gots) + }) + + t.Run("cyclical struct fields become pointers", func(t *testing.T) { + require.Nil(t, out.CyclicalA{}.FieldOne) + require.Nil(t, out.CyclicalA{}.FieldTwo) + require.Nil(t, out.CyclicalA{}.FieldThree) + require.NotNil(t, out.CyclicalA{}.FieldFour) + require.Nil(t, out.CyclicalB{}.FieldOne) + require.Nil(t, out.CyclicalB{}.FieldTwo) + require.Nil(t, out.CyclicalB{}.FieldThree) + require.Nil(t, out.CyclicalB{}.FieldFour) + require.NotNil(t, out.CyclicalB{}.FieldFive) + }) + + t.Run("non-cyclical struct fields become pointers", func(t *testing.T) { + require.NotNil(t, out.NotCyclicalB{}.FieldOne) + require.Nil(t, out.NotCyclicalB{}.FieldTwo) + }) + + t.Run("recursive struct fields become pointers", func(t *testing.T) { + require.Nil(t, out.Recursive{}.FieldOne) + require.Nil(t, out.Recursive{}.FieldTwo) + require.Nil(t, out.Recursive{}.FieldThree) + require.NotNil(t, out.Recursive{}.FieldFour) + }) + + t.Run("overridden struct field names use same capitalization as config", func(t *testing.T) { + require.NotNil(t, out.RenameFieldTest{}.GOODnaME) + }) + + t.Run("nullable input fields can be made omittable with goField", func(t *testing.T) { + require.IsType(t, out.MissingInput{}.NullString, graphql.Omittable[*string]{}) + require.IsType(t, out.MissingInput{}.NullEnum, graphql.Omittable[*out.MissingEnum]{}) + require.IsType(t, out.MissingInput{}.NullObject, graphql.Omittable[*out.ExistingInput]{}) + }) + + t.Run("extra fields are present", func(t *testing.T) { + var m out.ExtraFieldsTest + + require.IsType(t, m.FieldInt, int64(0)) + require.IsType(t, m.FieldInternalType, extrafields.Type{}) + require.IsType(t, m.FieldStringPtr, new(string)) + require.IsType(t, m.FieldIntSlice, []int64{}) + }) +} + +func TestModelGenerationOmitRootModels(t *testing.T) { + cfg, err := config.LoadConfig("testdata/gqlgen_omit_root_models.yml") + require.NoError(t, err) + require.NoError(t, cfg.Init()) + p := Plugin{ + MutateHook: mutateHook, + FieldHook: DefaultFieldMutateHook, + } + require.NoError(t, p.MutateConfig(cfg)) + require.NoError(t, goBuild(t, "./out/")) + generated, err := os.ReadFile("./out/generated_omit_root_models.go") + require.NoError(t, err) + require.NotContains(t, string(generated), "type Mutation struct") + require.NotContains(t, string(generated), "type Query struct") + require.NotContains(t, string(generated), "type Subscription struct") +} + +func TestModelGenerationStructFieldPointers(t *testing.T) { + cfg, err := config.LoadConfig("testdata/gqlgen_struct_field_pointers.yml") + require.NoError(t, err) + require.NoError(t, cfg.Init()) + p := Plugin{ + MutateHook: mutateHook, + FieldHook: DefaultFieldMutateHook, + } + require.NoError(t, p.MutateConfig(cfg)) + + t.Run("no pointer pointers", func(t *testing.T) { + generated, err := os.ReadFile("./out_struct_pointers/generated.go") + require.NoError(t, err) + require.NotContains(t, string(generated), "**") + }) + + t.Run("cyclical struct fields become pointers", func(t *testing.T) { + require.Nil(t, out_struct_pointers.CyclicalA{}.FieldOne) + require.Nil(t, out_struct_pointers.CyclicalA{}.FieldTwo) + require.Nil(t, out_struct_pointers.CyclicalA{}.FieldThree) + require.NotNil(t, out_struct_pointers.CyclicalA{}.FieldFour) + require.Nil(t, out_struct_pointers.CyclicalB{}.FieldOne) + require.Nil(t, out_struct_pointers.CyclicalB{}.FieldTwo) + require.Nil(t, out_struct_pointers.CyclicalB{}.FieldThree) + require.Nil(t, out_struct_pointers.CyclicalB{}.FieldFour) + require.NotNil(t, out_struct_pointers.CyclicalB{}.FieldFive) + }) + + t.Run("non-cyclical struct fields do not become pointers", func(t *testing.T) { + require.NotNil(t, out_struct_pointers.NotCyclicalB{}.FieldOne) + require.NotNil(t, out_struct_pointers.NotCyclicalB{}.FieldTwo) + }) + + t.Run("recursive struct fields become pointers", func(t *testing.T) { + require.Nil(t, out_struct_pointers.Recursive{}.FieldOne) + require.Nil(t, out_struct_pointers.Recursive{}.FieldTwo) + require.Nil(t, out_struct_pointers.Recursive{}.FieldThree) + require.NotNil(t, out_struct_pointers.Recursive{}.FieldFour) + }) + + t.Run("no getters", func(t *testing.T) { + generated, err := os.ReadFile("./out_struct_pointers/generated.go") + require.NoError(t, err) + require.NotContains(t, string(generated), "func (this") + }) +} + +func TestModelGenerationNullableInputOmittable(t *testing.T) { + cfg, err := config.LoadConfig("testdata/gqlgen_nullable_input_omittable.yml") + require.NoError(t, err) + require.NoError(t, cfg.Init()) + p := Plugin{ + MutateHook: mutateHook, + FieldHook: DefaultFieldMutateHook, + } + require.NoError(t, p.MutateConfig(cfg)) + + t.Run("nullable input fields are omittable", func(t *testing.T) { + require.IsType(t, out_nullable_input_omittable.MissingInput{}.Name, graphql.Omittable[*string]{}) + require.IsType(t, out_nullable_input_omittable.MissingInput{}.Enum, graphql.Omittable[*out_nullable_input_omittable.MissingEnum]{}) + require.IsType(t, out_nullable_input_omittable.MissingInput{}.NullString, graphql.Omittable[*string]{}) + require.IsType(t, out_nullable_input_omittable.MissingInput{}.NullEnum, graphql.Omittable[*out_nullable_input_omittable.MissingEnum]{}) + require.IsType(t, out_nullable_input_omittable.MissingInput{}.NullObject, graphql.Omittable[*out_nullable_input_omittable.ExistingInput]{}) + }) + + t.Run("non-nullable input fields are not omittable", func(t *testing.T) { + require.IsType(t, out_nullable_input_omittable.MissingInput{}.NonNullString, "") + }) +} + +func TestModelGenerationOmitemptyConfig(t *testing.T) { + suites := []struct { + n string + cfg string + enabled bool + t any + }{ + { + n: "nil", + cfg: "gqlgen_enable_model_json_omitempty_tag_nil.yml", + enabled: true, + t: out_enable_model_json_omitempty_tag_nil.OmitEmptyJSONTagTest{}, + }, + { + n: "true", + cfg: "gqlgen_enable_model_json_omitempty_tag_true.yml", + enabled: true, + t: out_enable_model_json_omitempty_tag_true.OmitEmptyJSONTagTest{}, + }, + { + n: "false", + cfg: "gqlgen_enable_model_json_omitempty_tag_false.yml", + enabled: false, + t: out_enable_model_json_omitempty_tag_false.OmitEmptyJSONTagTest{}, + }, + } + + for _, s := range suites { + t.Run(s.n, func(t *testing.T) { + cfg, err := config.LoadConfig(fmt.Sprintf("testdata/%s", s.cfg)) + require.NoError(t, err) + require.NoError(t, cfg.Init()) + p := Plugin{ + MutateHook: mutateHook, + FieldHook: DefaultFieldMutateHook, + } + require.NoError(t, p.MutateConfig(cfg)) + rt := reflect.TypeOf(s.t) + + // ensure non-nullable fields are never omitempty + sfn, ok := rt.FieldByName("ValueNonNil") + require.True(t, ok) + require.Equal(t, "ValueNonNil", sfn.Tag.Get("json")) + + // test nullable fields for configured omitempty + sf, ok := rt.FieldByName("Value") + require.True(t, ok) + + var expected string + if s.enabled { + expected = "Value,omitempty" + } else { + expected = "Value" + } + require.Equal(t, expected, sf.Tag.Get("json")) + }) + } +} + +func mutateHook(b *ModelBuild) *ModelBuild { + for _, model := range b.Models { + for _, field := range model.Fields { + field.Tag += ` database:"` + model.Name + field.Name + `"` + } + } + + return b +} + +func parseAst(path string) (*ast.Package, error) { + // test setup to parse the types + fset := token.NewFileSet() + pkgs, err := parser.ParseDir(fset, path, nil, parser.AllErrors) + if err != nil { + return nil, err + } + return pkgs["out"], nil +} + +func goBuild(t *testing.T, path string) error { + t.Helper() + cmd := exec.Command("go", "build", path) + out, err := cmd.CombinedOutput() + if err != nil { + return errors.New(string(out)) + } + + return nil +} + +func TestRemoveDuplicate(t *testing.T) { + type args struct { + t string + } + tests := []struct { + name string + args args + want string + wantPanic bool + }{ + { + name: "Duplicate Test with 1", + args: args{ + t: "json:\"name\"", + }, + want: "json:\"name\"", + }, + { + name: "Duplicate Test with 2", + args: args{ + t: "json:\"name\" json:\"name2\"", + }, + want: "json:\"name2\"", + }, + { + name: "Duplicate Test with 3", + args: args{ + t: "json:\"name\" json:\"name2\" json:\"name3\"", + }, + want: "json:\"name3\"", + }, + { + name: "Duplicate Test with 3 and 1 unrelated", + args: args{ + t: "json:\"name\" something:\"name2\" json:\"name3\"", + }, + want: "something:\"name2\" json:\"name3\"", + }, + { + name: "Duplicate Test with 3 and 2 unrelated", + args: args{ + t: "something:\"name1\" json:\"name\" something:\"name2\" json:\"name3\"", + }, + want: "something:\"name2\" json:\"name3\"", + }, + { + name: "Test tag value with leading empty space", + args: args{ + t: "json:\"name, name2\"", + }, + want: "json:\"name, name2\"", + wantPanic: true, + }, + { + name: "Test tag value with trailing empty space", + args: args{ + t: "json:\"name,name2 \"", + }, + want: "json:\"name,name2 \"", + wantPanic: true, + }, + { + name: "Test tag value with space in between", + args: args{ + t: "gorm:\"unique;not null\"", + }, + want: "gorm:\"unique;not null\"", + wantPanic: false, + }, + { + name: "Test mix use of gorm and json tags", + args: args{ + t: "gorm:\"unique;not null\" json:\"name,name2\"", + }, + want: "gorm:\"unique;not null\" json:\"name,name2\"", + wantPanic: false, + }, + { + name: "Test gorm tag with colon", + args: args{ + t: "gorm:\"type:varchar(63);unique_index\"", + }, + want: "gorm:\"type:varchar(63);unique_index\"", + wantPanic: false, + }, + { + name: "Test mix use of gorm and duplicate json tags with colon", + args: args{ + t: "json:\"name0\" gorm:\"type:varchar(63);unique_index\" json:\"name,name2\"", + }, + want: "gorm:\"type:varchar(63);unique_index\" json:\"name,name2\"", + wantPanic: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if tt.wantPanic { + assert.Panics(t, func() { removeDuplicateTags(tt.args.t) }, "The code did not panic") + } else { + if got := removeDuplicateTags(tt.args.t); got != tt.want { + t.Errorf("removeDuplicate() = %v, want %v", got, tt.want) + } + } + }) + } +} + +func Test_containsInvalidSpace(t *testing.T) { + type args struct { + valuesString string + } + tests := []struct { + name string + args args + want bool + }{ + { + name: "Test tag value with leading empty space", + args: args{ + valuesString: "name, name2", + }, + want: true, + }, + { + name: "Test tag value with trailing empty space", + args: args{ + valuesString: "name ,name2", + }, + want: true, + }, + { + name: "Test tag value with valid empty space in words", + args: args{ + valuesString: "accept this,name2", + }, + want: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + assert.Equalf(t, tt.want, containsInvalidSpace(tt.args.valuesString), "containsInvalidSpace(%v)", tt.args.valuesString) + }) + } +} + +func Test_splitTagsBySpace(t *testing.T) { + type args struct { + tagsString string + } + tests := []struct { + name string + args args + want []string + }{ + { + name: "multiple tags, single value", + args: args{ + tagsString: "json:\"name\" something:\"name2\" json:\"name3\"", + }, + want: []string{"json:\"name\"", "something:\"name2\"", "json:\"name3\""}, + }, + { + name: "multiple tag, multiple values", + args: args{ + tagsString: "json:\"name\" something:\"name2\" json:\"name3,name4\"", + }, + want: []string{"json:\"name\"", "something:\"name2\"", "json:\"name3,name4\""}, + }, + { + name: "single tag, single value", + args: args{ + tagsString: "json:\"name\"", + }, + want: []string{"json:\"name\""}, + }, + { + name: "single tag, multiple values", + args: args{ + tagsString: "json:\"name,name2\"", + }, + want: []string{"json:\"name,name2\""}, + }, + { + name: "space in value", + args: args{ + tagsString: "gorm:\"not nul,name2\"", + }, + want: []string{"gorm:\"not nul,name2\""}, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + assert.Equalf(t, tt.want, splitTagsBySpace(tt.args.tagsString), "splitTagsBySpace(%v)", tt.args.tagsString) + }) + } +} + +func TestCustomTemplate(t *testing.T) { + cfg, err := config.LoadConfig("testdata/gqlgen_custom_model_template.yml") + require.NoError(t, err) + require.NoError(t, cfg.Init()) + p := Plugin{ + MutateHook: mutateHook, + FieldHook: DefaultFieldMutateHook, + } + require.NoError(t, p.MutateConfig(cfg)) +} diff --git a/plugin/modelgen/out/existing.go b/plugin/modelgen/out/existing.go new file mode 100644 index 0000000..256d2d1 --- /dev/null +++ b/plugin/modelgen/out/existing.go @@ -0,0 +1,30 @@ +package out + +type ExistingType struct { + Name *string `json:"name"` + Enum *ExistingEnum `json:"enum"` + Int ExistingInterface `json:"int"` + Existing *MissingTypeNullable `json:"existing"` +} + +type ExistingModel struct { + Name string + Enum ExistingEnum + Int ExistingInterface +} + +type ExistingInput struct { + Name string + Enum ExistingEnum + Int ExistingInterface +} + +type ExistingEnum string + +type ExistingInterface interface { + IsExistingInterface() +} + +type ExistingUnion interface { + IsExistingUnion() +} diff --git a/plugin/modelgen/out/generated.go b/plugin/modelgen/out/generated.go new file mode 100644 index 0000000..0178211 --- /dev/null +++ b/plugin/modelgen/out/generated.go @@ -0,0 +1,327 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package out + +import ( + "fmt" + "io" + "strconv" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/plugin/modelgen/internal/extrafields" +) + +type A interface { + IsA() + GetA() string +} + +type ArrayOfA interface { + IsArrayOfA() + GetTrickyField() []A + GetTrickyFieldPointer() []A +} + +type B interface { + IsB() + GetB() int +} + +type C interface { + IsA() + IsC() + GetA() string + GetC() bool +} + +type D interface { + IsA() + IsB() + IsD() + GetA() string + GetB() int + GetD() *string +} + +type FooBarer interface { + IsFooBarer() + GetName() string +} + +// InterfaceWithDescription is an interface with a description +type InterfaceWithDescription interface { + IsInterfaceWithDescription() + GetName() *string +} + +type MissingInterface interface { + IsMissingInterface() + GetName() *string +} + +type MissingUnion interface { + IsMissingUnion() +} + +// UnionWithDescription is an union with a description +type UnionWithDescription interface { + IsUnionWithDescription() +} + +type X interface { + IsX() + GetId() string +} + +type CDImplemented struct { + A string `json:"a" database:"CDImplementeda"` + B int `json:"b" database:"CDImplementedb"` + C bool `json:"c" database:"CDImplementedc"` + D *string `json:"d,omitempty" database:"CDImplementedd"` +} + +func (CDImplemented) IsC() {} +func (this CDImplemented) GetA() string { return this.A } +func (this CDImplemented) GetC() bool { return this.C } + +func (CDImplemented) IsA() {} + +func (CDImplemented) IsD() {} + +func (this CDImplemented) GetB() int { return this.B } +func (this CDImplemented) GetD() *string { return this.D } + +func (CDImplemented) IsB() {} + +type CyclicalA struct { + FieldOne *CyclicalB `json:"field_one,omitempty" database:"CyclicalAfield_one"` + FieldTwo *CyclicalB `json:"field_two,omitempty" database:"CyclicalAfield_two"` + FieldThree *CyclicalB `json:"field_three,omitempty" database:"CyclicalAfield_three"` + FieldFour string `json:"field_four" database:"CyclicalAfield_four"` +} + +type CyclicalB struct { + FieldOne *CyclicalA `json:"field_one,omitempty" database:"CyclicalBfield_one"` + FieldTwo *CyclicalA `json:"field_two,omitempty" database:"CyclicalBfield_two"` + FieldThree *CyclicalA `json:"field_three,omitempty" database:"CyclicalBfield_three"` + FieldFour *CyclicalA `json:"field_four,omitempty" database:"CyclicalBfield_four"` + FieldFive string `json:"field_five" database:"CyclicalBfield_five"` +} + +type ExtraFieldsTest struct { + SchemaField string `json:"SchemaField" database:"ExtraFieldsTestSchemaField"` + FieldInt int64 `json:"field_int_tag" database:"ExtraFieldsTestFieldInt"` + FieldIntSlice []int64 `json:"-" database:"ExtraFieldsTestFieldIntSlice"` + // Internal field + FieldInternalType extrafields.Type `json:"-" database:"ExtraFieldsTestFieldInternalType"` + FieldStringPtr *string `json:"-" database:"ExtraFieldsTestFieldStringPtr"` +} + +type FieldMutationHook struct { + Name *string `json:"name,omitempty" anotherTag:"tag" database:"FieldMutationHookname"` + Enum *ExistingEnum `json:"enum,omitempty" yetAnotherTag:"12" database:"FieldMutationHookenum"` + NoVal *string `json:"noVal,omitempty" yaml:"noVal" repeated:"true" database:"FieldMutationHooknoVal"` + Repeated *string `json:"repeated,omitempty" someTag:"value" repeated:"true" database:"FieldMutationHookrepeated"` +} + +type ImplArrayOfA struct { + TrickyField []*CDImplemented `json:"trickyField" database:"ImplArrayOfAtrickyField"` + TrickyFieldPointer []*CDImplemented `json:"trickyFieldPointer,omitempty" database:"ImplArrayOfAtrickyFieldPointer"` +} + +func (ImplArrayOfA) IsArrayOfA() {} +func (this ImplArrayOfA) GetTrickyField() []A { + if this.TrickyField == nil { + return nil + } + interfaceSlice := make([]A, 0, len(this.TrickyField)) + for _, concrete := range this.TrickyField { + interfaceSlice = append(interfaceSlice, concrete) + } + return interfaceSlice +} +func (this ImplArrayOfA) GetTrickyFieldPointer() []A { + if this.TrickyFieldPointer == nil { + return nil + } + interfaceSlice := make([]A, 0, len(this.TrickyFieldPointer)) + for _, concrete := range this.TrickyFieldPointer { + interfaceSlice = append(interfaceSlice, concrete) + } + return interfaceSlice +} + +type MissingInput struct { + Name *string `json:"name,omitempty" database:"MissingInputname"` + Enum *MissingEnum `json:"enum,omitempty" database:"MissingInputenum"` + NonNullString string `json:"nonNullString" database:"MissingInputnonNullString"` + NullString graphql.Omittable[*string] `json:"nullString,omitempty" database:"MissingInputnullString"` + NullEnum graphql.Omittable[*MissingEnum] `json:"nullEnum,omitempty" database:"MissingInputnullEnum"` + NullObject graphql.Omittable[*ExistingInput] `json:"nullObject,omitempty" database:"MissingInputnullObject"` +} + +type MissingTypeNotNull struct { + Name string `json:"name" database:"MissingTypeNotNullname"` + Enum MissingEnum `json:"enum" database:"MissingTypeNotNullenum"` + Int MissingInterface `json:"int" database:"MissingTypeNotNullint"` + Existing *ExistingType `json:"existing" database:"MissingTypeNotNullexisting"` + Missing2 *MissingTypeNullable `json:"missing2" database:"MissingTypeNotNullmissing2"` +} + +func (MissingTypeNotNull) IsMissingInterface() {} +func (this MissingTypeNotNull) GetName() *string { return &this.Name } + +func (MissingTypeNotNull) IsExistingInterface() {} + +func (MissingTypeNotNull) IsMissingUnion() {} + +func (MissingTypeNotNull) IsExistingUnion() {} + +type MissingTypeNullable struct { + Name *string `json:"name,omitempty" database:"MissingTypeNullablename"` + Enum *MissingEnum `json:"enum,omitempty" database:"MissingTypeNullableenum"` + Int MissingInterface `json:"int,omitempty" database:"MissingTypeNullableint"` + Existing *ExistingType `json:"existing,omitempty" database:"MissingTypeNullableexisting"` + Missing2 *MissingTypeNotNull `json:"missing2,omitempty" database:"MissingTypeNullablemissing2"` +} + +func (MissingTypeNullable) IsMissingInterface() {} +func (this MissingTypeNullable) GetName() *string { return this.Name } + +func (MissingTypeNullable) IsExistingInterface() {} + +func (MissingTypeNullable) IsMissingUnion() {} + +func (MissingTypeNullable) IsExistingUnion() {} + +type NotCyclicalA struct { + FieldOne string `json:"FieldOne" database:"NotCyclicalAFieldOne"` + FieldTwo int `json:"FieldTwo" database:"NotCyclicalAFieldTwo"` +} + +type NotCyclicalB struct { + FieldOne string `json:"FieldOne" database:"NotCyclicalBFieldOne"` + FieldTwo *NotCyclicalA `json:"FieldTwo" database:"NotCyclicalBFieldTwo"` +} + +type OmitEmptyJSONTagTest struct { + ValueNonNil string `json:"ValueNonNil" database:"OmitEmptyJsonTagTestValueNonNil"` + Value *string `json:"Value,omitempty" database:"OmitEmptyJsonTagTestValue"` +} + +type Recursive struct { + FieldOne *Recursive `json:"FieldOne" database:"RecursiveFieldOne"` + FieldTwo *Recursive `json:"FieldTwo" database:"RecursiveFieldTwo"` + FieldThree *Recursive `json:"FieldThree" database:"RecursiveFieldThree"` + FieldFour string `json:"FieldFour" database:"RecursiveFieldFour"` +} + +type RenameFieldTest struct { + GOODnaME string `json:"badName" database:"RenameFieldTestbadName"` + OtherField string `json:"otherField" database:"RenameFieldTestotherField"` +} + +// TypeWithDescription is a type with a description +type TypeWithDescription struct { + Name *string `json:"name,omitempty" database:"TypeWithDescriptionname"` +} + +func (TypeWithDescription) IsUnionWithDescription() {} + +type Xer struct { + Id string `json:"Id" database:"XerId"` + Name string `json:"Name" database:"XerName"` +} + +func (Xer) IsX() {} +func (this Xer) GetId() string { return this.Id } + +type FooBarr struct { + Name string `json:"name" database:"_Foo_Barrname"` +} + +func (FooBarr) IsFooBarer() {} +func (this FooBarr) GetName() string { return this.Name } + +// EnumWithDescription is an enum with a description +type EnumWithDescription string + +const ( + EnumWithDescriptionCat EnumWithDescription = "CAT" + EnumWithDescriptionDog EnumWithDescription = "DOG" +) + +var AllEnumWithDescription = []EnumWithDescription{ + EnumWithDescriptionCat, + EnumWithDescriptionDog, +} + +func (e EnumWithDescription) IsValid() bool { + switch e { + case EnumWithDescriptionCat, EnumWithDescriptionDog: + return true + } + return false +} + +func (e EnumWithDescription) String() string { + return string(e) +} + +func (e *EnumWithDescription) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = EnumWithDescription(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid EnumWithDescription", str) + } + return nil +} + +func (e EnumWithDescription) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +type MissingEnum string + +const ( + MissingEnumHello MissingEnum = "Hello" + MissingEnumGoodbye MissingEnum = "Goodbye" +) + +var AllMissingEnum = []MissingEnum{ + MissingEnumHello, + MissingEnumGoodbye, +} + +func (e MissingEnum) IsValid() bool { + switch e { + case MissingEnumHello, MissingEnumGoodbye: + return true + } + return false +} + +func (e MissingEnum) String() string { + return string(e) +} + +func (e *MissingEnum) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = MissingEnum(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid MissingEnum", str) + } + return nil +} + +func (e MissingEnum) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} diff --git a/plugin/modelgen/out/generated_omit_root_models.go b/plugin/modelgen/out/generated_omit_root_models.go new file mode 100644 index 0000000..ce1731e --- /dev/null +++ b/plugin/modelgen/out/generated_omit_root_models.go @@ -0,0 +1,54 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package out + +import ( + "fmt" + "io" + "strconv" +) + +type SomeContent string + +const ( + SomeContentThis SomeContent = "This" + SomeContentIs SomeContent = "Is" + SomeContentA SomeContent = "A" + SomeContentTest SomeContent = "Test" +) + +var AllSomeContent = []SomeContent{ + SomeContentThis, + SomeContentIs, + SomeContentA, + SomeContentTest, +} + +func (e SomeContent) IsValid() bool { + switch e { + case SomeContentThis, SomeContentIs, SomeContentA, SomeContentTest: + return true + } + return false +} + +func (e SomeContent) String() string { + return string(e) +} + +func (e *SomeContent) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = SomeContent(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid SomeContent", str) + } + return nil +} + +func (e SomeContent) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} diff --git a/plugin/modelgen/out_enable_model_json_omitempty_tag_false/existing.go b/plugin/modelgen/out_enable_model_json_omitempty_tag_false/existing.go new file mode 100644 index 0000000..2258f16 --- /dev/null +++ b/plugin/modelgen/out_enable_model_json_omitempty_tag_false/existing.go @@ -0,0 +1,30 @@ +package out_enable_model_json_omitempty_tag_false + +type ExistingType struct { + Name *string `json:"name"` + Enum *ExistingEnum `json:"enum"` + Int ExistingInterface `json:"int"` + Existing *MissingTypeNullable `json:"existing"` +} + +type ExistingModel struct { + Name string + Enum ExistingEnum + Int ExistingInterface +} + +type ExistingInput struct { + Name string + Enum ExistingEnum + Int ExistingInterface +} + +type ExistingEnum string + +type ExistingInterface interface { + IsExistingInterface() +} + +type ExistingUnion interface { + IsExistingUnion() +} diff --git a/plugin/modelgen/out_enable_model_json_omitempty_tag_false/generated.go b/plugin/modelgen/out_enable_model_json_omitempty_tag_false/generated.go new file mode 100644 index 0000000..a9780f6 --- /dev/null +++ b/plugin/modelgen/out_enable_model_json_omitempty_tag_false/generated.go @@ -0,0 +1,331 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package out_enable_model_json_omitempty_tag_false + +import ( + "fmt" + "io" + "strconv" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/plugin/modelgen/out" +) + +type A interface { + IsA() + GetA() string +} + +type ArrayOfA interface { + IsArrayOfA() + GetTrickyField() []A + GetTrickyFieldPointer() []A +} + +type B interface { + IsB() + GetB() int +} + +type C interface { + IsA() + IsC() + GetA() string + GetC() bool +} + +type D interface { + IsA() + IsB() + IsD() + GetA() string + GetB() int + GetD() *string +} + +type FooBarer interface { + IsFooBarer() + GetName() string +} + +// InterfaceWithDescription is an interface with a description +type InterfaceWithDescription interface { + IsInterfaceWithDescription() + GetName() *string +} + +type MissingInterface interface { + IsMissingInterface() + GetName() *string +} + +type MissingUnion interface { + IsMissingUnion() +} + +// UnionWithDescription is an union with a description +type UnionWithDescription interface { + IsUnionWithDescription() +} + +type X interface { + IsX() + GetId() string +} + +type CDImplemented struct { + A string `json:"a" database:"CDImplementeda"` + B int `json:"b" database:"CDImplementedb"` + C bool `json:"c" database:"CDImplementedc"` + D *string `json:"d" database:"CDImplementedd"` +} + +func (CDImplemented) IsC() {} +func (this CDImplemented) GetA() string { return this.A } +func (this CDImplemented) GetC() bool { return this.C } + +func (CDImplemented) IsA() {} + +func (CDImplemented) IsD() {} + +func (this CDImplemented) GetB() int { return this.B } +func (this CDImplemented) GetD() *string { return this.D } + +func (CDImplemented) IsB() {} + +type CyclicalA struct { + FieldOne *CyclicalB `json:"field_one" database:"CyclicalAfield_one"` + FieldTwo *CyclicalB `json:"field_two" database:"CyclicalAfield_two"` + FieldThree *CyclicalB `json:"field_three" database:"CyclicalAfield_three"` + FieldFour string `json:"field_four" database:"CyclicalAfield_four"` +} + +type CyclicalB struct { + FieldOne *CyclicalA `json:"field_one" database:"CyclicalBfield_one"` + FieldTwo *CyclicalA `json:"field_two" database:"CyclicalBfield_two"` + FieldThree *CyclicalA `json:"field_three" database:"CyclicalBfield_three"` + FieldFour *CyclicalA `json:"field_four" database:"CyclicalBfield_four"` + FieldFive string `json:"field_five" database:"CyclicalBfield_five"` +} + +type ExtraFieldsTest struct { + SchemaField string `json:"SchemaField" database:"ExtraFieldsTestSchemaField"` +} + +type FieldMutationHook struct { + Name *string `json:"name" anotherTag:"tag" database:"FieldMutationHookname"` + Enum *out.ExistingEnum `json:"enum" yetAnotherTag:"12" database:"FieldMutationHookenum"` + NoVal *string `json:"noVal" yaml:"noVal" repeated:"true" database:"FieldMutationHooknoVal"` + Repeated *string `json:"repeated" someTag:"value" repeated:"true" database:"FieldMutationHookrepeated"` +} + +type ImplArrayOfA struct { + TrickyField []*CDImplemented `json:"trickyField" database:"ImplArrayOfAtrickyField"` + TrickyFieldPointer []*CDImplemented `json:"trickyFieldPointer" database:"ImplArrayOfAtrickyFieldPointer"` +} + +func (ImplArrayOfA) IsArrayOfA() {} +func (this ImplArrayOfA) GetTrickyField() []A { + if this.TrickyField == nil { + return nil + } + interfaceSlice := make([]A, 0, len(this.TrickyField)) + for _, concrete := range this.TrickyField { + interfaceSlice = append(interfaceSlice, concrete) + } + return interfaceSlice +} +func (this ImplArrayOfA) GetTrickyFieldPointer() []A { + if this.TrickyFieldPointer == nil { + return nil + } + interfaceSlice := make([]A, 0, len(this.TrickyFieldPointer)) + for _, concrete := range this.TrickyFieldPointer { + interfaceSlice = append(interfaceSlice, concrete) + } + return interfaceSlice +} + +type MissingInput struct { + Name *string `json:"name" database:"MissingInputname"` + Enum *MissingEnum `json:"enum" database:"MissingInputenum"` + NonNullString string `json:"nonNullString" database:"MissingInputnonNullString"` + NullString graphql.Omittable[*string] `json:"nullString" database:"MissingInputnullString"` + NullEnum graphql.Omittable[*MissingEnum] `json:"nullEnum" database:"MissingInputnullEnum"` + NullObject graphql.Omittable[*out.ExistingInput] `json:"nullObject" database:"MissingInputnullObject"` +} + +type MissingTypeNotNull struct { + Name string `json:"name" database:"MissingTypeNotNullname"` + Enum MissingEnum `json:"enum" database:"MissingTypeNotNullenum"` + Int MissingInterface `json:"int" database:"MissingTypeNotNullint"` + Existing *out.ExistingType `json:"existing" database:"MissingTypeNotNullexisting"` + Missing2 *MissingTypeNullable `json:"missing2" database:"MissingTypeNotNullmissing2"` +} + +func (MissingTypeNotNull) IsMissingInterface() {} +func (this MissingTypeNotNull) GetName() *string { return &this.Name } + +func (MissingTypeNotNull) IsExistingInterface() {} + +func (MissingTypeNotNull) IsMissingUnion() {} + +func (MissingTypeNotNull) IsExistingUnion() {} + +type MissingTypeNullable struct { + Name *string `json:"name" database:"MissingTypeNullablename"` + Enum *MissingEnum `json:"enum" database:"MissingTypeNullableenum"` + Int MissingInterface `json:"int" database:"MissingTypeNullableint"` + Existing *out.ExistingType `json:"existing" database:"MissingTypeNullableexisting"` + Missing2 *MissingTypeNotNull `json:"missing2" database:"MissingTypeNullablemissing2"` +} + +func (MissingTypeNullable) IsMissingInterface() {} +func (this MissingTypeNullable) GetName() *string { return this.Name } + +func (MissingTypeNullable) IsExistingInterface() {} + +func (MissingTypeNullable) IsMissingUnion() {} + +func (MissingTypeNullable) IsExistingUnion() {} + +type Mutation struct { +} + +type NotCyclicalA struct { + FieldOne string `json:"FieldOne" database:"NotCyclicalAFieldOne"` + FieldTwo int `json:"FieldTwo" database:"NotCyclicalAFieldTwo"` +} + +type NotCyclicalB struct { + FieldOne string `json:"FieldOne" database:"NotCyclicalBFieldOne"` + FieldTwo *NotCyclicalA `json:"FieldTwo" database:"NotCyclicalBFieldTwo"` +} + +type OmitEmptyJSONTagTest struct { + ValueNonNil string `json:"ValueNonNil" database:"OmitEmptyJsonTagTestValueNonNil"` + Value *string `json:"Value" database:"OmitEmptyJsonTagTestValue"` +} + +type Query struct { +} + +type Recursive struct { + FieldOne *Recursive `json:"FieldOne" database:"RecursiveFieldOne"` + FieldTwo *Recursive `json:"FieldTwo" database:"RecursiveFieldTwo"` + FieldThree *Recursive `json:"FieldThree" database:"RecursiveFieldThree"` + FieldFour string `json:"FieldFour" database:"RecursiveFieldFour"` +} + +type RenameFieldTest struct { + BadName string `json:"badName" database:"RenameFieldTestbadName"` + OtherField string `json:"otherField" database:"RenameFieldTestotherField"` +} + +type Subscription struct { +} + +// TypeWithDescription is a type with a description +type TypeWithDescription struct { + Name *string `json:"name" database:"TypeWithDescriptionname"` +} + +func (TypeWithDescription) IsUnionWithDescription() {} + +type Xer struct { + Id string `json:"Id" database:"XerId"` + Name string `json:"Name" database:"XerName"` +} + +func (Xer) IsX() {} +func (this Xer) GetId() string { return this.Id } + +type FooBarr struct { + Name string `json:"name" database:"_Foo_Barrname"` +} + +func (FooBarr) IsFooBarer() {} +func (this FooBarr) GetName() string { return this.Name } + +// EnumWithDescription is an enum with a description +type EnumWithDescription string + +const ( + EnumWithDescriptionCat EnumWithDescription = "CAT" + EnumWithDescriptionDog EnumWithDescription = "DOG" +) + +var AllEnumWithDescription = []EnumWithDescription{ + EnumWithDescriptionCat, + EnumWithDescriptionDog, +} + +func (e EnumWithDescription) IsValid() bool { + switch e { + case EnumWithDescriptionCat, EnumWithDescriptionDog: + return true + } + return false +} + +func (e EnumWithDescription) String() string { + return string(e) +} + +func (e *EnumWithDescription) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = EnumWithDescription(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid EnumWithDescription", str) + } + return nil +} + +func (e EnumWithDescription) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +type MissingEnum string + +const ( + MissingEnumHello MissingEnum = "Hello" + MissingEnumGoodbye MissingEnum = "Goodbye" +) + +var AllMissingEnum = []MissingEnum{ + MissingEnumHello, + MissingEnumGoodbye, +} + +func (e MissingEnum) IsValid() bool { + switch e { + case MissingEnumHello, MissingEnumGoodbye: + return true + } + return false +} + +func (e MissingEnum) String() string { + return string(e) +} + +func (e *MissingEnum) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = MissingEnum(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid MissingEnum", str) + } + return nil +} + +func (e MissingEnum) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} diff --git a/plugin/modelgen/out_enable_model_json_omitempty_tag_nil/existing.go b/plugin/modelgen/out_enable_model_json_omitempty_tag_nil/existing.go new file mode 100644 index 0000000..5555ebc --- /dev/null +++ b/plugin/modelgen/out_enable_model_json_omitempty_tag_nil/existing.go @@ -0,0 +1,30 @@ +package out_enable_model_json_omitempty_tag_nil + +type ExistingType struct { + Name *string `json:"name"` + Enum *ExistingEnum `json:"enum"` + Int ExistingInterface `json:"int"` + Existing *MissingTypeNullable `json:"existing"` +} + +type ExistingModel struct { + Name string + Enum ExistingEnum + Int ExistingInterface +} + +type ExistingInput struct { + Name string + Enum ExistingEnum + Int ExistingInterface +} + +type ExistingEnum string + +type ExistingInterface interface { + IsExistingInterface() +} + +type ExistingUnion interface { + IsExistingUnion() +} diff --git a/plugin/modelgen/out_enable_model_json_omitempty_tag_nil/generated.go b/plugin/modelgen/out_enable_model_json_omitempty_tag_nil/generated.go new file mode 100644 index 0000000..6da656c --- /dev/null +++ b/plugin/modelgen/out_enable_model_json_omitempty_tag_nil/generated.go @@ -0,0 +1,330 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package out_enable_model_json_omitempty_tag_nil + +import ( + "fmt" + "io" + "strconv" + + "github.com/niko0xdev/gqlgen/graphql" +) + +type A interface { + IsA() + GetA() string +} + +type ArrayOfA interface { + IsArrayOfA() + GetTrickyField() []A + GetTrickyFieldPointer() []A +} + +type B interface { + IsB() + GetB() int +} + +type C interface { + IsA() + IsC() + GetA() string + GetC() bool +} + +type D interface { + IsA() + IsB() + IsD() + GetA() string + GetB() int + GetD() *string +} + +type FooBarer interface { + IsFooBarer() + GetName() string +} + +// InterfaceWithDescription is an interface with a description +type InterfaceWithDescription interface { + IsInterfaceWithDescription() + GetName() *string +} + +type MissingInterface interface { + IsMissingInterface() + GetName() *string +} + +type MissingUnion interface { + IsMissingUnion() +} + +// UnionWithDescription is an union with a description +type UnionWithDescription interface { + IsUnionWithDescription() +} + +type X interface { + IsX() + GetId() string +} + +type CDImplemented struct { + A string `json:"a" database:"CDImplementeda"` + B int `json:"b" database:"CDImplementedb"` + C bool `json:"c" database:"CDImplementedc"` + D *string `json:"d,omitempty" database:"CDImplementedd"` +} + +func (CDImplemented) IsC() {} +func (this CDImplemented) GetA() string { return this.A } +func (this CDImplemented) GetC() bool { return this.C } + +func (CDImplemented) IsA() {} + +func (CDImplemented) IsD() {} + +func (this CDImplemented) GetB() int { return this.B } +func (this CDImplemented) GetD() *string { return this.D } + +func (CDImplemented) IsB() {} + +type CyclicalA struct { + FieldOne *CyclicalB `json:"field_one,omitempty" database:"CyclicalAfield_one"` + FieldTwo *CyclicalB `json:"field_two,omitempty" database:"CyclicalAfield_two"` + FieldThree *CyclicalB `json:"field_three,omitempty" database:"CyclicalAfield_three"` + FieldFour string `json:"field_four" database:"CyclicalAfield_four"` +} + +type CyclicalB struct { + FieldOne *CyclicalA `json:"field_one,omitempty" database:"CyclicalBfield_one"` + FieldTwo *CyclicalA `json:"field_two,omitempty" database:"CyclicalBfield_two"` + FieldThree *CyclicalA `json:"field_three,omitempty" database:"CyclicalBfield_three"` + FieldFour *CyclicalA `json:"field_four,omitempty" database:"CyclicalBfield_four"` + FieldFive string `json:"field_five" database:"CyclicalBfield_five"` +} + +type ExtraFieldsTest struct { + SchemaField string `json:"SchemaField" database:"ExtraFieldsTestSchemaField"` +} + +type FieldMutationHook struct { + Name *string `json:"name,omitempty" anotherTag:"tag" database:"FieldMutationHookname"` + Enum *ExistingEnum `json:"enum,omitempty" yetAnotherTag:"12" database:"FieldMutationHookenum"` + NoVal *string `json:"noVal,omitempty" yaml:"noVal" repeated:"true" database:"FieldMutationHooknoVal"` + Repeated *string `json:"repeated,omitempty" someTag:"value" repeated:"true" database:"FieldMutationHookrepeated"` +} + +type ImplArrayOfA struct { + TrickyField []*CDImplemented `json:"trickyField" database:"ImplArrayOfAtrickyField"` + TrickyFieldPointer []*CDImplemented `json:"trickyFieldPointer,omitempty" database:"ImplArrayOfAtrickyFieldPointer"` +} + +func (ImplArrayOfA) IsArrayOfA() {} +func (this ImplArrayOfA) GetTrickyField() []A { + if this.TrickyField == nil { + return nil + } + interfaceSlice := make([]A, 0, len(this.TrickyField)) + for _, concrete := range this.TrickyField { + interfaceSlice = append(interfaceSlice, concrete) + } + return interfaceSlice +} +func (this ImplArrayOfA) GetTrickyFieldPointer() []A { + if this.TrickyFieldPointer == nil { + return nil + } + interfaceSlice := make([]A, 0, len(this.TrickyFieldPointer)) + for _, concrete := range this.TrickyFieldPointer { + interfaceSlice = append(interfaceSlice, concrete) + } + return interfaceSlice +} + +type MissingInput struct { + Name *string `json:"name,omitempty" database:"MissingInputname"` + Enum *MissingEnum `json:"enum,omitempty" database:"MissingInputenum"` + NonNullString string `json:"nonNullString" database:"MissingInputnonNullString"` + NullString graphql.Omittable[*string] `json:"nullString,omitempty" database:"MissingInputnullString"` + NullEnum graphql.Omittable[*MissingEnum] `json:"nullEnum,omitempty" database:"MissingInputnullEnum"` + NullObject graphql.Omittable[*ExistingInput] `json:"nullObject,omitempty" database:"MissingInputnullObject"` +} + +type MissingTypeNotNull struct { + Name string `json:"name" database:"MissingTypeNotNullname"` + Enum MissingEnum `json:"enum" database:"MissingTypeNotNullenum"` + Int MissingInterface `json:"int" database:"MissingTypeNotNullint"` + Existing *ExistingType `json:"existing" database:"MissingTypeNotNullexisting"` + Missing2 *MissingTypeNullable `json:"missing2" database:"MissingTypeNotNullmissing2"` +} + +func (MissingTypeNotNull) IsMissingInterface() {} +func (this MissingTypeNotNull) GetName() *string { return &this.Name } + +func (MissingTypeNotNull) IsExistingInterface() {} + +func (MissingTypeNotNull) IsMissingUnion() {} + +func (MissingTypeNotNull) IsExistingUnion() {} + +type MissingTypeNullable struct { + Name *string `json:"name,omitempty" database:"MissingTypeNullablename"` + Enum *MissingEnum `json:"enum,omitempty" database:"MissingTypeNullableenum"` + Int MissingInterface `json:"int,omitempty" database:"MissingTypeNullableint"` + Existing *ExistingType `json:"existing,omitempty" database:"MissingTypeNullableexisting"` + Missing2 *MissingTypeNotNull `json:"missing2,omitempty" database:"MissingTypeNullablemissing2"` +} + +func (MissingTypeNullable) IsMissingInterface() {} +func (this MissingTypeNullable) GetName() *string { return this.Name } + +func (MissingTypeNullable) IsExistingInterface() {} + +func (MissingTypeNullable) IsMissingUnion() {} + +func (MissingTypeNullable) IsExistingUnion() {} + +type Mutation struct { +} + +type NotCyclicalA struct { + FieldOne string `json:"FieldOne" database:"NotCyclicalAFieldOne"` + FieldTwo int `json:"FieldTwo" database:"NotCyclicalAFieldTwo"` +} + +type NotCyclicalB struct { + FieldOne string `json:"FieldOne" database:"NotCyclicalBFieldOne"` + FieldTwo *NotCyclicalA `json:"FieldTwo" database:"NotCyclicalBFieldTwo"` +} + +type OmitEmptyJSONTagTest struct { + ValueNonNil string `json:"ValueNonNil" database:"OmitEmptyJsonTagTestValueNonNil"` + Value *string `json:"Value,omitempty" database:"OmitEmptyJsonTagTestValue"` +} + +type Query struct { +} + +type Recursive struct { + FieldOne *Recursive `json:"FieldOne" database:"RecursiveFieldOne"` + FieldTwo *Recursive `json:"FieldTwo" database:"RecursiveFieldTwo"` + FieldThree *Recursive `json:"FieldThree" database:"RecursiveFieldThree"` + FieldFour string `json:"FieldFour" database:"RecursiveFieldFour"` +} + +type RenameFieldTest struct { + BadName string `json:"badName" database:"RenameFieldTestbadName"` + OtherField string `json:"otherField" database:"RenameFieldTestotherField"` +} + +type Subscription struct { +} + +// TypeWithDescription is a type with a description +type TypeWithDescription struct { + Name *string `json:"name,omitempty" database:"TypeWithDescriptionname"` +} + +func (TypeWithDescription) IsUnionWithDescription() {} + +type Xer struct { + Id string `json:"Id" database:"XerId"` + Name string `json:"Name" database:"XerName"` +} + +func (Xer) IsX() {} +func (this Xer) GetId() string { return this.Id } + +type FooBarr struct { + Name string `json:"name" database:"_Foo_Barrname"` +} + +func (FooBarr) IsFooBarer() {} +func (this FooBarr) GetName() string { return this.Name } + +// EnumWithDescription is an enum with a description +type EnumWithDescription string + +const ( + EnumWithDescriptionCat EnumWithDescription = "CAT" + EnumWithDescriptionDog EnumWithDescription = "DOG" +) + +var AllEnumWithDescription = []EnumWithDescription{ + EnumWithDescriptionCat, + EnumWithDescriptionDog, +} + +func (e EnumWithDescription) IsValid() bool { + switch e { + case EnumWithDescriptionCat, EnumWithDescriptionDog: + return true + } + return false +} + +func (e EnumWithDescription) String() string { + return string(e) +} + +func (e *EnumWithDescription) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = EnumWithDescription(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid EnumWithDescription", str) + } + return nil +} + +func (e EnumWithDescription) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +type MissingEnum string + +const ( + MissingEnumHello MissingEnum = "Hello" + MissingEnumGoodbye MissingEnum = "Goodbye" +) + +var AllMissingEnum = []MissingEnum{ + MissingEnumHello, + MissingEnumGoodbye, +} + +func (e MissingEnum) IsValid() bool { + switch e { + case MissingEnumHello, MissingEnumGoodbye: + return true + } + return false +} + +func (e MissingEnum) String() string { + return string(e) +} + +func (e *MissingEnum) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = MissingEnum(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid MissingEnum", str) + } + return nil +} + +func (e MissingEnum) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} diff --git a/plugin/modelgen/out_enable_model_json_omitempty_tag_true/existing.go b/plugin/modelgen/out_enable_model_json_omitempty_tag_true/existing.go new file mode 100644 index 0000000..ded0482 --- /dev/null +++ b/plugin/modelgen/out_enable_model_json_omitempty_tag_true/existing.go @@ -0,0 +1,30 @@ +package out_enable_model_json_omitempty_tag_true + +type ExistingType struct { + Name *string `json:"name"` + Enum *ExistingEnum `json:"enum"` + Int ExistingInterface `json:"int"` + Existing *MissingTypeNullable `json:"existing"` +} + +type ExistingModel struct { + Name string + Enum ExistingEnum + Int ExistingInterface +} + +type ExistingInput struct { + Name string + Enum ExistingEnum + Int ExistingInterface +} + +type ExistingEnum string + +type ExistingInterface interface { + IsExistingInterface() +} + +type ExistingUnion interface { + IsExistingUnion() +} diff --git a/plugin/modelgen/out_enable_model_json_omitempty_tag_true/generated.go b/plugin/modelgen/out_enable_model_json_omitempty_tag_true/generated.go new file mode 100644 index 0000000..7efb81a --- /dev/null +++ b/plugin/modelgen/out_enable_model_json_omitempty_tag_true/generated.go @@ -0,0 +1,331 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package out_enable_model_json_omitempty_tag_true + +import ( + "fmt" + "io" + "strconv" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/plugin/modelgen/out" +) + +type A interface { + IsA() + GetA() string +} + +type ArrayOfA interface { + IsArrayOfA() + GetTrickyField() []A + GetTrickyFieldPointer() []A +} + +type B interface { + IsB() + GetB() int +} + +type C interface { + IsA() + IsC() + GetA() string + GetC() bool +} + +type D interface { + IsA() + IsB() + IsD() + GetA() string + GetB() int + GetD() *string +} + +type FooBarer interface { + IsFooBarer() + GetName() string +} + +// InterfaceWithDescription is an interface with a description +type InterfaceWithDescription interface { + IsInterfaceWithDescription() + GetName() *string +} + +type MissingInterface interface { + IsMissingInterface() + GetName() *string +} + +type MissingUnion interface { + IsMissingUnion() +} + +// UnionWithDescription is an union with a description +type UnionWithDescription interface { + IsUnionWithDescription() +} + +type X interface { + IsX() + GetId() string +} + +type CDImplemented struct { + A string `json:"a" database:"CDImplementeda"` + B int `json:"b" database:"CDImplementedb"` + C bool `json:"c" database:"CDImplementedc"` + D *string `json:"d,omitempty" database:"CDImplementedd"` +} + +func (CDImplemented) IsC() {} +func (this CDImplemented) GetA() string { return this.A } +func (this CDImplemented) GetC() bool { return this.C } + +func (CDImplemented) IsA() {} + +func (CDImplemented) IsD() {} + +func (this CDImplemented) GetB() int { return this.B } +func (this CDImplemented) GetD() *string { return this.D } + +func (CDImplemented) IsB() {} + +type CyclicalA struct { + FieldOne *CyclicalB `json:"field_one,omitempty" database:"CyclicalAfield_one"` + FieldTwo *CyclicalB `json:"field_two,omitempty" database:"CyclicalAfield_two"` + FieldThree *CyclicalB `json:"field_three,omitempty" database:"CyclicalAfield_three"` + FieldFour string `json:"field_four" database:"CyclicalAfield_four"` +} + +type CyclicalB struct { + FieldOne *CyclicalA `json:"field_one,omitempty" database:"CyclicalBfield_one"` + FieldTwo *CyclicalA `json:"field_two,omitempty" database:"CyclicalBfield_two"` + FieldThree *CyclicalA `json:"field_three,omitempty" database:"CyclicalBfield_three"` + FieldFour *CyclicalA `json:"field_four,omitempty" database:"CyclicalBfield_four"` + FieldFive string `json:"field_five" database:"CyclicalBfield_five"` +} + +type ExtraFieldsTest struct { + SchemaField string `json:"SchemaField" database:"ExtraFieldsTestSchemaField"` +} + +type FieldMutationHook struct { + Name *string `json:"name,omitempty" anotherTag:"tag" database:"FieldMutationHookname"` + Enum *out.ExistingEnum `json:"enum,omitempty" yetAnotherTag:"12" database:"FieldMutationHookenum"` + NoVal *string `json:"noVal,omitempty" yaml:"noVal" repeated:"true" database:"FieldMutationHooknoVal"` + Repeated *string `json:"repeated,omitempty" someTag:"value" repeated:"true" database:"FieldMutationHookrepeated"` +} + +type ImplArrayOfA struct { + TrickyField []*CDImplemented `json:"trickyField" database:"ImplArrayOfAtrickyField"` + TrickyFieldPointer []*CDImplemented `json:"trickyFieldPointer,omitempty" database:"ImplArrayOfAtrickyFieldPointer"` +} + +func (ImplArrayOfA) IsArrayOfA() {} +func (this ImplArrayOfA) GetTrickyField() []A { + if this.TrickyField == nil { + return nil + } + interfaceSlice := make([]A, 0, len(this.TrickyField)) + for _, concrete := range this.TrickyField { + interfaceSlice = append(interfaceSlice, concrete) + } + return interfaceSlice +} +func (this ImplArrayOfA) GetTrickyFieldPointer() []A { + if this.TrickyFieldPointer == nil { + return nil + } + interfaceSlice := make([]A, 0, len(this.TrickyFieldPointer)) + for _, concrete := range this.TrickyFieldPointer { + interfaceSlice = append(interfaceSlice, concrete) + } + return interfaceSlice +} + +type MissingInput struct { + Name *string `json:"name,omitempty" database:"MissingInputname"` + Enum *MissingEnum `json:"enum,omitempty" database:"MissingInputenum"` + NonNullString string `json:"nonNullString" database:"MissingInputnonNullString"` + NullString graphql.Omittable[*string] `json:"nullString,omitempty" database:"MissingInputnullString"` + NullEnum graphql.Omittable[*MissingEnum] `json:"nullEnum,omitempty" database:"MissingInputnullEnum"` + NullObject graphql.Omittable[*out.ExistingInput] `json:"nullObject,omitempty" database:"MissingInputnullObject"` +} + +type MissingTypeNotNull struct { + Name string `json:"name" database:"MissingTypeNotNullname"` + Enum MissingEnum `json:"enum" database:"MissingTypeNotNullenum"` + Int MissingInterface `json:"int" database:"MissingTypeNotNullint"` + Existing *out.ExistingType `json:"existing" database:"MissingTypeNotNullexisting"` + Missing2 *MissingTypeNullable `json:"missing2" database:"MissingTypeNotNullmissing2"` +} + +func (MissingTypeNotNull) IsMissingInterface() {} +func (this MissingTypeNotNull) GetName() *string { return &this.Name } + +func (MissingTypeNotNull) IsExistingInterface() {} + +func (MissingTypeNotNull) IsMissingUnion() {} + +func (MissingTypeNotNull) IsExistingUnion() {} + +type MissingTypeNullable struct { + Name *string `json:"name,omitempty" database:"MissingTypeNullablename"` + Enum *MissingEnum `json:"enum,omitempty" database:"MissingTypeNullableenum"` + Int MissingInterface `json:"int,omitempty" database:"MissingTypeNullableint"` + Existing *out.ExistingType `json:"existing,omitempty" database:"MissingTypeNullableexisting"` + Missing2 *MissingTypeNotNull `json:"missing2,omitempty" database:"MissingTypeNullablemissing2"` +} + +func (MissingTypeNullable) IsMissingInterface() {} +func (this MissingTypeNullable) GetName() *string { return this.Name } + +func (MissingTypeNullable) IsExistingInterface() {} + +func (MissingTypeNullable) IsMissingUnion() {} + +func (MissingTypeNullable) IsExistingUnion() {} + +type Mutation struct { +} + +type NotCyclicalA struct { + FieldOne string `json:"FieldOne" database:"NotCyclicalAFieldOne"` + FieldTwo int `json:"FieldTwo" database:"NotCyclicalAFieldTwo"` +} + +type NotCyclicalB struct { + FieldOne string `json:"FieldOne" database:"NotCyclicalBFieldOne"` + FieldTwo *NotCyclicalA `json:"FieldTwo" database:"NotCyclicalBFieldTwo"` +} + +type OmitEmptyJSONTagTest struct { + ValueNonNil string `json:"ValueNonNil" database:"OmitEmptyJsonTagTestValueNonNil"` + Value *string `json:"Value,omitempty" database:"OmitEmptyJsonTagTestValue"` +} + +type Query struct { +} + +type Recursive struct { + FieldOne *Recursive `json:"FieldOne" database:"RecursiveFieldOne"` + FieldTwo *Recursive `json:"FieldTwo" database:"RecursiveFieldTwo"` + FieldThree *Recursive `json:"FieldThree" database:"RecursiveFieldThree"` + FieldFour string `json:"FieldFour" database:"RecursiveFieldFour"` +} + +type RenameFieldTest struct { + BadName string `json:"badName" database:"RenameFieldTestbadName"` + OtherField string `json:"otherField" database:"RenameFieldTestotherField"` +} + +type Subscription struct { +} + +// TypeWithDescription is a type with a description +type TypeWithDescription struct { + Name *string `json:"name,omitempty" database:"TypeWithDescriptionname"` +} + +func (TypeWithDescription) IsUnionWithDescription() {} + +type Xer struct { + Id string `json:"Id" database:"XerId"` + Name string `json:"Name" database:"XerName"` +} + +func (Xer) IsX() {} +func (this Xer) GetId() string { return this.Id } + +type FooBarr struct { + Name string `json:"name" database:"_Foo_Barrname"` +} + +func (FooBarr) IsFooBarer() {} +func (this FooBarr) GetName() string { return this.Name } + +// EnumWithDescription is an enum with a description +type EnumWithDescription string + +const ( + EnumWithDescriptionCat EnumWithDescription = "CAT" + EnumWithDescriptionDog EnumWithDescription = "DOG" +) + +var AllEnumWithDescription = []EnumWithDescription{ + EnumWithDescriptionCat, + EnumWithDescriptionDog, +} + +func (e EnumWithDescription) IsValid() bool { + switch e { + case EnumWithDescriptionCat, EnumWithDescriptionDog: + return true + } + return false +} + +func (e EnumWithDescription) String() string { + return string(e) +} + +func (e *EnumWithDescription) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = EnumWithDescription(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid EnumWithDescription", str) + } + return nil +} + +func (e EnumWithDescription) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +type MissingEnum string + +const ( + MissingEnumHello MissingEnum = "Hello" + MissingEnumGoodbye MissingEnum = "Goodbye" +) + +var AllMissingEnum = []MissingEnum{ + MissingEnumHello, + MissingEnumGoodbye, +} + +func (e MissingEnum) IsValid() bool { + switch e { + case MissingEnumHello, MissingEnumGoodbye: + return true + } + return false +} + +func (e MissingEnum) String() string { + return string(e) +} + +func (e *MissingEnum) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = MissingEnum(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid MissingEnum", str) + } + return nil +} + +func (e MissingEnum) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} diff --git a/plugin/modelgen/out_nullable_input_omittable/existing.go b/plugin/modelgen/out_nullable_input_omittable/existing.go new file mode 100644 index 0000000..b29fe7a --- /dev/null +++ b/plugin/modelgen/out_nullable_input_omittable/existing.go @@ -0,0 +1,34 @@ +package out_nullable_input_omittable + +import ( + "github.com/niko0xdev/gqlgen/graphql" +) + +type ExistingType struct { + Name *string `json:"name"` + Enum *ExistingEnum `json:"enum"` + Int ExistingInterface `json:"int"` + Existing *MissingTypeNullable `json:"existing"` +} + +type ExistingModel struct { + Name string + Enum ExistingEnum + Int ExistingInterface +} + +type ExistingInput struct { + Name graphql.Omittable[string] + Enum graphql.Omittable[ExistingEnum] + Int graphql.Omittable[ExistingInterface] +} + +type ExistingEnum string + +type ExistingInterface interface { + IsExistingInterface() +} + +type ExistingUnion interface { + IsExistingUnion() +} diff --git a/plugin/modelgen/out_nullable_input_omittable/generated.go b/plugin/modelgen/out_nullable_input_omittable/generated.go new file mode 100644 index 0000000..d55ea0c --- /dev/null +++ b/plugin/modelgen/out_nullable_input_omittable/generated.go @@ -0,0 +1,330 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package out_nullable_input_omittable + +import ( + "fmt" + "io" + "strconv" + + "github.com/niko0xdev/gqlgen/graphql" +) + +type A interface { + IsA() + GetA() string +} + +type ArrayOfA interface { + IsArrayOfA() + GetTrickyField() []A + GetTrickyFieldPointer() []A +} + +type B interface { + IsB() + GetB() int +} + +type C interface { + IsA() + IsC() + GetA() string + GetC() bool +} + +type D interface { + IsA() + IsB() + IsD() + GetA() string + GetB() int + GetD() *string +} + +type FooBarer interface { + IsFooBarer() + GetName() string +} + +// InterfaceWithDescription is an interface with a description +type InterfaceWithDescription interface { + IsInterfaceWithDescription() + GetName() *string +} + +type MissingInterface interface { + IsMissingInterface() + GetName() *string +} + +type MissingUnion interface { + IsMissingUnion() +} + +// UnionWithDescription is an union with a description +type UnionWithDescription interface { + IsUnionWithDescription() +} + +type X interface { + IsX() + GetId() string +} + +type CDImplemented struct { + A string `json:"a" database:"CDImplementeda"` + B int `json:"b" database:"CDImplementedb"` + C bool `json:"c" database:"CDImplementedc"` + D *string `json:"d,omitempty" database:"CDImplementedd"` +} + +func (CDImplemented) IsC() {} +func (this CDImplemented) GetA() string { return this.A } +func (this CDImplemented) GetC() bool { return this.C } + +func (CDImplemented) IsA() {} + +func (CDImplemented) IsD() {} + +func (this CDImplemented) GetB() int { return this.B } +func (this CDImplemented) GetD() *string { return this.D } + +func (CDImplemented) IsB() {} + +type CyclicalA struct { + FieldOne *CyclicalB `json:"field_one,omitempty" database:"CyclicalAfield_one"` + FieldTwo *CyclicalB `json:"field_two,omitempty" database:"CyclicalAfield_two"` + FieldThree *CyclicalB `json:"field_three,omitempty" database:"CyclicalAfield_three"` + FieldFour string `json:"field_four" database:"CyclicalAfield_four"` +} + +type CyclicalB struct { + FieldOne *CyclicalA `json:"field_one,omitempty" database:"CyclicalBfield_one"` + FieldTwo *CyclicalA `json:"field_two,omitempty" database:"CyclicalBfield_two"` + FieldThree *CyclicalA `json:"field_three,omitempty" database:"CyclicalBfield_three"` + FieldFour *CyclicalA `json:"field_four,omitempty" database:"CyclicalBfield_four"` + FieldFive string `json:"field_five" database:"CyclicalBfield_five"` +} + +type ExtraFieldsTest struct { + SchemaField string `json:"SchemaField" database:"ExtraFieldsTestSchemaField"` +} + +type FieldMutationHook struct { + Name *string `json:"name,omitempty" anotherTag:"tag" database:"FieldMutationHookname"` + Enum *ExistingEnum `json:"enum,omitempty" yetAnotherTag:"12" database:"FieldMutationHookenum"` + NoVal *string `json:"noVal,omitempty" yaml:"noVal" repeated:"true" database:"FieldMutationHooknoVal"` + Repeated *string `json:"repeated,omitempty" someTag:"value" repeated:"true" database:"FieldMutationHookrepeated"` +} + +type ImplArrayOfA struct { + TrickyField []*CDImplemented `json:"trickyField" database:"ImplArrayOfAtrickyField"` + TrickyFieldPointer []*CDImplemented `json:"trickyFieldPointer,omitempty" database:"ImplArrayOfAtrickyFieldPointer"` +} + +func (ImplArrayOfA) IsArrayOfA() {} +func (this ImplArrayOfA) GetTrickyField() []A { + if this.TrickyField == nil { + return nil + } + interfaceSlice := make([]A, 0, len(this.TrickyField)) + for _, concrete := range this.TrickyField { + interfaceSlice = append(interfaceSlice, concrete) + } + return interfaceSlice +} +func (this ImplArrayOfA) GetTrickyFieldPointer() []A { + if this.TrickyFieldPointer == nil { + return nil + } + interfaceSlice := make([]A, 0, len(this.TrickyFieldPointer)) + for _, concrete := range this.TrickyFieldPointer { + interfaceSlice = append(interfaceSlice, concrete) + } + return interfaceSlice +} + +type MissingInput struct { + Name graphql.Omittable[*string] `json:"name,omitempty" database:"MissingInputname"` + Enum graphql.Omittable[*MissingEnum] `json:"enum,omitempty" database:"MissingInputenum"` + NonNullString string `json:"nonNullString" database:"MissingInputnonNullString"` + NullString graphql.Omittable[*string] `json:"nullString,omitempty" database:"MissingInputnullString"` + NullEnum graphql.Omittable[*MissingEnum] `json:"nullEnum,omitempty" database:"MissingInputnullEnum"` + NullObject graphql.Omittable[*ExistingInput] `json:"nullObject,omitempty" database:"MissingInputnullObject"` +} + +type MissingTypeNotNull struct { + Name string `json:"name" database:"MissingTypeNotNullname"` + Enum MissingEnum `json:"enum" database:"MissingTypeNotNullenum"` + Int MissingInterface `json:"int" database:"MissingTypeNotNullint"` + Existing *ExistingType `json:"existing" database:"MissingTypeNotNullexisting"` + Missing2 *MissingTypeNullable `json:"missing2" database:"MissingTypeNotNullmissing2"` +} + +func (MissingTypeNotNull) IsMissingInterface() {} +func (this MissingTypeNotNull) GetName() *string { return &this.Name } + +func (MissingTypeNotNull) IsExistingInterface() {} + +func (MissingTypeNotNull) IsMissingUnion() {} + +func (MissingTypeNotNull) IsExistingUnion() {} + +type MissingTypeNullable struct { + Name *string `json:"name,omitempty" database:"MissingTypeNullablename"` + Enum *MissingEnum `json:"enum,omitempty" database:"MissingTypeNullableenum"` + Int MissingInterface `json:"int,omitempty" database:"MissingTypeNullableint"` + Existing *ExistingType `json:"existing,omitempty" database:"MissingTypeNullableexisting"` + Missing2 *MissingTypeNotNull `json:"missing2,omitempty" database:"MissingTypeNullablemissing2"` +} + +func (MissingTypeNullable) IsMissingInterface() {} +func (this MissingTypeNullable) GetName() *string { return this.Name } + +func (MissingTypeNullable) IsExistingInterface() {} + +func (MissingTypeNullable) IsMissingUnion() {} + +func (MissingTypeNullable) IsExistingUnion() {} + +type Mutation struct { +} + +type NotCyclicalA struct { + FieldOne string `json:"FieldOne" database:"NotCyclicalAFieldOne"` + FieldTwo int `json:"FieldTwo" database:"NotCyclicalAFieldTwo"` +} + +type NotCyclicalB struct { + FieldOne string `json:"FieldOne" database:"NotCyclicalBFieldOne"` + FieldTwo *NotCyclicalA `json:"FieldTwo" database:"NotCyclicalBFieldTwo"` +} + +type OmitEmptyJSONTagTest struct { + ValueNonNil string `json:"ValueNonNil" database:"OmitEmptyJsonTagTestValueNonNil"` + Value *string `json:"Value,omitempty" database:"OmitEmptyJsonTagTestValue"` +} + +type Query struct { +} + +type Recursive struct { + FieldOne *Recursive `json:"FieldOne" database:"RecursiveFieldOne"` + FieldTwo *Recursive `json:"FieldTwo" database:"RecursiveFieldTwo"` + FieldThree *Recursive `json:"FieldThree" database:"RecursiveFieldThree"` + FieldFour string `json:"FieldFour" database:"RecursiveFieldFour"` +} + +type RenameFieldTest struct { + BadName string `json:"badName" database:"RenameFieldTestbadName"` + OtherField string `json:"otherField" database:"RenameFieldTestotherField"` +} + +type Subscription struct { +} + +// TypeWithDescription is a type with a description +type TypeWithDescription struct { + Name *string `json:"name,omitempty" database:"TypeWithDescriptionname"` +} + +func (TypeWithDescription) IsUnionWithDescription() {} + +type Xer struct { + Id string `json:"Id" database:"XerId"` + Name string `json:"Name" database:"XerName"` +} + +func (Xer) IsX() {} +func (this Xer) GetId() string { return this.Id } + +type FooBarr struct { + Name string `json:"name" database:"_Foo_Barrname"` +} + +func (FooBarr) IsFooBarer() {} +func (this FooBarr) GetName() string { return this.Name } + +// EnumWithDescription is an enum with a description +type EnumWithDescription string + +const ( + EnumWithDescriptionCat EnumWithDescription = "CAT" + EnumWithDescriptionDog EnumWithDescription = "DOG" +) + +var AllEnumWithDescription = []EnumWithDescription{ + EnumWithDescriptionCat, + EnumWithDescriptionDog, +} + +func (e EnumWithDescription) IsValid() bool { + switch e { + case EnumWithDescriptionCat, EnumWithDescriptionDog: + return true + } + return false +} + +func (e EnumWithDescription) String() string { + return string(e) +} + +func (e *EnumWithDescription) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = EnumWithDescription(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid EnumWithDescription", str) + } + return nil +} + +func (e EnumWithDescription) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +type MissingEnum string + +const ( + MissingEnumHello MissingEnum = "Hello" + MissingEnumGoodbye MissingEnum = "Goodbye" +) + +var AllMissingEnum = []MissingEnum{ + MissingEnumHello, + MissingEnumGoodbye, +} + +func (e MissingEnum) IsValid() bool { + switch e { + case MissingEnumHello, MissingEnumGoodbye: + return true + } + return false +} + +func (e MissingEnum) String() string { + return string(e) +} + +func (e *MissingEnum) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = MissingEnum(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid MissingEnum", str) + } + return nil +} + +func (e MissingEnum) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} diff --git a/plugin/modelgen/out_struct_pointers/existing.go b/plugin/modelgen/out_struct_pointers/existing.go new file mode 100644 index 0000000..8e6a5e9 --- /dev/null +++ b/plugin/modelgen/out_struct_pointers/existing.go @@ -0,0 +1,30 @@ +package out_struct_pointers + +type ExistingType struct { + Name *string `json:"name"` + Enum *ExistingEnum `json:"enum"` + Int ExistingInterface `json:"int"` + Existing *MissingTypeNullable `json:"existing"` +} + +type ExistingModel struct { + Name string + Enum ExistingEnum + Int ExistingInterface +} + +type ExistingInput struct { + Name string + Enum ExistingEnum + Int ExistingInterface +} + +type ExistingEnum string + +type ExistingInterface interface { + IsExistingInterface() +} + +type ExistingUnion interface { + IsExistingUnion() +} diff --git a/plugin/modelgen/out_struct_pointers/generated.go b/plugin/modelgen/out_struct_pointers/generated.go new file mode 100644 index 0000000..2b98b77 --- /dev/null +++ b/plugin/modelgen/out_struct_pointers/generated.go @@ -0,0 +1,288 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package out_struct_pointers + +import ( + "fmt" + "io" + "strconv" + + "github.com/niko0xdev/gqlgen/graphql" +) + +type A interface { + IsA() +} + +type ArrayOfA interface { + IsArrayOfA() +} + +type B interface { + IsB() +} + +type C interface { + IsA() + IsC() +} + +type D interface { + IsA() + IsB() + IsD() +} + +type FooBarer interface { + IsFooBarer() +} + +// InterfaceWithDescription is an interface with a description +type InterfaceWithDescription interface { + IsInterfaceWithDescription() +} + +type MissingInterface interface { + IsMissingInterface() +} + +type MissingUnion interface { + IsMissingUnion() +} + +// UnionWithDescription is an union with a description +type UnionWithDescription interface { + IsUnionWithDescription() +} + +type X interface { + IsX() +} + +type CDImplemented struct { + A string `json:"a" database:"CDImplementeda"` + B int `json:"b" database:"CDImplementedb"` + C bool `json:"c" database:"CDImplementedc"` + D *string `json:"d,omitempty" database:"CDImplementedd"` +} + +func (CDImplemented) IsC() {} + +func (CDImplemented) IsA() {} + +func (CDImplemented) IsD() {} + +func (CDImplemented) IsB() {} + +type CyclicalA struct { + FieldOne *CyclicalB `json:"field_one,omitempty" database:"CyclicalAfield_one"` + FieldTwo *CyclicalB `json:"field_two,omitempty" database:"CyclicalAfield_two"` + FieldThree *CyclicalB `json:"field_three,omitempty" database:"CyclicalAfield_three"` + FieldFour string `json:"field_four" database:"CyclicalAfield_four"` +} + +type CyclicalB struct { + FieldOne *CyclicalA `json:"field_one,omitempty" database:"CyclicalBfield_one"` + FieldTwo *CyclicalA `json:"field_two,omitempty" database:"CyclicalBfield_two"` + FieldThree *CyclicalA `json:"field_three,omitempty" database:"CyclicalBfield_three"` + FieldFour *CyclicalA `json:"field_four,omitempty" database:"CyclicalBfield_four"` + FieldFive string `json:"field_five" database:"CyclicalBfield_five"` +} + +type ExtraFieldsTest struct { + SchemaField string `json:"SchemaField" database:"ExtraFieldsTestSchemaField"` +} + +type FieldMutationHook struct { + Name *string `json:"name,omitempty" anotherTag:"tag" database:"FieldMutationHookname"` + Enum *ExistingEnum `json:"enum,omitempty" yetAnotherTag:"12" database:"FieldMutationHookenum"` + NoVal *string `json:"noVal,omitempty" yaml:"noVal" repeated:"true" database:"FieldMutationHooknoVal"` + Repeated *string `json:"repeated,omitempty" someTag:"value" repeated:"true" database:"FieldMutationHookrepeated"` +} + +type ImplArrayOfA struct { + TrickyField []*CDImplemented `json:"trickyField" database:"ImplArrayOfAtrickyField"` + TrickyFieldPointer []*CDImplemented `json:"trickyFieldPointer,omitempty" database:"ImplArrayOfAtrickyFieldPointer"` +} + +func (ImplArrayOfA) IsArrayOfA() {} + +type MissingInput struct { + Name *string `json:"name,omitempty" database:"MissingInputname"` + Enum *MissingEnum `json:"enum,omitempty" database:"MissingInputenum"` + NonNullString string `json:"nonNullString" database:"MissingInputnonNullString"` + NullString graphql.Omittable[*string] `json:"nullString,omitempty" database:"MissingInputnullString"` + NullEnum graphql.Omittable[*MissingEnum] `json:"nullEnum,omitempty" database:"MissingInputnullEnum"` + NullObject graphql.Omittable[*ExistingInput] `json:"nullObject,omitempty" database:"MissingInputnullObject"` +} + +type MissingTypeNotNull struct { + Name string `json:"name" database:"MissingTypeNotNullname"` + Enum MissingEnum `json:"enum" database:"MissingTypeNotNullenum"` + Int MissingInterface `json:"int" database:"MissingTypeNotNullint"` + Existing ExistingType `json:"existing" database:"MissingTypeNotNullexisting"` + Missing2 MissingTypeNullable `json:"missing2" database:"MissingTypeNotNullmissing2"` +} + +func (MissingTypeNotNull) IsMissingInterface() {} + +func (MissingTypeNotNull) IsExistingInterface() {} + +func (MissingTypeNotNull) IsMissingUnion() {} + +func (MissingTypeNotNull) IsExistingUnion() {} + +type MissingTypeNullable struct { + Name *string `json:"name,omitempty" database:"MissingTypeNullablename"` + Enum *MissingEnum `json:"enum,omitempty" database:"MissingTypeNullableenum"` + Int MissingInterface `json:"int,omitempty" database:"MissingTypeNullableint"` + Existing *ExistingType `json:"existing,omitempty" database:"MissingTypeNullableexisting"` + Missing2 *MissingTypeNotNull `json:"missing2,omitempty" database:"MissingTypeNullablemissing2"` +} + +func (MissingTypeNullable) IsMissingInterface() {} + +func (MissingTypeNullable) IsExistingInterface() {} + +func (MissingTypeNullable) IsMissingUnion() {} + +func (MissingTypeNullable) IsExistingUnion() {} + +type Mutation struct { +} + +type NotCyclicalA struct { + FieldOne string `json:"FieldOne" database:"NotCyclicalAFieldOne"` + FieldTwo int `json:"FieldTwo" database:"NotCyclicalAFieldTwo"` +} + +type NotCyclicalB struct { + FieldOne string `json:"FieldOne" database:"NotCyclicalBFieldOne"` + FieldTwo NotCyclicalA `json:"FieldTwo" database:"NotCyclicalBFieldTwo"` +} + +type OmitEmptyJSONTagTest struct { + ValueNonNil string `json:"ValueNonNil" database:"OmitEmptyJsonTagTestValueNonNil"` + Value *string `json:"Value,omitempty" database:"OmitEmptyJsonTagTestValue"` +} + +type Query struct { +} + +type Recursive struct { + FieldOne *Recursive `json:"FieldOne" database:"RecursiveFieldOne"` + FieldTwo *Recursive `json:"FieldTwo" database:"RecursiveFieldTwo"` + FieldThree *Recursive `json:"FieldThree" database:"RecursiveFieldThree"` + FieldFour string `json:"FieldFour" database:"RecursiveFieldFour"` +} + +type RenameFieldTest struct { + BadName string `json:"badName" database:"RenameFieldTestbadName"` + OtherField string `json:"otherField" database:"RenameFieldTestotherField"` +} + +type Subscription struct { +} + +// TypeWithDescription is a type with a description +type TypeWithDescription struct { + Name *string `json:"name,omitempty" database:"TypeWithDescriptionname"` +} + +func (TypeWithDescription) IsUnionWithDescription() {} + +type Xer struct { + Id string `json:"Id" database:"XerId"` + Name string `json:"Name" database:"XerName"` +} + +func (Xer) IsX() {} + +type FooBarr struct { + Name string `json:"name" database:"_Foo_Barrname"` +} + +func (FooBarr) IsFooBarer() {} + +// EnumWithDescription is an enum with a description +type EnumWithDescription string + +const ( + EnumWithDescriptionCat EnumWithDescription = "CAT" + EnumWithDescriptionDog EnumWithDescription = "DOG" +) + +var AllEnumWithDescription = []EnumWithDescription{ + EnumWithDescriptionCat, + EnumWithDescriptionDog, +} + +func (e EnumWithDescription) IsValid() bool { + switch e { + case EnumWithDescriptionCat, EnumWithDescriptionDog: + return true + } + return false +} + +func (e EnumWithDescription) String() string { + return string(e) +} + +func (e *EnumWithDescription) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = EnumWithDescription(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid EnumWithDescription", str) + } + return nil +} + +func (e EnumWithDescription) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} + +type MissingEnum string + +const ( + MissingEnumHello MissingEnum = "Hello" + MissingEnumGoodbye MissingEnum = "Goodbye" +) + +var AllMissingEnum = []MissingEnum{ + MissingEnumHello, + MissingEnumGoodbye, +} + +func (e MissingEnum) IsValid() bool { + switch e { + case MissingEnumHello, MissingEnumGoodbye: + return true + } + return false +} + +func (e MissingEnum) String() string { + return string(e) +} + +func (e *MissingEnum) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = MissingEnum(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid MissingEnum", str) + } + return nil +} + +func (e MissingEnum) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} diff --git a/plugin/modelgen/testdata/customModelTemplate.gotpl b/plugin/modelgen/testdata/customModelTemplate.gotpl new file mode 100644 index 0000000..1de611e --- /dev/null +++ b/plugin/modelgen/testdata/customModelTemplate.gotpl @@ -0,0 +1,106 @@ +{{ reserveImport "context" }} +{{ reserveImport "fmt" }} +{{ reserveImport "io" }} +{{ reserveImport "strconv" }} +{{ reserveImport "time" }} +{{ reserveImport "sync" }} +{{ reserveImport "errors" }} +{{ reserveImport "bytes" }} + +{{ reserveImport "github.com/vektah/gqlparser/v2" }} +{{ reserveImport "github.com/vektah/gqlparser/v2/ast" }} +{{ reserveImport "github.com/niko0xdev/gqlgen/graphql" }} +{{ reserveImport "github.com/niko0xdev/gqlgen/graphql/introspection" }} + +// Add any new functions or any additional code/template functionality here + +{{- range $model := .Interfaces }} + {{ with .Description }} {{.|prefixLines "// "}} {{ end }} + type {{ goModelName .Name }} interface { + {{- if not .OmitCheck }} + {{- range $impl := .Implements }} + Is{{ goModelName $impl }}() + {{- end }} + Is{{ goModelName .Name }}() + {{- end }} + {{- range $field := .Fields }} + {{- with .Description }} + {{.|prefixLines "// "}} + {{- end}} + Get{{ $field.GoName }}() {{ $field.Type | ref }} + {{- end }} + } +{{- end }} + +{{ range $model := .Models }} + {{with .Description }} {{.|prefixLines "// "}} {{end}} + type {{ goModelName .Name }} struct { + {{- range $field := .Fields }} + {{- with .Description }} + {{.|prefixLines "// "}} + {{- end}} + {{ $field.GoName }} {{$field.Type | ref}} `{{$field.Tag}}` + {{- end }} + } + + {{ range .Implements }} + func ({{ goModelName $model.Name }}) Is{{ goModelName . }}() {} + {{- with getInterfaceByName . }} + {{- range .Fields }} + {{- with .Description }} + {{.|prefixLines "// "}} + {{- end}} + {{ generateGetter $model . }} + {{- end }} + {{- end }} + {{ end }} +{{- end}} + +{{ range $enum := .Enums }} + {{ with .Description }} {{.|prefixLines "// "}} {{end}} + type {{ goModelName .Name }} string + const ( + {{- range $value := .Values}} + {{- with .Description}} + {{.|prefixLines "// "}} + {{- end}} + {{ goModelName $enum.Name .Name }} {{ goModelName $enum.Name }} = {{ .Name|quote }} + {{- end }} + ) + + var All{{ goModelName .Name }} = []{{ goModelName .Name }}{ + {{- range $value := .Values}} + {{ goModelName $enum.Name .Name }}, + {{- end }} + } + + func (e {{ goModelName .Name }}) IsValid() bool { + switch e { + case {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ goModelName $enum.Name $element.Name }}{{end}}: + return true + } + return false + } + + func (e {{ goModelName .Name }}) String() string { + return string(e) + } + + func (e *{{ goModelName .Name }}) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = {{ goModelName .Name }}(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid {{ .Name }}", str) + } + return nil + } + + func (e {{ goModelName .Name }}) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) + } + +{{- end }} diff --git a/plugin/modelgen/testdata/gqlgen.yml b/plugin/modelgen/testdata/gqlgen.yml new file mode 100644 index 0000000..f6a31b8 --- /dev/null +++ b/plugin/modelgen/testdata/gqlgen.yml @@ -0,0 +1,37 @@ +schema: + - "testdata/schema.graphql" + +exec: + filename: out/ignored.go +model: + filename: out/generated.go + +models: + ExistingModel: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out.ExistingModel + ExistingInput: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out.ExistingInput + ExistingEnum: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out.ExistingEnum + ExistingInterface: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out.ExistingInterface + ExistingUnion: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out.ExistingUnion + ExistingType: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out.ExistingType + RenameFieldTest: + fields: + badName: + fieldName: GOODnaME + ExtraFieldsTest: + extraFields: + FieldInternalType: + description: "Internal field" + type: github.com/niko0xdev/gqlgen/plugin/modelgen/internal/extrafields.Type + FieldStringPtr: + type: "*string" + FieldInt: + type: "int64" + overrideTags: 'json:"field_int_tag"' + FieldIntSlice: + type: "[]int64" diff --git a/plugin/modelgen/testdata/gqlgen_custom_model_template.yml b/plugin/modelgen/testdata/gqlgen_custom_model_template.yml new file mode 100644 index 0000000..420699a --- /dev/null +++ b/plugin/modelgen/testdata/gqlgen_custom_model_template.yml @@ -0,0 +1,38 @@ +schema: + - "testdata/schema.graphql" + +exec: + filename: out/ignored.go +model: + filename: out/generated.go + model_template: "testdata/customModelTemplate.gotpl" + +models: + ExistingModel: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out.ExistingModel + ExistingInput: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out.ExistingInput + ExistingEnum: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out.ExistingEnum + ExistingInterface: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out.ExistingInterface + ExistingUnion: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out.ExistingUnion + ExistingType: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out.ExistingType + RenameFieldTest: + fields: + badName: + fieldName: GOODnaME + ExtraFieldsTest: + extraFields: + FieldInternalType: + description: "Internal field" + type: github.com/niko0xdev/gqlgen/plugin/modelgen/internal/extrafields.Type + FieldStringPtr: + type: "*string" + FieldInt: + type: "int64" + overrideTags: 'json:"field_int_tag"' + FieldIntSlice: + type: "[]int64" diff --git a/plugin/modelgen/testdata/gqlgen_enable_model_json_omitempty_tag_false.yml b/plugin/modelgen/testdata/gqlgen_enable_model_json_omitempty_tag_false.yml new file mode 100644 index 0000000..6c80906 --- /dev/null +++ b/plugin/modelgen/testdata/gqlgen_enable_model_json_omitempty_tag_false.yml @@ -0,0 +1,23 @@ +schema: + - "testdata/schema.graphql" + +enable_model_json_omitempty_tag: false + +exec: + filename: out_enable_model_json_omitempty_tag_false/ignored.go +model: + filename: out_enable_model_json_omitempty_tag_false/generated.go + +models: + ExistingModel: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_false.ExistingModel + ExistingInput: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out.ExistingInput + ExistingEnum: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out.ExistingEnum + ExistingInterface: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out.ExistingInterface + ExistingUnion: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out.ExistingUnion + ExistingType: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out.ExistingType diff --git a/plugin/modelgen/testdata/gqlgen_enable_model_json_omitempty_tag_nil.yml b/plugin/modelgen/testdata/gqlgen_enable_model_json_omitempty_tag_nil.yml new file mode 100644 index 0000000..f02974b --- /dev/null +++ b/plugin/modelgen/testdata/gqlgen_enable_model_json_omitempty_tag_nil.yml @@ -0,0 +1,21 @@ +schema: + - "testdata/schema.graphql" + +exec: + filename: out_enable_model_json_omitempty_tag_nil/ignored.go +model: + filename: out_enable_model_json_omitempty_tag_nil/generated.go + +models: + ExistingModel: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_nil.ExistingModel + ExistingInput: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_nil.ExistingInput + ExistingEnum: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_nil.ExistingEnum + ExistingInterface: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_nil.ExistingInterface + ExistingUnion: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_nil.ExistingUnion + ExistingType: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_nil.ExistingType diff --git a/plugin/modelgen/testdata/gqlgen_enable_model_json_omitempty_tag_true.yml b/plugin/modelgen/testdata/gqlgen_enable_model_json_omitempty_tag_true.yml new file mode 100644 index 0000000..d9c248f --- /dev/null +++ b/plugin/modelgen/testdata/gqlgen_enable_model_json_omitempty_tag_true.yml @@ -0,0 +1,23 @@ +schema: + - "testdata/schema.graphql" + +enable_model_json_omitempty_tag: true + +exec: + filename: out_enable_model_json_omitempty_tag_true/ignored.go +model: + filename: out_enable_model_json_omitempty_tag_true/generated.go + +models: + ExistingModel: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_true.ExistingModel + ExistingInput: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out.ExistingInput + ExistingEnum: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out.ExistingEnum + ExistingInterface: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out.ExistingInterface + ExistingUnion: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out.ExistingUnion + ExistingType: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out.ExistingType diff --git a/plugin/modelgen/testdata/gqlgen_nullable_input_omittable.yml b/plugin/modelgen/testdata/gqlgen_nullable_input_omittable.yml new file mode 100644 index 0000000..6fea764 --- /dev/null +++ b/plugin/modelgen/testdata/gqlgen_nullable_input_omittable.yml @@ -0,0 +1,23 @@ +schema: + - "testdata/schema.graphql" + +exec: + filename: out_nullable_input_omittable/ignored.go +model: + filename: out_nullable_input_omittable/generated.go + +nullable_input_omittable: true + +models: + ExistingModel: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out_nullable_input_omittable.ExistingModel + ExistingInput: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out_nullable_input_omittable.ExistingInput + ExistingEnum: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out_nullable_input_omittable.ExistingEnum + ExistingInterface: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out_nullable_input_omittable.ExistingInterface + ExistingUnion: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out_nullable_input_omittable.ExistingUnion + ExistingType: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out_nullable_input_omittable.ExistingType diff --git a/plugin/modelgen/testdata/gqlgen_omit_root_models.yml b/plugin/modelgen/testdata/gqlgen_omit_root_models.yml new file mode 100644 index 0000000..6372008 --- /dev/null +++ b/plugin/modelgen/testdata/gqlgen_omit_root_models.yml @@ -0,0 +1,9 @@ +schema: + - "testdata/schema_omit_root_models.graphql" + +exec: + filename: out/ignored.go +model: + filename: out/generated_omit_root_models.go + +omit_root_models: true diff --git a/plugin/modelgen/testdata/gqlgen_struct_field_pointers.yml b/plugin/modelgen/testdata/gqlgen_struct_field_pointers.yml new file mode 100644 index 0000000..fa5a50d --- /dev/null +++ b/plugin/modelgen/testdata/gqlgen_struct_field_pointers.yml @@ -0,0 +1,25 @@ +schema: + - "testdata/schema.graphql" + +exec: + filename: out_struct_pointers/ignored.go +model: + filename: out_struct_pointers/generated.go + +struct_fields_always_pointers: false +omit_getters: true + +models: + ExistingModel: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out_struct_pointers.ExistingModel + ExistingInput: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out_struct_pointers.ExistingInput + ExistingEnum: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out_struct_pointers.ExistingEnum + ExistingInterface: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out_struct_pointers.ExistingInterface + ExistingUnion: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out_struct_pointers.ExistingUnion + ExistingType: + model: github.com/niko0xdev/gqlgen/plugin/modelgen/out_struct_pointers.ExistingType + diff --git a/plugin/modelgen/testdata/schema.graphql b/plugin/modelgen/testdata/schema.graphql new file mode 100644 index 0000000..16b80f1 --- /dev/null +++ b/plugin/modelgen/testdata/schema.graphql @@ -0,0 +1,209 @@ +directive @goTag( + key: String! + value: String +) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION + +directive @goField( + forceResolver: Boolean + name: String + omittable: Boolean +) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION | INTERFACE + +type Query { + thisShoudlntGetGenerated: Boolean +} + +type Mutation { + thisShoudlntGetGenerated: Boolean +} + +type Subscription { + thisShoudlntGetGenerated: Boolean +} + +type MissingTypeNotNull implements MissingInterface & ExistingInterface { + name: String! + enum: MissingEnum! + int: MissingInterface! + existing: ExistingType! + missing2: MissingTypeNullable! +} + +type MissingTypeNullable implements MissingInterface & ExistingInterface { + name: String + enum: MissingEnum + int: MissingInterface + existing: ExistingType + missing2: MissingTypeNotNull +} + +input MissingInput { + name: String + enum: MissingEnum + nonNullString: String! + nullString: String @goField(omittable: true) + nullEnum: MissingEnum @goField(omittable: true) + nullObject: ExistingInput @goField(omittable: true) +} + +enum MissingEnum { + Hello + Goodbye +} + +interface MissingInterface { + name: String +} + +union MissingUnion = MissingTypeNotNull | MissingTypeNullable | ExistingType + +type ExistingType implements MissingInterface & ExistingInterface { + name: String + enum: ExistingEnum + int: ExistingInterface + existing: MissingTypeNullable +} + +input ExistingInput { + name: String + enum: ExistingEnum +} + +type FieldMutationHook { + name: String @goTag(key :"anotherTag", value: "tag") + enum: ExistingEnum @goTag(key: "yetAnotherTag", value: "12") + noVal: String @goTag(key: "yaml") @goTag(key : "repeated", value: "true") + repeated: String @goTag(key: "someTag", value: "value") @goTag(key : "repeated", value: "true") + +} + +enum ExistingEnum { + Hello + Goodbye +} + +interface ExistingInterface { + name: String +} + +union ExistingUnion = MissingTypeNotNull | MissingTypeNullable | ExistingType + +"TypeWithDescription is a type with a description" +type TypeWithDescription { + name: String +} + +"EnumWithDescription is an enum with a description" +enum EnumWithDescription { + CAT + DOG +} + +"InterfaceWithDescription is an interface with a description" +interface InterfaceWithDescription { + name: String +} + +"UnionWithDescription is an union with a description" +union UnionWithDescription = TypeWithDescription | ExistingType + + +interface Foo_Barer { + name: String! +} + +type _Foo_Barr implements Foo_Barer { + name: String! +} + +# https://spec.graphql.org/October2021/#sec-Interfaces +interface A { + a: String! +} + +interface B { + b: Int! +} + +interface C implements A { + a: String! + c: Boolean! +} + +interface D implements A & B { + a: String! + b: Int! + d: String +} + +type CDImplemented implements C & D & A & B { + a: String! + b: Int! + c: Boolean! + d: String +} + +type CyclicalA { + field_one: CyclicalB + field_two: CyclicalB + field_three: CyclicalB + field_four: String! +} + +type CyclicalB { + field_one: CyclicalA + field_two: CyclicalA + field_three: CyclicalA + field_four: CyclicalA + field_five: String! +} + +type NotCyclicalA { + FieldOne: String! + FieldTwo: Int! +} + +type NotCyclicalB { + FieldOne: String! + FieldTwo: NotCyclicalA! +} + +type Recursive { + FieldOne: Recursive! + FieldTwo: Recursive! + FieldThree: Recursive! + FieldFour: String! +} + +type RenameFieldTest { + badName: String! + otherField: String! +} + +interface ArrayOfA { + trickyField: [A!]! + trickyFieldPointer: [A] +} + +type ImplArrayOfA implements ArrayOfA { + trickyField: [CDImplemented!]! + trickyFieldPointer: [CDImplemented] +} + +interface X { + Id: String! @goField(name: "Id") +} + +type Xer implements X { + Id: String! @goField(name: "Id") + Name: String! +} + +type ExtraFieldsTest { + SchemaField: String! +} + +type OmitEmptyJsonTagTest { + ValueNonNil: String! + Value: String +} diff --git a/plugin/modelgen/testdata/schema_omit_root_models.graphql b/plugin/modelgen/testdata/schema_omit_root_models.graphql new file mode 100644 index 0000000..800020b --- /dev/null +++ b/plugin/modelgen/testdata/schema_omit_root_models.graphql @@ -0,0 +1,18 @@ +type Query { + thisShoudlntGetGenerated: Boolean +} + +type Mutation { + thisShoudlntGetGenerated: Boolean +} + +type Subscription { + thisShoudlntGetGenerated: Boolean +} + +enum SomeContent { + This + Is + A + Test +} diff --git a/plugin/modelgen/types.go b/plugin/modelgen/types.go new file mode 100644 index 0000000..5e76138 --- /dev/null +++ b/plugin/modelgen/types.go @@ -0,0 +1,47 @@ +package modelgen + +import ( + "go/types" + "strings" +) + +// buildType constructs a types.Type for the given string (using the syntax +// from the extra field config Type field). +func buildType(typeString string) types.Type { + switch { + case typeString[0] == '*': + return types.NewPointer(buildType(typeString[1:])) + case strings.HasPrefix(typeString, "[]"): + return types.NewSlice(buildType(typeString[2:])) + default: + return buildNamedType(typeString) + } +} + +// buildNamedType returns the specified named or builtin type. +// +// Note that we don't look up the full types.Type object from the appropriate +// package -- gqlgen doesn't give us the package-map we'd need to do so. +// Instead we construct a placeholder type that has all the fields gqlgen +// wants. This is roughly what gqlgen itself does, anyway: +// https://github.com/niko0xdev/gqlgen/blob/master/plugin/modelgen/models.go#L119 +func buildNamedType(fullName string) types.Type { + dotIndex := strings.LastIndex(fullName, ".") + if dotIndex == -1 { // builtinType + return types.Universe.Lookup(fullName).Type() + } + + // type is pkg.Name + pkgPath := fullName[:dotIndex] + typeName := fullName[dotIndex+1:] + + pkgName := pkgPath + slashIndex := strings.LastIndex(pkgPath, "/") + if slashIndex != -1 { + pkgName = pkgPath[slashIndex+1:] + } + + pkg := types.NewPackage(pkgPath, pkgName) + // gqlgen doesn't use some of the fields, so we leave them 0/nil + return types.NewNamed(types.NewTypeName(0, pkg, typeName, nil), nil, nil) +} diff --git a/plugin/plugin.go b/plugin/plugin.go new file mode 100644 index 0000000..1dae14d --- /dev/null +++ b/plugin/plugin.go @@ -0,0 +1,37 @@ +// plugin package interfaces are EXPERIMENTAL. + +package plugin + +import ( + "github.com/vektah/gqlparser/v2/ast" + + "github.com/niko0xdev/gqlgen/codegen" + "github.com/niko0xdev/gqlgen/codegen/config" +) + +type Plugin interface { + Name() string +} + +type ConfigMutator interface { + MutateConfig(cfg *config.Config) error +} + +type CodeGenerator interface { + GenerateCode(cfg *codegen.Data) error +} + +// EarlySourceInjector is used to inject things that are required for user schema files to compile. +type EarlySourceInjector interface { + InjectSourceEarly() *ast.Source +} + +// LateSourceInjector is used to inject more sources, after we have loaded the users schema. +type LateSourceInjector interface { + InjectSourceLate(schema *ast.Schema) *ast.Source +} + +// ResolverImplementer is used to generate code inside resolvers +type ResolverImplementer interface { + Implement(field *codegen.Field) string +} diff --git a/plugin/resolvergen/resolver.go b/plugin/resolvergen/resolver.go new file mode 100644 index 0000000..50b2735 --- /dev/null +++ b/plugin/resolvergen/resolver.go @@ -0,0 +1,286 @@ +package resolvergen + +import ( + _ "embed" + "errors" + "fmt" + "go/ast" + "io/fs" + "os" + "path/filepath" + "strings" + + "golang.org/x/text/cases" + "golang.org/x/text/language" + + "github.com/niko0xdev/gqlgen/codegen" + "github.com/niko0xdev/gqlgen/codegen/config" + "github.com/niko0xdev/gqlgen/codegen/templates" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/internal/rewrite" + "github.com/niko0xdev/gqlgen/plugin" +) + +//go:embed resolver.gotpl +var resolverTemplate string + +func New() plugin.Plugin { + return &Plugin{} +} + +type Plugin struct{} + +var _ plugin.CodeGenerator = &Plugin{} + +func (m *Plugin) Name() string { + return "resolvergen" +} + +func (m *Plugin) GenerateCode(data *codegen.Data) error { + if !data.Config.Resolver.IsDefined() { + return nil + } + + switch data.Config.Resolver.Layout { + case config.LayoutSingleFile: + return m.generateSingleFile(data) + case config.LayoutFollowSchema: + return m.generatePerSchema(data) + } + + return nil +} + +func (m *Plugin) generateSingleFile(data *codegen.Data) error { + file := File{} + + if _, err := os.Stat(data.Config.Resolver.Filename); err == nil { + // file already exists and we do not support updating resolvers with layout = single so just return + return nil + } + + for _, o := range data.Objects { + if o.HasResolvers() { + file.Objects = append(file.Objects, o) + } + for _, f := range o.Fields { + if !f.IsResolver { + continue + } + + resolver := Resolver{o, f, nil, "", `panic("not implemented")`, nil} + file.Resolvers = append(file.Resolvers, &resolver) + } + } + + resolverBuild := &ResolverBuild{ + File: &file, + PackageName: data.Config.Resolver.Package, + ResolverType: data.Config.Resolver.Type, + HasRoot: true, + OmitTemplateComment: data.Config.Resolver.OmitTemplateComment, + } + + newResolverTemplate := resolverTemplate + if data.Config.Resolver.ResolverTemplate != "" { + newResolverTemplate = readResolverTemplate(data.Config.Resolver.ResolverTemplate) + } + + return templates.Render(templates.Options{ + PackageName: data.Config.Resolver.Package, + FileNotice: `// THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES.`, + Filename: data.Config.Resolver.Filename, + Data: resolverBuild, + Packages: data.Config.Packages, + Template: newResolverTemplate, + }) +} + +func (m *Plugin) generatePerSchema(data *codegen.Data) error { + rewriter, err := rewrite.New(data.Config.Resolver.Dir()) + if err != nil { + return err + } + + files := map[string]*File{} + + objects := make(codegen.Objects, len(data.Objects)+len(data.Inputs)) + copy(objects, data.Objects) + copy(objects[len(data.Objects):], data.Inputs) + + for _, o := range objects { + if o.HasResolvers() { + fnCase := gqlToResolverName(data.Config.Resolver.Dir(), o.Position.Src.Name, data.Config.Resolver.FilenameTemplate) + fn := strings.ToLower(fnCase) + if files[fn] == nil { + files[fn] = &File{ + name: fnCase, + } + } + + caser := cases.Title(language.English, cases.NoLower) + rewriter.MarkStructCopied(templates.LcFirst(o.Name) + templates.UcFirst(data.Config.Resolver.Type)) + rewriter.GetMethodBody(data.Config.Resolver.Type, caser.String(o.Name)) + files[fn].Objects = append(files[fn].Objects, o) + } + for _, f := range o.Fields { + if !f.IsResolver { + continue + } + + structName := templates.LcFirst(o.Name) + templates.UcFirst(data.Config.Resolver.Type) + comment := strings.TrimSpace(strings.TrimLeft(rewriter.GetMethodComment(structName, f.GoFieldName), `\`)) + implementation := strings.TrimSpace(rewriter.GetMethodBody(structName, f.GoFieldName)) + if implementation == "" { + // use default implementation, if no implementation was previously used + implementation = fmt.Sprintf("panic(fmt.Errorf(\"not implemented: %v - %v\"))", f.GoFieldName, f.Name) + } + resolver := Resolver{o, f, rewriter.GetPrevDecl(structName, f.GoFieldName), comment, implementation, nil} + var implExists bool + for _, p := range data.Plugins { + rImpl, ok := p.(plugin.ResolverImplementer) + if !ok { + continue + } + if implExists { + return fmt.Errorf("multiple plugins implement ResolverImplementer") + } + implExists = true + resolver.ImplementationRender = rImpl.Implement + } + fnCase := gqlToResolverName(data.Config.Resolver.Dir(), f.Position.Src.Name, data.Config.Resolver.FilenameTemplate) + fn := strings.ToLower(fnCase) + if files[fn] == nil { + files[fn] = &File{ + name: fnCase, + } + } + + files[fn].Resolvers = append(files[fn].Resolvers, &resolver) + } + } + + for _, file := range files { + file.imports = rewriter.ExistingImports(file.name) + file.RemainingSource = rewriter.RemainingSource(file.name) + } + newResolverTemplate := resolverTemplate + if data.Config.Resolver.ResolverTemplate != "" { + newResolverTemplate = readResolverTemplate(data.Config.Resolver.ResolverTemplate) + } + + for _, file := range files { + resolverBuild := &ResolverBuild{ + File: file, + PackageName: data.Config.Resolver.Package, + ResolverType: data.Config.Resolver.Type, + OmitTemplateComment: data.Config.Resolver.OmitTemplateComment, + } + + var fileNotice strings.Builder + if !data.Config.OmitGQLGenFileNotice { + fileNotice.WriteString(` + // 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. + // Code generated by github.com/niko0xdev/gqlgen`, + ) + if !data.Config.OmitGQLGenVersionInFileNotice { + fileNotice.WriteString(` version `) + fileNotice.WriteString(graphql.Version) + } + } + + err := templates.Render(templates.Options{ + PackageName: data.Config.Resolver.Package, + FileNotice: fileNotice.String(), + Filename: file.name, + Data: resolverBuild, + Packages: data.Config.Packages, + Template: newResolverTemplate, + }) + if err != nil { + return err + } + } + + if _, err := os.Stat(data.Config.Resolver.Filename); errors.Is(err, fs.ErrNotExist) { + err := templates.Render(templates.Options{ + PackageName: data.Config.Resolver.Package, + FileNotice: ` + // This file will not be regenerated automatically. + // + // It serves as dependency injection for your app, add any dependencies you require here.`, + Template: `type {{.}} struct {}`, + Filename: data.Config.Resolver.Filename, + Data: data.Config.Resolver.Type, + Packages: data.Config.Packages, + }) + if err != nil { + return err + } + } + return nil +} + +type ResolverBuild struct { + *File + HasRoot bool + PackageName string + ResolverType string + OmitTemplateComment bool +} + +type File struct { + name string + // These are separated because the type definition of the resolver object may live in a different file from the + // resolver method implementations, for example when extending a type in a different graphql schema file + Objects []*codegen.Object + Resolvers []*Resolver + imports []rewrite.Import + RemainingSource string +} + +func (f *File) Imports() string { + for _, imp := range f.imports { + if imp.Alias == "" { + _, _ = templates.CurrentImports.Reserve(imp.ImportPath) + } else { + _, _ = templates.CurrentImports.Reserve(imp.ImportPath, imp.Alias) + } + } + return "" +} + +type Resolver struct { + Object *codegen.Object + Field *codegen.Field + PrevDecl *ast.FuncDecl + Comment string + ImplementationStr string + ImplementationRender func(r *codegen.Field) string +} + +func (r *Resolver) Implementation() string { + if r.ImplementationRender != nil { + return r.ImplementationRender(r.Field) + } + return r.ImplementationStr +} + +func gqlToResolverName(base string, gqlname, filenameTmpl string) string { + gqlname = filepath.Base(gqlname) + ext := filepath.Ext(gqlname) + if filenameTmpl == "" { + filenameTmpl = "{name}.resolvers.go" + } + filename := strings.ReplaceAll(filenameTmpl, "{name}", strings.TrimSuffix(gqlname, ext)) + return filepath.Join(base, filename) +} + +func readResolverTemplate(customResolverTemplate string) string { + contentBytes, err := os.ReadFile(customResolverTemplate) + if err != nil { + panic(err) + } + return string(contentBytes) +} diff --git a/plugin/resolvergen/resolver.gotpl b/plugin/resolvergen/resolver.gotpl new file mode 100644 index 0000000..88e88d1 --- /dev/null +++ b/plugin/resolvergen/resolver.gotpl @@ -0,0 +1,52 @@ +{{ reserveImport "context" }} +{{ reserveImport "fmt" }} +{{ reserveImport "io" }} +{{ reserveImport "strconv" }} +{{ reserveImport "time" }} +{{ reserveImport "sync" }} +{{ reserveImport "errors" }} +{{ reserveImport "bytes" }} + +{{ reserveImport "github.com/vektah/gqlparser/v2" }} +{{ reserveImport "github.com/vektah/gqlparser/v2/ast" }} +{{ reserveImport "github.com/niko0xdev/gqlgen/graphql" }} +{{ reserveImport "github.com/niko0xdev/gqlgen/graphql/introspection" }} + +{{ .Imports }} + +{{ if .HasRoot }} + type {{.ResolverType}} struct {} +{{ end }} + +{{ range $resolver := .Resolvers -}} + {{ if $resolver.Comment -}} + // {{ $resolver.Comment }} + {{- else if not $.OmitTemplateComment -}} + // {{ $resolver.Field.GoFieldName }} is the resolver for the {{ $resolver.Field.Name }} field. + {{- end }} + func (r *{{lcFirst $resolver.Object.Name}}{{ucFirst $.ResolverType}}) {{$resolver.Field.GoFieldName}}{{ with $resolver.PrevDecl }}{{ $resolver.Field.ShortResolverSignature .Type }}{{ else }}{{ $resolver.Field.ShortResolverDeclaration }}{{ end }}{ + {{ $resolver.Implementation }} + } + +{{ end }} + +{{ range $object := .Objects -}} + {{ if not $.OmitTemplateComment -}} + // {{ucFirst $object.Name}} returns {{ $object.ResolverInterface | ref }} implementation. + {{- end }} + func (r *{{$.ResolverType}}) {{ucFirst $object.Name}}() {{ $object.ResolverInterface | ref }} { return &{{lcFirst $object.Name}}{{ucFirst $.ResolverType}}{r} } +{{ end }} + +{{ range $object := .Objects -}} + type {{lcFirst $object.Name}}{{ucFirst $.ResolverType}} struct { *{{$.ResolverType}} } +{{ end }} + +{{ if (ne .RemainingSource "") }} + // !!! WARNING !!! + // The code below was going to be deleted when updating resolvers. It has been copied here so you have + // one last chance to move it out of harms way if you want. There are two reasons this happens: + // - When renaming or deleting a resolver the old code will be put in here. You can safely delete + // it when you're done. + // - You have helper methods in this file. Move them out to keep these resolver files clean. + {{ .RemainingSource }} +{{ end }} diff --git a/plugin/resolvergen/resolver_test.go b/plugin/resolvergen/resolver_test.go new file mode 100644 index 0000000..d6b0074 --- /dev/null +++ b/plugin/resolvergen/resolver_test.go @@ -0,0 +1,168 @@ +package resolvergen + +import ( + "fmt" + "os" + "syscall" + "testing" + + "github.com/stretchr/testify/require" + "golang.org/x/tools/go/packages" + + "github.com/niko0xdev/gqlgen/codegen" + "github.com/niko0xdev/gqlgen/codegen/config" +) + +func TestLayoutSingleFile(t *testing.T) { + _ = syscall.Unlink("testdata/singlefile/out/resolver.go") + + cfg, err := config.LoadConfig("testdata/singlefile/gqlgen.yml") + require.NoError(t, err) + p := Plugin{} + + require.NoError(t, cfg.Init()) + + data, err := codegen.BuildData(cfg) + if err != nil { + panic(err) + } + + require.NoError(t, p.GenerateCode(data)) + assertNoErrors(t, "github.com/niko0xdev/gqlgen/plugin/resolvergen/testdata/singlefile/out") +} + +func TestLayoutFollowSchema(t *testing.T) { + testFollowSchemaPersistence(t, "testdata/followschema") + + b, err := os.ReadFile("testdata/followschema/out/schema.resolvers.go") + require.NoError(t, err) + source := string(b) + + require.Contains(t, source, "(_ *customresolver.Resolver, err error)") + require.Contains(t, source, "// Named return values are supported.") + require.Contains(t, source, "// CustomerResolverType.Name implementation") + require.Contains(t, source, "// AUserHelperFunction implementation") +} + +func TestLayoutFollowSchemaWithCustomFilename(t *testing.T) { + testFollowSchemaPersistence(t, "testdata/filetemplate") + + b, err := os.ReadFile("testdata/filetemplate/out/schema.custom.go") + require.NoError(t, err) + source := string(b) + + require.Contains(t, source, "// CustomerResolverType.Resolver implementation") + require.Contains(t, source, "// CustomerResolverType.Name implementation") + require.Contains(t, source, "// AUserHelperFunction implementation") +} + +func TestLayoutInvalidModelPath(t *testing.T) { + cfg, err := config.LoadConfig("testdata/invalid_model_path/gqlgen.yml") + require.NoError(t, err) + + require.NoError(t, cfg.Init()) + + _, err = codegen.BuildData(cfg) + require.Error(t, err) +} + +func TestOmitTemplateComment(t *testing.T) { + _ = syscall.Unlink("testdata/omit_template_comment/resolver.go") + + cfg, err := config.LoadConfig("testdata/omit_template_comment/gqlgen.yml") + require.NoError(t, err) + p := Plugin{} + + require.NoError(t, cfg.Init()) + + data, err := codegen.BuildData(cfg) + if err != nil { + panic(err) + } + + require.NoError(t, p.GenerateCode(data)) + assertNoErrors(t, "github.com/niko0xdev/gqlgen/plugin/resolvergen/testdata/omit_template_comment/out") +} + +func TestResolver_Implementation(t *testing.T) { + _ = syscall.Unlink("testdata/resolver_implementor/resolver.go") + + cfg, err := config.LoadConfig("testdata/resolver_implementor/gqlgen.yml") + require.NoError(t, err) + p := Plugin{} + + require.NoError(t, cfg.Init()) + + data, err := codegen.BuildData(cfg, &implementorTest{}) + if err != nil { + panic(err) + } + + require.NoError(t, p.GenerateCode(data)) + assertNoErrors(t, "github.com/niko0xdev/gqlgen/plugin/resolvergen/testdata/resolver_implementor/out") +} + +func TestCustomResolverTemplate(t *testing.T) { + _ = syscall.Unlink("testdata/resolvertemplate/out/resolver.go") + cfg, err := config.LoadConfig("testdata/resolvertemplate/gqlgen.yml") + require.NoError(t, err) + p := Plugin{} + + require.NoError(t, cfg.Init()) + + data, err := codegen.BuildData(cfg) + if err != nil { + panic(err) + } + + require.NoError(t, p.GenerateCode(data)) +} + +func testFollowSchemaPersistence(t *testing.T, dir string) { + _ = syscall.Unlink(dir + "/out/resolver.go") + + cfg, err := config.LoadConfig(dir + "/gqlgen.yml") + require.NoError(t, err) + p := Plugin{} + + require.NoError(t, cfg.Init()) + + data, err := codegen.BuildData(cfg) + if err != nil { + panic(err) + } + + require.NoError(t, p.GenerateCode(data)) + assertNoErrors(t, "github.com/niko0xdev/gqlgen/plugin/resolvergen/"+dir+"/out") +} + +func assertNoErrors(t *testing.T, pkg string) { + pkgs, err := packages.Load(&packages.Config{ + Mode: packages.NeedName | + packages.NeedFiles | + packages.NeedCompiledGoFiles | + packages.NeedImports | + packages.NeedTypes | + packages.NeedTypesSizes, + }, pkg) + if err != nil { + panic(err) + } + + hasErrors := false + for _, pkg := range pkgs { + for _, err := range pkg.Errors { + hasErrors = true + fmt.Println(err.Pos + ":" + err.Msg) + } + } + if hasErrors { + t.Fatal("see compilation errors above") + } +} + +type implementorTest struct{} + +func (i *implementorTest) Implement(field *codegen.Field) string { + return "panic(\"implementor implemented me\")" +} diff --git a/plugin/resolvergen/testdata/filetemplate/gqlgen.yml b/plugin/resolvergen/testdata/filetemplate/gqlgen.yml new file mode 100644 index 0000000..16deb49 --- /dev/null +++ b/plugin/resolvergen/testdata/filetemplate/gqlgen.yml @@ -0,0 +1,16 @@ +schema: + - "testdata/schema.graphql" + +exec: + filename: testdata/singlefile/out/ignored.go +model: + filename: testdata/singlefile/out/generated.go +resolver: + type: CustomResolverType + layout: follow-schema + dir: testdata/filetemplate/out + filename_template: "{name}.custom.go" + +models: + Resolver: + model: github.com/niko0xdev/gqlgen/plugin/resolvergen/testdata/singlefile/out.Resolver diff --git a/plugin/resolvergen/testdata/filetemplate/out/model.go b/plugin/resolvergen/testdata/filetemplate/out/model.go new file mode 100644 index 0000000..47712a1 --- /dev/null +++ b/plugin/resolvergen/testdata/filetemplate/out/model.go @@ -0,0 +1,13 @@ +package customresolver + +import "context" + +type Resolver struct{} + +type QueryResolver interface { + Resolver(ctx context.Context) (*Resolver, error) +} + +type ResolverResolver interface { + Name(ctx context.Context, obj *Resolver) (string, error) +} diff --git a/plugin/resolvergen/testdata/filetemplate/out/resolver.go b/plugin/resolvergen/testdata/filetemplate/out/resolver.go new file mode 100644 index 0000000..fbe00ec --- /dev/null +++ b/plugin/resolvergen/testdata/filetemplate/out/resolver.go @@ -0,0 +1,7 @@ +package customresolver + +// This file will not be regenerated automatically. +// +// It serves as dependency injection for your app, add any dependencies you require here. + +type CustomResolverType struct{} diff --git a/plugin/resolvergen/testdata/filetemplate/out/schema.custom.go b/plugin/resolvergen/testdata/filetemplate/out/schema.custom.go new file mode 100644 index 0000000..a6bf177 --- /dev/null +++ b/plugin/resolvergen/testdata/filetemplate/out/schema.custom.go @@ -0,0 +1,44 @@ +package customresolver + +// 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. +// Code generated by github.com/niko0xdev/gqlgen version v0.17.41-dev + +import ( + "context" + + customresolver "github.com/niko0xdev/gqlgen/plugin/resolvergen/testdata/singlefile/out" +) + +// Resolver is the resolver for the resolver field. +func (r *queryCustomResolverType) Resolver(ctx context.Context) (*customresolver.Resolver, error) { + // CustomerResolverType.Resolver implementation + return nil, nil +} + +// Name is the resolver for the name field. +func (r *resolverCustomResolverType) Name(ctx context.Context, obj *customresolver.Resolver) (string, error) { + // CustomerResolverType.Name implementation + return "", nil +} + +// Query returns customresolver.QueryResolver implementation. +func (r *CustomResolverType) Query() customresolver.QueryResolver { return &queryCustomResolverType{r} } + +// Resolver returns customresolver.ResolverResolver implementation. +func (r *CustomResolverType) Resolver() customresolver.ResolverResolver { + return &resolverCustomResolverType{r} +} + +type queryCustomResolverType struct{ *CustomResolverType } +type resolverCustomResolverType struct{ *CustomResolverType } + +// !!! WARNING !!! +// The code below was going to be deleted when updating resolvers. It has been copied here so you have +// one last chance to move it out of harms way if you want. There are two reasons this happens: +// - When renaming or deleting a resolver the old code will be put in here. You can safely delete +// it when you're done. +// - You have helper methods in this file. Move them out to keep these resolver files clean. +func AUserHelperFunction() { + // AUserHelperFunction implementation +} diff --git a/plugin/resolvergen/testdata/followschema/gqlgen.yml b/plugin/resolvergen/testdata/followschema/gqlgen.yml new file mode 100644 index 0000000..f0ec2fe --- /dev/null +++ b/plugin/resolvergen/testdata/followschema/gqlgen.yml @@ -0,0 +1,15 @@ +schema: + - "testdata/schema.graphql" + +exec: + filename: testdata/singlefile/out/ignored.go +model: + filename: testdata/singlefile/out/generated.go +resolver: + type: CustomResolverType + layout: follow-schema + dir: testdata/followschema/out + +models: + Resolver: + model: github.com/niko0xdev/gqlgen/plugin/resolvergen/testdata/singlefile/out.Resolver diff --git a/plugin/resolvergen/testdata/followschema/out/model.go b/plugin/resolvergen/testdata/followschema/out/model.go new file mode 100644 index 0000000..47712a1 --- /dev/null +++ b/plugin/resolvergen/testdata/followschema/out/model.go @@ -0,0 +1,13 @@ +package customresolver + +import "context" + +type Resolver struct{} + +type QueryResolver interface { + Resolver(ctx context.Context) (*Resolver, error) +} + +type ResolverResolver interface { + Name(ctx context.Context, obj *Resolver) (string, error) +} diff --git a/plugin/resolvergen/testdata/followschema/out/resolver.go b/plugin/resolvergen/testdata/followschema/out/resolver.go new file mode 100644 index 0000000..fbe00ec --- /dev/null +++ b/plugin/resolvergen/testdata/followschema/out/resolver.go @@ -0,0 +1,7 @@ +package customresolver + +// This file will not be regenerated automatically. +// +// It serves as dependency injection for your app, add any dependencies you require here. + +type CustomResolverType struct{} diff --git a/plugin/resolvergen/testdata/followschema/out/schema.resolvers.go b/plugin/resolvergen/testdata/followschema/out/schema.resolvers.go new file mode 100644 index 0000000..ac92647 --- /dev/null +++ b/plugin/resolvergen/testdata/followschema/out/schema.resolvers.go @@ -0,0 +1,44 @@ +package customresolver + +// 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. +// Code generated by github.com/niko0xdev/gqlgen version v0.17.41-dev + +import ( + "context" + + customresolver "github.com/niko0xdev/gqlgen/plugin/resolvergen/testdata/singlefile/out" +) + +// Resolver is the resolver for the resolver field. +func (r *queryCustomResolverType) Resolver(ctx context.Context) (_ *customresolver.Resolver, err error) { + // Named return values are supported. + return +} + +// Name is the resolver for the name field. +func (r *resolverCustomResolverType) Name(ctx context.Context, obj *customresolver.Resolver) (string, error) { + // CustomerResolverType.Name implementation + return "", nil +} + +// Query returns customresolver.QueryResolver implementation. +func (r *CustomResolverType) Query() customresolver.QueryResolver { return &queryCustomResolverType{r} } + +// Resolver returns customresolver.ResolverResolver implementation. +func (r *CustomResolverType) Resolver() customresolver.ResolverResolver { + return &resolverCustomResolverType{r} +} + +type queryCustomResolverType struct{ *CustomResolverType } +type resolverCustomResolverType struct{ *CustomResolverType } + +// !!! WARNING !!! +// The code below was going to be deleted when updating resolvers. It has been copied here so you have +// one last chance to move it out of harms way if you want. There are two reasons this happens: +// - When renaming or deleting a resolver the old code will be put in here. You can safely delete +// it when you're done. +// - You have helper methods in this file. Move them out to keep these resolver files clean. +func AUserHelperFunction() { + // AUserHelperFunction implementation +} diff --git a/plugin/resolvergen/testdata/invalid_model_path/gqlgen.yml b/plugin/resolvergen/testdata/invalid_model_path/gqlgen.yml new file mode 100644 index 0000000..6089c89 --- /dev/null +++ b/plugin/resolvergen/testdata/invalid_model_path/gqlgen.yml @@ -0,0 +1,6 @@ +schema: + - "testdata/schema.graphql" + +models: + Resolver: + model: github.com/niko0xdev/invalid/invalid/invalid/nope.Resolver diff --git a/plugin/resolvergen/testdata/omit_template_comment/gqlgen.yml b/plugin/resolvergen/testdata/omit_template_comment/gqlgen.yml new file mode 100644 index 0000000..18b03d0 --- /dev/null +++ b/plugin/resolvergen/testdata/omit_template_comment/gqlgen.yml @@ -0,0 +1,16 @@ +schema: + - "testdata/schema.graphql" + +exec: + filename: testdata/singlefile/out/ignored.go +model: + filename: testdata/singlefile/out/generated.go +resolver: + type: CustomResolverType + layout: follow-schema + dir: testdata/omit_template_comment/out + omit_template_comment: true + +models: + Resolver: + model: github.com/niko0xdev/gqlgen/plugin/resolvergen/testdata/singlefile/out.Resolver diff --git a/plugin/resolvergen/testdata/omit_template_comment/out/resolver.go b/plugin/resolvergen/testdata/omit_template_comment/out/resolver.go new file mode 100644 index 0000000..640b3c5 --- /dev/null +++ b/plugin/resolvergen/testdata/omit_template_comment/out/resolver.go @@ -0,0 +1,7 @@ +package out + +// This file will not be regenerated automatically. +// +// It serves as dependency injection for your app, add any dependencies you require here. + +type CustomResolverType struct{} diff --git a/plugin/resolvergen/testdata/omit_template_comment/out/schema.resolvers.go b/plugin/resolvergen/testdata/omit_template_comment/out/schema.resolvers.go new file mode 100644 index 0000000..f14ed70 --- /dev/null +++ b/plugin/resolvergen/testdata/omit_template_comment/out/schema.resolvers.go @@ -0,0 +1,30 @@ +package out + +// 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. +// Code generated by github.com/niko0xdev/gqlgen version v0.17.41-dev + +import ( + "context" + "fmt" + + customresolver "github.com/niko0xdev/gqlgen/plugin/resolvergen/testdata/singlefile/out" +) + +func (r *queryCustomResolverType) Resolver(ctx context.Context) (*customresolver.Resolver, error) { + panic(fmt.Errorf("not implemented: Resolver - resolver")) +} + +// This comment was added manually after code generation. It will remain after re-generation. +func (r *resolverCustomResolverType) Name(ctx context.Context, obj *customresolver.Resolver) (string, error) { + panic(fmt.Errorf("not implemented: Name - name")) +} + +func (r *CustomResolverType) Query() customresolver.QueryResolver { return &queryCustomResolverType{r} } + +func (r *CustomResolverType) Resolver() customresolver.ResolverResolver { + return &resolverCustomResolverType{r} +} + +type queryCustomResolverType struct{ *CustomResolverType } +type resolverCustomResolverType struct{ *CustomResolverType } diff --git a/plugin/resolvergen/testdata/resolver_implementor/gqlgen.yml b/plugin/resolvergen/testdata/resolver_implementor/gqlgen.yml new file mode 100644 index 0000000..efea14e --- /dev/null +++ b/plugin/resolvergen/testdata/resolver_implementor/gqlgen.yml @@ -0,0 +1,15 @@ +schema: + - "testdata/schema.graphql" + +exec: + filename: testdata/resolver_implementor/out/ignored.go +model: + filename: testdata/resolver_implementor/out/generated.go +resolver: + type: CustomResolverType + layout: follow-schema + dir: testdata/resolver_implementor/out + +models: + Resolver: + model: github.com/niko0xdev/gqlgen/plugin/resolvergen/testdata/resolver_implementor/out.Resolver diff --git a/plugin/resolvergen/testdata/resolver_implementor/out/model.go b/plugin/resolvergen/testdata/resolver_implementor/out/model.go new file mode 100644 index 0000000..47712a1 --- /dev/null +++ b/plugin/resolvergen/testdata/resolver_implementor/out/model.go @@ -0,0 +1,13 @@ +package customresolver + +import "context" + +type Resolver struct{} + +type QueryResolver interface { + Resolver(ctx context.Context) (*Resolver, error) +} + +type ResolverResolver interface { + Name(ctx context.Context, obj *Resolver) (string, error) +} diff --git a/plugin/resolvergen/testdata/resolver_implementor/out/resolver.go b/plugin/resolvergen/testdata/resolver_implementor/out/resolver.go new file mode 100644 index 0000000..fbe00ec --- /dev/null +++ b/plugin/resolvergen/testdata/resolver_implementor/out/resolver.go @@ -0,0 +1,7 @@ +package customresolver + +// This file will not be regenerated automatically. +// +// It serves as dependency injection for your app, add any dependencies you require here. + +type CustomResolverType struct{} diff --git a/plugin/resolvergen/testdata/resolver_implementor/out/schema.resolvers.go b/plugin/resolvergen/testdata/resolver_implementor/out/schema.resolvers.go new file mode 100644 index 0000000..bf76ff4 --- /dev/null +++ b/plugin/resolvergen/testdata/resolver_implementor/out/schema.resolvers.go @@ -0,0 +1,28 @@ +package customresolver + +// 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. +// Code generated by github.com/niko0xdev/gqlgen version v0.17.41-dev + +import ( + "context" +) + +// Resolver is the resolver for the resolver field. +func (r *queryCustomResolverType) Resolver(ctx context.Context) (*Resolver, error) { + panic("implementor implemented me") +} + +// Name is the resolver for the name field. +func (r *resolverCustomResolverType) Name(ctx context.Context, obj *Resolver) (string, error) { + panic("implementor implemented me") +} + +// Query returns QueryResolver implementation. +func (r *CustomResolverType) Query() QueryResolver { return &queryCustomResolverType{r} } + +// Resolver returns ResolverResolver implementation. +func (r *CustomResolverType) Resolver() ResolverResolver { return &resolverCustomResolverType{r} } + +type queryCustomResolverType struct{ *CustomResolverType } +type resolverCustomResolverType struct{ *CustomResolverType } diff --git a/plugin/resolvergen/testdata/resolvertemplate/customResolverTemplate.gotpl b/plugin/resolvergen/testdata/resolvertemplate/customResolverTemplate.gotpl new file mode 100644 index 0000000..ea3ae27 --- /dev/null +++ b/plugin/resolvergen/testdata/resolvertemplate/customResolverTemplate.gotpl @@ -0,0 +1,54 @@ +{{ reserveImport "context" }} +{{ reserveImport "fmt" }} +{{ reserveImport "io" }} +{{ reserveImport "strconv" }} +{{ reserveImport "time" }} +{{ reserveImport "sync" }} +{{ reserveImport "errors" }} +{{ reserveImport "bytes" }} +{{ reserveImport "encoding/json" }} + +{{ reserveImport "github.com/vektah/gqlparser/v2" }} +{{ reserveImport "github.com/vektah/gqlparser/v2/ast" }} +{{ reserveImport "github.com/niko0xdev/gqlgen/graphql" }} +{{ reserveImport "github.com/niko0xdev/gqlgen/graphql/introspection" }} + +{{ .Imports }} + +{{ if .HasRoot }} + type {{.ResolverType}} struct {} +{{ end }} + +{{ range $resolver := .Resolvers -}} + {{ if $resolver.Comment -}} + // {{ $resolver.Comment }} + {{- else if not $.OmitTemplateComment -}} + // {{ $resolver.Field.GoFieldName }} is the resolver for the {{ $resolver.Field.Name }} field. + {{- end }} + func (r *{{lcFirst $resolver.Object.Name}}{{ucFirst $.ResolverType}}) {{$resolver.Field.GoFieldName}}{{ with $resolver.PrevDecl }}{{ $resolver.Field.ShortResolverSignature .Type }}{{ else }}{{ $resolver.Field.ShortResolverDeclaration }}{{ end }}{ + // Custom Resolver implementation + panic(fmt.Errorf("custom Resolver not implemented: {{ $resolver.Field.GoFieldName }} - {{lcFirst $resolver.Field.GoFieldName }}")) + } + +{{ end }} + +{{ range $object := .Objects -}} + {{ if not $.OmitTemplateComment -}} + // {{ucFirst $object.Name}} returns {{ $object.ResolverInterface | ref }} implementation. + {{- end }} + func (r *{{$.ResolverType}}) {{ucFirst $object.Name}}() {{ $object.ResolverInterface | ref }} { return &{{lcFirst $object.Name}}{{ucFirst $.ResolverType}}{r} } +{{ end }} + +{{ range $object := .Objects -}} + type {{lcFirst $object.Name}}{{ucFirst $.ResolverType}} struct { *{{$.ResolverType}} } +{{ end }} + +{{ if (ne .RemainingSource "") }} + // !!! WARNING !!! + // The code below was going to be deleted when updating resolvers. It has been copied here so you have + // one last chance to move it out of harms way if you want. There are two reasons this happens: + // - When renaming or deleting a resolver the old code will be put in here. You can safely delete + // it when you're done. + // - You have helper methods in this file. Move them out to keep these resolver files clean. + {{ .RemainingSource }} +{{ end }} diff --git a/plugin/resolvergen/testdata/resolvertemplate/gqlgen.yml b/plugin/resolvergen/testdata/resolvertemplate/gqlgen.yml new file mode 100644 index 0000000..771c43b --- /dev/null +++ b/plugin/resolvergen/testdata/resolvertemplate/gqlgen.yml @@ -0,0 +1,17 @@ +schema: + - "testdata/schema.graphql" + +exec: + filename: testdata/singlefile/out/ignored.go +model: + filename: testdata/singlefile/out/generated.go +resolver: + type: CustomResolverType + layout: follow-schema + dir: testdata/resolvertemplate/out + filename_template: "{name}.resolvers.go" + resolver_template: "testdata/resolvertemplate/customResolverTemplate.gotpl" + +models: + Resolver: + model: github.com/niko0xdev/gqlgen/plugin/resolvergen/testdata/singlefile/out.Resolver diff --git a/plugin/resolvergen/testdata/resolvertemplate/out/resolver.go b/plugin/resolvergen/testdata/resolvertemplate/out/resolver.go new file mode 100644 index 0000000..640b3c5 --- /dev/null +++ b/plugin/resolvergen/testdata/resolvertemplate/out/resolver.go @@ -0,0 +1,7 @@ +package out + +// This file will not be regenerated automatically. +// +// It serves as dependency injection for your app, add any dependencies you require here. + +type CustomResolverType struct{} diff --git a/plugin/resolvergen/testdata/resolvertemplate/out/schema.resolvers.go b/plugin/resolvergen/testdata/resolvertemplate/out/schema.resolvers.go new file mode 100644 index 0000000..4b0fb0e --- /dev/null +++ b/plugin/resolvergen/testdata/resolvertemplate/out/schema.resolvers.go @@ -0,0 +1,35 @@ +package out + +// 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. +// Code generated by github.com/niko0xdev/gqlgen version v0.17.41-dev + +import ( + "context" + "fmt" + + customresolver "github.com/niko0xdev/gqlgen/plugin/resolvergen/testdata/singlefile/out" +) + +// Resolver is the resolver for the resolver field. +func (r *queryCustomResolverType) Resolver(ctx context.Context) (*customresolver.Resolver, error) { + // Custom Resolver implementation + panic(fmt.Errorf("custom Resolver not implemented: Resolver - resolver")) +} + +// Name is the resolver for the name field. +func (r *resolverCustomResolverType) Name(ctx context.Context, obj *customresolver.Resolver) (string, error) { + // Custom Resolver implementation + panic(fmt.Errorf("custom Resolver not implemented: Name - name")) +} + +// Query returns customresolver.QueryResolver implementation. +func (r *CustomResolverType) Query() customresolver.QueryResolver { return &queryCustomResolverType{r} } + +// Resolver returns customresolver.ResolverResolver implementation. +func (r *CustomResolverType) Resolver() customresolver.ResolverResolver { + return &resolverCustomResolverType{r} +} + +type queryCustomResolverType struct{ *CustomResolverType } +type resolverCustomResolverType struct{ *CustomResolverType } diff --git a/plugin/resolvergen/testdata/return_values/gqlgen.yml b/plugin/resolvergen/testdata/return_values/gqlgen.yml new file mode 100644 index 0000000..ea8ffcc --- /dev/null +++ b/plugin/resolvergen/testdata/return_values/gqlgen.yml @@ -0,0 +1,11 @@ +schema: + - schema.graphqls + +exec: + filename: ignored.go +model: + filename: model.go +resolver: + filename: resolvers.go + +resolvers_always_return_pointers: false diff --git a/plugin/resolvergen/testdata/return_values/ignored.go b/plugin/resolvergen/testdata/return_values/ignored.go new file mode 100644 index 0000000..ff06eb3 --- /dev/null +++ b/plugin/resolvergen/testdata/return_values/ignored.go @@ -0,0 +1,3315 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package return_values + +import ( + "bytes" + "context" + "embed" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/graphql/introspection" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// 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 { + Query() QueryResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + Query struct { + User func(childComplexity int) int + UserPointer func(childComplexity int) int + } + + User struct { + ID func(childComplexity int) int + Name func(childComplexity int) int + } +} + +type QueryResolver interface { + User(ctx context.Context) (User, error) + UserPointer(ctx context.Context) (*User, error) +} + +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 "Query.user": + if e.complexity.Query.User == nil { + break + } + + return e.complexity.Query.User(childComplexity), true + + case "Query.userPointer": + if e.complexity.Query.UserPointer == nil { + break + } + + return e.complexity.Query.UserPointer(childComplexity), true + + case "User.id": + if e.complexity.User.ID == nil { + break + } + + return e.complexity.User.ID(childComplexity), true + + case "User.name": + if e.complexity.User.Name == nil { + break + } + + return e.complexity.User.Name(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e} + inputUnmarshalMap := graphql.BuildUnmarshalerMap() + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data := ec._Query(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + 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 +} + +//go:embed "schema.graphqls" +var sourcesFS embed.FS + +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) +} + +var sources = []*ast.Source{ + {Name: "schema.graphqls", Input: sourceData("schema.graphqls"), BuiltIn: false}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// 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___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) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_user(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().User(rctx) + }) + 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.(User) + fc.Result = res + return ec.marshalNUser2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋresolvergenᚋtestdataᚋreturn_valuesᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query_userPointer(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_userPointer(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().UserPointer(rctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*User) + fc.Result = res + return ec.marshalOUser2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋresolvergenᚋtestdataᚋreturn_valuesᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_userPointer(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext_User_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, 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.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, 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.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), 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) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), 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.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), 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.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), 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.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), 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.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + 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 { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +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 "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 "userPointer": + 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_userPointer(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.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) + + case "__schema": + + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) + + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + +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": + + out.Values[i] = ec._User_id(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "name": + + out.Values[i] = ec._User_name(ctx, field, obj) + + 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 __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": + + out.Values[i] = ec.___Directive_name(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "description": + + out.Values[i] = ec.___Directive_description(ctx, field, obj) + + case "locations": + + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "args": + + out.Values[i] = ec.___Directive_args(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "isRepeatable": + + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + + 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": + + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "description": + + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + + case "isDeprecated": + + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "deprecationReason": + + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + + 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": + + out.Values[i] = ec.___Field_name(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "description": + + out.Values[i] = ec.___Field_description(ctx, field, obj) + + case "args": + + out.Values[i] = ec.___Field_args(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "type": + + out.Values[i] = ec.___Field_type(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "isDeprecated": + + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "deprecationReason": + + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + + 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": + + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "description": + + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + + case "type": + + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "defaultValue": + + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + + 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 "description": + + out.Values[i] = ec.___Schema_description(ctx, field, obj) + + case "types": + + out.Values[i] = ec.___Schema_types(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "queryType": + + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "mutationType": + + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + + case "subscriptionType": + + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + + case "directives": + + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + + 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": + + out.Values[i] = ec.___Type_kind(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "name": + + out.Values[i] = ec.___Type_name(ctx, field, obj) + + case "description": + + out.Values[i] = ec.___Type_description(ctx, field, obj) + + case "fields": + + out.Values[i] = ec.___Type_fields(ctx, field, obj) + + case "interfaces": + + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + + case "possibleTypes": + + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + + case "enumValues": + + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + + case "inputFields": + + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + + case "ofType": + + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + + case "specifiedByURL": + + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + + 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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + 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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalNUser2githubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋresolvergenᚋtestdataᚋreturn_valuesᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { + return ec._User(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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, "the requested element is null which the schema does not allow") + } + 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, "the requested element is null which the schema does not allow") + } + } + 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) 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) marshalOUser2ᚖgithubᚗcomᚋniko0xdevᚋgqlgenᚋpluginᚋresolvergenᚋtestdataᚋreturn_valuesᚐUser(ctx context.Context, sel ast.SelectionSet, v *User) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._User(ctx, sel, v) +} + +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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ᚋniko0xdevᚋ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/plugin/resolvergen/testdata/return_values/model.go b/plugin/resolvergen/testdata/return_values/model.go new file mode 100644 index 0000000..c8c67f2 --- /dev/null +++ b/plugin/resolvergen/testdata/return_values/model.go @@ -0,0 +1,8 @@ +// Code generated by github.com/niko0xdev/gqlgen, DO NOT EDIT. + +package return_values + +type User struct { + ID string `json:"id"` + Name string `json:"name"` +} diff --git a/plugin/resolvergen/testdata/return_values/resolvers.go b/plugin/resolvergen/testdata/return_values/resolvers.go new file mode 100644 index 0000000..9776e03 --- /dev/null +++ b/plugin/resolvergen/testdata/return_values/resolvers.go @@ -0,0 +1,24 @@ +package return_values + +// THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES. + +import ( + "context" +) + +type Resolver struct{} + +// // foo +func (r *queryResolver) User(ctx context.Context) (User, error) { + panic("not implemented") +} + +// // foo +func (r *queryResolver) UserPointer(ctx context.Context) (*User, error) { + panic("not implemented") +} + +// Query returns QueryResolver implementation. +func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } + +type queryResolver struct{ *Resolver } diff --git a/plugin/resolvergen/testdata/return_values/return_values_test.go b/plugin/resolvergen/testdata/return_values/return_values_test.go new file mode 100644 index 0000000..744a33a --- /dev/null +++ b/plugin/resolvergen/testdata/return_values/return_values_test.go @@ -0,0 +1,18 @@ +package return_values + +import ( + "reflect" + "testing" + + "github.com/stretchr/testify/require" +) + +//go:generate rm -f resolvers.go +//go:generate go run ../../../../testdata/gqlgen.go -config gqlgen.yml + +func TestResolverReturnTypes(t *testing.T) { + // verify that the return value of the User resolver is a struct, not a pointer + require.Equal(t, "struct", reflect.TypeOf((&queryResolver{}).User).Out(0).Kind().String()) + // the UserPointer resolver should return a pointer + require.Equal(t, "ptr", reflect.TypeOf((&queryResolver{}).UserPointer).Out(0).Kind().String()) +} diff --git a/plugin/resolvergen/testdata/return_values/schema.graphqls b/plugin/resolvergen/testdata/return_values/schema.graphqls new file mode 100644 index 0000000..f016c60 --- /dev/null +++ b/plugin/resolvergen/testdata/return_values/schema.graphqls @@ -0,0 +1,9 @@ +type User { + id: ID! + name: String! +} + +type Query { + user: User! + userPointer: User +} diff --git a/plugin/resolvergen/testdata/schema.graphql b/plugin/resolvergen/testdata/schema.graphql new file mode 100644 index 0000000..7ced739 --- /dev/null +++ b/plugin/resolvergen/testdata/schema.graphql @@ -0,0 +1,7 @@ +type Query { + resolver: Resolver! +} + +type Resolver { + name: String! +} diff --git a/plugin/resolvergen/testdata/singlefile/gqlgen.yml b/plugin/resolvergen/testdata/singlefile/gqlgen.yml new file mode 100644 index 0000000..c6318c5 --- /dev/null +++ b/plugin/resolvergen/testdata/singlefile/gqlgen.yml @@ -0,0 +1,14 @@ +schema: + - "testdata/schema.graphql" + +exec: + filename: testdata/singlefile/out/ignored.go +model: + filename: testdata/singlefile/out/generated.go +resolver: + filename: testdata/singlefile/out/resolver.go + type: CustomResolverType + +models: + Resolver: + model: github.com/niko0xdev/gqlgen/plugin/resolvergen/testdata/singlefile/out.Resolver diff --git a/plugin/resolvergen/testdata/singlefile/out/model.go b/plugin/resolvergen/testdata/singlefile/out/model.go new file mode 100644 index 0000000..47712a1 --- /dev/null +++ b/plugin/resolvergen/testdata/singlefile/out/model.go @@ -0,0 +1,13 @@ +package customresolver + +import "context" + +type Resolver struct{} + +type QueryResolver interface { + Resolver(ctx context.Context) (*Resolver, error) +} + +type ResolverResolver interface { + Name(ctx context.Context, obj *Resolver) (string, error) +} diff --git a/plugin/resolvergen/testdata/singlefile/out/resolver.go b/plugin/resolvergen/testdata/singlefile/out/resolver.go new file mode 100644 index 0000000..844b077 --- /dev/null +++ b/plugin/resolvergen/testdata/singlefile/out/resolver.go @@ -0,0 +1,28 @@ +package customresolver + +// THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES. + +import ( + "context" +) + +type CustomResolverType struct{} + +// Resolver is the resolver for the resolver field. +func (r *queryCustomResolverType) Resolver(ctx context.Context) (*Resolver, error) { + panic("not implemented") +} + +// Name is the resolver for the name field. +func (r *resolverCustomResolverType) Name(ctx context.Context, obj *Resolver) (string, error) { + panic("not implemented") +} + +// Query returns QueryResolver implementation. +func (r *CustomResolverType) Query() QueryResolver { return &queryCustomResolverType{r} } + +// Resolver returns ResolverResolver implementation. +func (r *CustomResolverType) Resolver() ResolverResolver { return &resolverCustomResolverType{r} } + +type queryCustomResolverType struct{ *CustomResolverType } +type resolverCustomResolverType struct{ *CustomResolverType } diff --git a/plugin/servergen/server.go b/plugin/servergen/server.go new file mode 100644 index 0000000..3a575f9 --- /dev/null +++ b/plugin/servergen/server.go @@ -0,0 +1,57 @@ +package servergen + +import ( + _ "embed" + "errors" + "io/fs" + "log" + "os" + + "github.com/niko0xdev/gqlgen/codegen" + "github.com/niko0xdev/gqlgen/codegen/templates" + "github.com/niko0xdev/gqlgen/plugin" +) + +//go:embed server.gotpl +var serverTemplate string + +func New(filename string) plugin.Plugin { + return &Plugin{filename} +} + +type Plugin struct { + filename string +} + +var _ plugin.CodeGenerator = &Plugin{} + +func (m *Plugin) Name() string { + return "servergen" +} + +func (m *Plugin) GenerateCode(data *codegen.Data) error { + serverBuild := &ServerBuild{ + ExecPackageName: data.Config.Exec.ImportPath(), + ResolverPackageName: data.Config.Resolver.ImportPath(), + } + + if _, err := os.Stat(m.filename); errors.Is(err, fs.ErrNotExist) { + return templates.Render(templates.Options{ + PackageName: "main", + Filename: m.filename, + Data: serverBuild, + Packages: data.Config.Packages, + Template: serverTemplate, + }) + } + + log.Printf("Skipped server: %s already exists\n", m.filename) + return nil +} + +type ServerBuild struct { + codegen.Data + + ExecPackageName string + ResolverPackageName string +} diff --git a/plugin/servergen/server.gotpl b/plugin/servergen/server.gotpl new file mode 100644 index 0000000..ce270a0 --- /dev/null +++ b/plugin/servergen/server.gotpl @@ -0,0 +1,23 @@ +{{ reserveImport "context" }} +{{ reserveImport "log" }} +{{ reserveImport "net/http" }} +{{ reserveImport "os" }} +{{ reserveImport "github.com/niko0xdev/gqlgen/graphql/playground" }} +{{ reserveImport "github.com/niko0xdev/gqlgen/graphql/handler" }} + +const defaultPort = "8080" + +func main() { + port := os.Getenv("PORT") + if port == "" { + port = defaultPort + } + + srv := handler.NewDefaultServer({{ lookupImport .ExecPackageName }}.NewExecutableSchema({{ lookupImport .ExecPackageName}}.Config{Resolvers: &{{ lookupImport .ResolverPackageName}}.Resolver{}})) + + http.Handle("/", playground.Handler("GraphQL playground", "/query")) + http.Handle("/query", srv) + + log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) + log.Fatal(http.ListenAndServe(":" + port, nil)) +} diff --git a/plugin/stubgen/stubs.go b/plugin/stubgen/stubs.go new file mode 100644 index 0000000..4a58bf7 --- /dev/null +++ b/plugin/stubgen/stubs.go @@ -0,0 +1,65 @@ +package stubgen + +import ( + _ "embed" + "path/filepath" + "syscall" + + "github.com/niko0xdev/gqlgen/codegen" + "github.com/niko0xdev/gqlgen/codegen/config" + "github.com/niko0xdev/gqlgen/codegen/templates" + "github.com/niko0xdev/gqlgen/internal/code" + "github.com/niko0xdev/gqlgen/plugin" +) + +//go:embed stubs.gotpl +var stubsTemplate string + +func New(filename string, typename string) plugin.Plugin { + return &Plugin{filename: filename, typeName: typename} +} + +type Plugin struct { + filename string + typeName string +} + +var ( + _ plugin.CodeGenerator = &Plugin{} + _ plugin.ConfigMutator = &Plugin{} +) + +func (m *Plugin) Name() string { + return "stubgen" +} + +func (m *Plugin) MutateConfig(cfg *config.Config) error { + _ = syscall.Unlink(m.filename) + return nil +} + +func (m *Plugin) GenerateCode(data *codegen.Data) error { + abs, err := filepath.Abs(m.filename) + if err != nil { + return err + } + pkgName := code.NameForDir(filepath.Dir(abs)) + + return templates.Render(templates.Options{ + PackageName: pkgName, + Filename: m.filename, + Data: &ResolverBuild{ + Data: data, + TypeName: m.typeName, + }, + GeneratedHeader: true, + Packages: data.Config.Packages, + Template: stubsTemplate, + }) +} + +type ResolverBuild struct { + *codegen.Data + + TypeName string +} diff --git a/plugin/stubgen/stubs.gotpl b/plugin/stubgen/stubs.gotpl new file mode 100644 index 0000000..9b20a91 --- /dev/null +++ b/plugin/stubgen/stubs.gotpl @@ -0,0 +1,87 @@ +{{ reserveImport "context" }} +{{ reserveImport "fmt" }} +{{ reserveImport "io" }} +{{ reserveImport "strconv" }} +{{ reserveImport "time" }} +{{ reserveImport "sync" }} +{{ reserveImport "errors" }} +{{ reserveImport "bytes" }} + +{{ reserveImport "github.com/vektah/gqlparser/v2" }} +{{ reserveImport "github.com/vektah/gqlparser/v2/ast" }} +{{ reserveImport "github.com/niko0xdev/gqlgen/graphql" }} +{{ reserveImport "github.com/niko0xdev/gqlgen/graphql/introspection" }} + +{{ $root := . }} + +type {{$root.TypeName}} struct { + {{ range $object := .Objects }} + {{- if $object.HasResolvers }} + {{$object.Name}}Resolver struct { + {{- range $field := $object.Fields }} + {{- if $field.IsResolver }} + {{- $field.GoFieldName}} func{{ $field.ShortResolverDeclaration }} + {{ end }} + {{- end }} + } + {{- end }} + {{- end }} + {{range $object := .Inputs -}} + {{- if $object.HasResolvers }} + {{$object.Name}}Resolver struct { + {{- range $field := $object.Fields }} + {{- if $field.IsResolver }} + {{- $field.GoFieldName}} func{{ $field.ShortResolverDeclaration }} + {{ end }} + {{- end }} + } + {{- end }} + {{- end }} +} + +{{ range $object := .Objects -}} + {{- if $object.HasResolvers -}} + func (r *{{$.TypeName}}) {{$object.Name}}() {{ $object.ResolverInterface | ref }} { + return &{{lcFirst $root.TypeName}}{{$object.Name}}{r} + } + {{ end -}} +{{ end }} +{{ range $object := .Inputs -}} + {{- if $object.HasResolvers -}} + func (r *{{$.TypeName}}) {{$object.Name}}() {{ $object.ResolverInterface | ref }} { + return &{{lcFirst $root.TypeName}}{{$object.Name}}{r} + } + {{ end -}} +{{ end }} + +{{ range $object := .Objects -}} + {{- if $object.HasResolvers -}} + type {{lcFirst $root.TypeName}}{{$object.Name}} struct { *{{$root.TypeName}} } + + {{ range $field := $object.Fields -}} + {{- if $field.IsResolver -}} + func (r *{{lcFirst $root.TypeName}}{{$object.Name}}) {{$field.GoFieldName}}{{ $field.ShortResolverDeclaration }} { + return r.{{$object.Name}}Resolver.{{$field.GoFieldName}}(ctx, + {{- if not $object.Root }}obj,{{end -}} + {{- range $arg := $field.Args}} + {{- $arg.VarName}}, + {{- end }} + ) + } + {{ end -}} + {{ end -}} + {{ end -}} +{{ end }} +{{ range $object := .Inputs -}} + {{- if $object.HasResolvers -}} + type {{lcFirst $root.TypeName}}{{$object.Name}} struct { *{{$root.TypeName}} } + + {{ range $field := $object.Fields -}} + {{- if $field.IsResolver -}} + func (r *{{lcFirst $root.TypeName}}{{$object.Name}}) {{$field.GoFieldName}}{{ $field.ShortResolverDeclaration }} { + return r.{{$object.Name}}Resolver.{{$field.GoFieldName}}(ctx, obj, data) + } + {{ end -}} + {{ end -}} + {{ end -}} +{{ end }} diff --git a/testdata/gomod-with-leading-comments.mod b/testdata/gomod-with-leading-comments.mod new file mode 100644 index 0000000..ebf83c8 --- /dev/null +++ b/testdata/gomod-with-leading-comments.mod @@ -0,0 +1,7 @@ +// main module of gqlgen + + // and another module to test stripping of comment lines + +module github.com/niko0xdev/gqlgen // replace it for new project + +go 1.18 diff --git a/testdata/gqlgen.go b/testdata/gqlgen.go new file mode 100644 index 0000000..0c4ffc9 --- /dev/null +++ b/testdata/gqlgen.go @@ -0,0 +1,50 @@ +package main + +import ( + "flag" + "fmt" + "io" + "log" + "os" + "time" + + "github.com/niko0xdev/gqlgen/api" + "github.com/niko0xdev/gqlgen/codegen/config" + "github.com/niko0xdev/gqlgen/graphql" + "github.com/niko0xdev/gqlgen/plugin/stubgen" +) + +func main() { + stub := flag.String("stub", "", "name of stub file to generate") + cfgPath := flag.String("config", "", "path to config file (use default if omitted)") + flag.Parse() + + log.SetOutput(io.Discard) + + start := graphql.Now() + + var cfg *config.Config + var err error + if cfgPath != nil && *cfgPath != "" { + cfg, err = config.LoadConfig(*cfgPath) + } else { + cfg, err = config.LoadConfigFromDefaultLocations() + } + if err != nil { + fmt.Fprintln(os.Stderr, "failed to load config", err.Error()) + os.Exit(2) + } + + var options []api.Option + if *stub != "" { + options = append(options, api.AddPlugin(stubgen.New(*stub, "Stub"))) + } + + err = api.Generate(cfg, options...) + if err != nil { + fmt.Fprintln(os.Stderr, err.Error()) + os.Exit(3) + } + + fmt.Printf("Generated %s in %4.2fs\n", cfg.Exec.ImportPath(), time.Since(start).Seconds()) +}